LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - glbltree.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 736 0.0 %
Date: 2012-08-25 Functions: 0 50 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1139 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 <vcl/msgbox.hxx>
      30                 :            : #include <svl/stritem.hxx>
      31                 :            : #include <sfx2/fcontnr.hxx>
      32                 :            : #include <sfx2/linkmgr.hxx>
      33                 :            : #include <sfx2/dispatch.hxx>
      34                 :            : #include <svl/urihelper.hxx>
      35                 :            : #include <sfx2/docfile.hxx>
      36                 :            : #include <vcl/help.hxx>
      37                 :            : #include <sot/filelist.hxx>
      38                 :            : #include <svl/eitem.hxx>
      39                 :            : #include <svl/urlbmk.hxx>
      40                 :            : #include <svtools/filter.hxx>
      41                 :            : #include <sfx2/docinsert.hxx>
      42                 :            : #include <sfx2/filedlghelper.hxx>
      43                 :            : 
      44                 :            : #include <sfx2/app.hxx>
      45                 :            : #include <swmodule.hxx>
      46                 :            : #include <wrtsh.hxx>
      47                 :            : #include <view.hxx>
      48                 :            : #include <docsh.hxx>
      49                 :            : #include <content.hxx>
      50                 :            : #include <edglbldc.hxx>
      51                 :            : #include <section.hxx>
      52                 :            : #include <tox.hxx>
      53                 :            : #include <cnttab.hxx>
      54                 :            : #define NAVIPI_CXX
      55                 :            : #include <navipi.hxx>
      56                 :            : #include <navicont.hxx>
      57                 :            : #include <edtwin.hxx>
      58                 :            : #include <uitool.hxx>
      59                 :            : 
      60                 :            : #include <cmdid.h>
      61                 :            : #include <helpid.h>
      62                 :            : #include <navipi.hrc>
      63                 :            : #include <utlui.hrc>
      64                 :            : #include <comcore.hrc>
      65                 :            : #include <globals.hrc>
      66                 :            : #include "swabstdlg.hxx"
      67                 :            : 
      68                 :            : using namespace ::com::sun::star::uno;
      69                 :            : using ::rtl::OUString;
      70                 :            : 
      71                 :            : // Kontextmenue fuer GlobalTree
      72                 :            : #define CTX_INSERT_ANY_INDEX 10
      73                 :            : #define CTX_INSERT_FILE     11
      74                 :            : #define CTX_INSERT_NEW_FILE 12
      75                 :            : #define CTX_INSERT_TEXT     13
      76                 :            : 
      77                 :            : #define CTX_UPDATE_SEL      20
      78                 :            : #define CTX_UPDATE_INDEX    21
      79                 :            : #define CTX_UPDATE_LINK     22
      80                 :            : #define CTX_UPDATE_ALL      23
      81                 :            : 
      82                 :            : #define CTX_UPDATE          1
      83                 :            : #define CTX_INSERT          2
      84                 :            : #define CTX_EDIT            3
      85                 :            : #define CTX_DELETE          4
      86                 :            : #define CTX_EDIT_LINK       5
      87                 :            : 
      88                 :            : #define GLOBAL_UPDATE_TIMEOUT 2000
      89                 :            : 
      90                 :            : // Flags fuer PopupMenu-enable/disable
      91                 :            : #define ENABLE_INSERT_IDX   0x0001
      92                 :            : #define ENABLE_INSERT_FILE  0x0002
      93                 :            : #define ENABLE_INSERT_TEXT  0x0004
      94                 :            : #define ENABLE_EDIT         0x0008
      95                 :            : #define ENABLE_DELETE       0x0010
      96                 :            : #define ENABLE_UPDATE       0x0020
      97                 :            : #define ENABLE_UPDATE_SEL   0x0040
      98                 :            : #define ENABLE_EDIT_LINK    0x0080
      99                 :            : 
     100                 :            : // TabPos nach links schieben
     101                 :            : #define  GLBL_TABPOS_SUB 5
     102                 :            : 
     103                 :            : const SfxObjectShell* SwGlobalTree::pShowShell = 0;
     104                 :            : static const char* aHelpForMenu[] =
     105                 :            : {
     106                 :            :     0,                          //
     107                 :            :     HID_GLBLTREE_UPDATE,        //CTX_UPDATE
     108                 :            :     HID_GLBLTREE_INSERT,        //CTX_INSERT
     109                 :            :     HID_GLBLTREE_EDIT,          //CTX_EDIT
     110                 :            :     HID_GLBLTREE_DEL,           //CTX_DELETE
     111                 :            :     HID_GLBLTREE_EDIT_LINK,     //CTX_EDIT_LINK
     112                 :            :     0,                        //
     113                 :            :     0,                        //
     114                 :            :     0,                        //
     115                 :            :     0,                        //
     116                 :            :     HID_GLBLTREE_INS_IDX,       //CTX_INSERT_ANY_INDEX
     117                 :            :     HID_GLBLTREE_INS_FILE,      //CTX_INSERT_FILE
     118                 :            :     HID_GLBLTREE_INS_NEW_FILE,  //CTX_INSERT_NEW_FILE
     119                 :            :     HID_GLBLTREE_INS_TEXT,      //CTX_INSERT_TEXT
     120                 :            :     0,                          //
     121                 :            :     0,                          //
     122                 :            :     0,                          //
     123                 :            :     0,                          //
     124                 :            :     0,                          //
     125                 :            :     0,                          //
     126                 :            :     HID_GLBLTREE_UPD_SEL,       //CTX_UPDATE_SEL
     127                 :            :     HID_GLBLTREE_UPD_IDX,       //CTX_UPDATE_INDEX
     128                 :            :     HID_GLBLTREE_UPD_LINK,      //CTX_UPDATE_LINK
     129                 :            :     HID_GLBLTREEUPD_ALL         //CTX_UPDATE_ALL
     130                 :            : };
     131                 :            : 
     132         [ #  # ]:          0 : class SwGlobalFrameListener_Impl : public SfxListener
     133                 :            : {
     134                 :            :     sal_Bool bValid;
     135                 :            : public:
     136                 :          0 :     SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) :
     137                 :          0 :         bValid(sal_True)
     138                 :            :         {
     139         [ #  # ]:          0 :             StartListening(rFrame);
     140                 :          0 :         }
     141                 :            : 
     142                 :            :     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     143                 :            : 
     144                 :          0 :     sal_Bool                IsValid() const {return bValid;}
     145                 :            : };
     146                 :            : 
     147                 :          0 : void    SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
     148                 :            : {
     149   [ #  #  #  # ]:          0 :     if( rHint.ISA(SfxSimpleHint) &&
                 [ #  # ]
     150                 :          0 :             (((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING))
     151                 :          0 :         bValid = sal_False;
     152                 :          0 : }
     153                 :            : 
     154                 :          0 : SwGlobalTree::SwGlobalTree(Window* pParent, const ResId& rResId) :
     155                 :            : 
     156                 :            :     SvTreeListBox(pParent, rResId),
     157                 :            : 
     158                 :            :     pActiveShell        ( NULL ),
     159                 :            :     pEmphasisEntry      ( NULL ),
     160                 :            :     pDDSource           ( NULL ),
     161                 :            :     pSwGlblDocContents  ( NULL ),
     162                 :            :     pDefParentWin       ( NULL ),
     163                 :            :     pDocContent         ( NULL ),
     164                 :            :     pDocInserter        ( NULL ),
     165                 :            : 
     166                 :            :     bIsInternalDrag         ( sal_False ),
     167                 :            :     bLastEntryEmphasis      ( sal_False ),
     168 [ #  # ][ #  # ]:          0 :     bIsImageListInitialized ( sal_False )
         [ #  # ][ #  #  
             #  #  #  # ]
     169                 :            : 
     170                 :            : {
     171                 :            :     SetDragDropMode(SV_DRAGDROP_APP_COPY  |
     172                 :            :                     SV_DRAGDROP_CTRL_MOVE |
     173         [ #  # ]:          0 :                     SV_DRAGDROP_ENABLE_TOP );
     174                 :            : 
     175         [ #  # ]:          0 :     aUpdateTimer.SetTimeout(GLOBAL_UPDATE_TIMEOUT);
     176         [ #  # ]:          0 :     aUpdateTimer.SetTimeoutHdl(LINK(this, SwGlobalTree, Timeout));
     177         [ #  # ]:          0 :     aUpdateTimer.Start();
     178         [ #  # ]:          0 :     for(sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++)
     179                 :            :     {
     180 [ #  # ][ #  # ]:          0 :         aContextStrings[i] = SW_RESSTR(i+ ST_GLOBAL_CONTEXT_FIRST);
     181                 :            :     }
     182         [ #  # ]:          0 :     SetHelpId(HID_NAVIGATOR_GLOB_TREELIST);
     183         [ #  # ]:          0 :     SelectHdl();
     184         [ #  # ]:          0 :     SetDoubleClickHdl(LINK(this, SwGlobalTree, DoubleClickHdl));
     185         [ #  # ]:          0 :     EnableContextMenuHandling();
     186   [ #  #  #  # ]:          0 : }
     187                 :            : 
     188 [ #  # ][ #  # ]:          0 : SwGlobalTree::~SwGlobalTree()
                 [ #  # ]
     189                 :            : {
     190 [ #  # ][ #  # ]:          0 :     delete pSwGlblDocContents;
     191 [ #  # ][ #  # ]:          0 :     delete pDocInserter;
     192 [ #  # ][ #  # ]:          0 : }
                 [ #  # ]
           [ #  #  #  # ]
     193                 :            : 
     194                 :          0 : sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
     195                 :            : {
     196                 :          0 :     sal_Int8 nRet = DND_ACTION_NONE;
     197                 :          0 :     SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
     198         [ #  # ]:          0 :     if(pEmphasisEntry)
     199                 :            :     {
     200                 :          0 :         ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
     201                 :          0 :         pEmphasisEntry = 0;
     202                 :            :     }
     203 [ #  # ][ #  # ]:          0 :     else if(bLastEntryEmphasis && pLast)
     204                 :            :     {
     205                 :          0 :         ImplShowTargetEmphasis( pLast, sal_False);
     206                 :            :     }
     207                 :            : 
     208         [ #  # ]:          0 :     SvLBoxEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel);
     209         [ #  # ]:          0 :     if( bIsInternalDrag )
     210                 :            :     {
     211                 :          0 :         SvLBoxEntry* pDummy = 0;
     212                 :          0 :         sal_uLong nInsertionPos = LIST_APPEND;
     213         [ #  # ]:          0 :         NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos );
     214                 :            :     }
     215                 :            :     else
     216                 :            :     {
     217         [ #  # ]:          0 :         TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
     218                 :            : 
     219         [ #  # ]:          0 :         String sFileName;
     220                 :            :         const SwGlblDocContent* pCnt = pDropEntry ?
     221                 :            :                     (const SwGlblDocContent*)pDropEntry->GetUserData() :
     222         [ #  # ]:          0 :                             0;
     223 [ #  # ][ #  # ]:          0 :         if( aData.HasFormat( FORMAT_FILE_LIST ))
     224                 :            :         {
     225                 :          0 :             nRet = rEvt.mnAction;
     226 [ #  # ][ #  # ]:          0 :             SwGlblDocContents* pTempContents = new SwGlblDocContents;
     227                 :            :             int nAbsContPos = pDropEntry ?
     228         [ #  # ]:          0 :                                 (int) GetModel()->GetAbsPos(pDropEntry):
     229         [ #  # ]:          0 :                                     - 1;
     230                 :          0 :             sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
     231                 :            : 
     232                 :            :             // Daten holen
     233         [ #  # ]:          0 :             FileList aFileList;
     234         [ #  # ]:          0 :             aData.GetFileList( FORMAT_FILE_LIST, aFileList );
     235 [ #  # ][ #  # ]:          0 :             for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; )
     236                 :            :             {
     237 [ #  # ][ #  # ]:          0 :                 sFileName = aFileList.GetFile(n);
                 [ #  # ]
     238         [ #  # ]:          0 :                 InsertRegion(pCnt, &sFileName);
     239                 :            :                 // nach dem Einfuegen muss die Liste der Contents neu
     240                 :            :                 // geholt werden, um nicht auf einem alten Content zu
     241                 :            :                 // arbeiten
     242         [ #  # ]:          0 :                 if(n)
     243                 :            :                 {
     244         [ #  # ]:          0 :                     pActiveShell->GetGlobalDocContent(*pTempContents);
     245                 :            :                     // wenn das file erfolgreich eingefuegt wurde,
     246                 :            :                     // dann muss auch der naechste Content geholt werden
     247         [ #  # ]:          0 :                     if(nEntryCount < pTempContents->size())
     248                 :            :                     {
     249                 :          0 :                         nEntryCount++;
     250                 :          0 :                         nAbsContPos++;
     251         [ #  # ]:          0 :                         pCnt = (*pTempContents)[ nAbsContPos ];
     252                 :            :                     }
     253                 :            :                 }
     254                 :            :             }
     255 [ #  # ][ #  # ]:          0 :             delete pTempContents;
                 [ #  # ]
     256                 :            :         }
     257         [ #  # ]:          0 :         else if( 0 != (sFileName =
     258 [ #  # ][ #  # ]:          0 :                         SwNavigationPI::CreateDropFileName( aData )).Len())
                 [ #  # ]
     259                 :            :         {
     260 [ #  # ][ #  # ]:          0 :             INetURLObject aTemp(sFileName);
     261         [ #  # ]:          0 :             GraphicDescriptor aDesc(aTemp);
     262 [ #  # ][ #  # ]:          0 :             if( !aDesc.Detect() )   // keine Grafiken annehmen
     263                 :            :             {
     264                 :          0 :                 nRet = rEvt.mnAction;
     265         [ #  # ]:          0 :                 InsertRegion(pCnt, &sFileName);
     266 [ #  # ][ #  # ]:          0 :             }
     267 [ #  # ][ #  # ]:          0 :         }
     268                 :            :     }
     269                 :          0 :     bLastEntryEmphasis = sal_False;
     270                 :          0 :     return nRet;
     271                 :            : 
     272                 :            : }
     273                 :            : 
     274                 :          0 : sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt )
     275                 :            : {
     276                 :          0 :     sal_Int8 nRet = rEvt.mnAction;
     277                 :            : 
     278                 :            :     //initiate scrolling
     279                 :          0 :     GetDropTarget( rEvt.maPosPixel );
     280                 :          0 :     SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
     281         [ #  # ]:          0 :     if( rEvt.mbLeaving )
     282                 :            :     {
     283         [ #  # ]:          0 :         if( pEmphasisEntry )
     284                 :            :         {
     285                 :          0 :             ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
     286                 :          0 :             pEmphasisEntry = 0;
     287                 :            :         }
     288 [ #  # ][ #  # ]:          0 :         else if(bLastEntryEmphasis && pLast)
     289                 :            :         {
     290                 :          0 :             ImplShowTargetEmphasis( pLast, sal_False);
     291                 :            :         }
     292                 :          0 :         bLastEntryEmphasis = sal_False;
     293                 :            :     }
     294                 :            :     else
     295                 :            :     {
     296                 :          0 :         SvLBoxEntry* pDropEntry = GetEntry( rEvt.maPosPixel );
     297         [ #  # ]:          0 :         if(bIsInternalDrag)
     298                 :            :         {
     299         [ #  # ]:          0 :             if( pDDSource != pDropEntry )
     300                 :          0 :                 nRet = rEvt.mnAction;
     301                 :            :         }
     302   [ #  #  #  #  :          0 :         else if( IsDropFormatSupported( FORMAT_FILE ) ||
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
                 [ #  # ]
     303                 :          0 :                   IsDropFormatSupported( FORMAT_STRING ) ||
     304                 :          0 :                   IsDropFormatSupported( FORMAT_FILE_LIST ) ||
     305                 :          0 :                   IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
     306                 :          0 :                    IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
     307                 :          0 :                    IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
     308                 :          0 :                    IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
     309                 :          0 :                    IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
     310                 :          0 :                    IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME ))
     311                 :          0 :                 nRet = DND_ACTION_LINK;
     312                 :            : 
     313 [ #  # ][ #  # ]:          0 :         if(pEmphasisEntry && pEmphasisEntry != pDropEntry)
     314                 :          0 :             ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
     315 [ #  # ][ #  # ]:          0 :         else if(pLast && bLastEntryEmphasis  && pDropEntry)
                 [ #  # ]
     316                 :            :         {
     317                 :          0 :             ImplShowTargetEmphasis( pLast, sal_False);
     318                 :          0 :             bLastEntryEmphasis = sal_False;
     319                 :            :         }
     320                 :            : 
     321         [ #  # ]:          0 :         if(pDropEntry)
     322                 :          0 :             ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet );
     323         [ #  # ]:          0 :         else if(pLast)
     324                 :            :         {
     325                 :          0 :             ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet );
     326                 :          0 :             bLastEntryEmphasis = sal_True;
     327                 :            :         }
     328                 :          0 :         pEmphasisEntry = pDropEntry;
     329                 :            :     }
     330                 :          0 :     return nRet;
     331                 :            : }
     332                 :            : 
     333                 :          0 : PopupMenu* SwGlobalTree::CreateContextMenu()
     334                 :            : {
     335                 :          0 :     PopupMenu* pPop = 0;
     336   [ #  #  #  # ]:          0 :     if(pActiveShell &&
                 [ #  # ]
     337                 :          0 :         !pActiveShell->GetView().GetDocShell()->IsReadOnly())
     338                 :            :     {
     339                 :          0 :         sal_uInt16 nEnableFlags = GetEnableFlags();
     340         [ #  # ]:          0 :         pPop = new PopupMenu;
     341         [ #  # ]:          0 :         PopupMenu* pSubPop1 = new PopupMenu;
     342         [ #  # ]:          0 :         PopupMenu* pSubPop2 = new PopupMenu;
     343                 :            : 
     344         [ #  # ]:          0 :         for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
     345                 :            :         {
     346                 :          0 :             pSubPop2->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
     347         [ #  # ]:          0 :             pSubPop2->SetHelpId(i, aHelpForMenu[i]);
     348                 :            :         }
     349                 :          0 :         pSubPop2->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
     350                 :            : 
     351                 :          0 :         pSubPop1->InsertItem(CTX_INSERT_ANY_INDEX, aContextStrings[ST_INDEX  - ST_GLOBAL_CONTEXT_FIRST]);
     352         [ #  # ]:          0 :         pSubPop1->SetHelpId(CTX_INSERT_ANY_INDEX, aHelpForMenu[CTX_INSERT_ANY_INDEX]);
     353                 :          0 :         pSubPop1->InsertItem(CTX_INSERT_FILE, aContextStrings[ST_FILE   - ST_GLOBAL_CONTEXT_FIRST]);
     354         [ #  # ]:          0 :         pSubPop1->SetHelpId(CTX_INSERT_FILE, aHelpForMenu[CTX_INSERT_FILE]);
     355                 :          0 :         pSubPop1->InsertItem(CTX_INSERT_NEW_FILE, aContextStrings[ST_NEW_FILE   - ST_GLOBAL_CONTEXT_FIRST]);
     356         [ #  # ]:          0 :         pSubPop1->SetHelpId(CTX_INSERT_NEW_FILE, aHelpForMenu[CTX_INSERT_NEW_FILE]);
     357                 :          0 :         pSubPop1->InsertItem(CTX_INSERT_TEXT, aContextStrings[ST_TEXT   - ST_GLOBAL_CONTEXT_FIRST]);
     358         [ #  # ]:          0 :         pSubPop1->SetHelpId(CTX_INSERT_TEXT, aHelpForMenu[CTX_INSERT_TEXT]);
     359                 :            : 
     360                 :            : 
     361                 :          0 :         pPop->InsertItem(CTX_UPDATE, aContextStrings[ST_UPDATE - ST_GLOBAL_CONTEXT_FIRST]);
     362         [ #  # ]:          0 :         pPop->SetHelpId(CTX_UPDATE, aHelpForMenu[CTX_UPDATE]);
     363                 :          0 :         pPop->InsertItem(CTX_EDIT, aContextStrings[ST_EDIT_CONTENT - ST_GLOBAL_CONTEXT_FIRST]);
     364         [ #  # ]:          0 :         pPop->SetHelpId(CTX_EDIT, aHelpForMenu[CTX_EDIT]);
     365         [ #  # ]:          0 :         if(nEnableFlags&ENABLE_EDIT_LINK)
     366                 :            :         {
     367                 :          0 :             pPop->InsertItem(CTX_EDIT_LINK, aContextStrings[ST_EDIT_LINK - ST_GLOBAL_CONTEXT_FIRST]);
     368         [ #  # ]:          0 :             pPop->SetHelpId(CTX_EDIT_LINK, aHelpForMenu[CTX_EDIT_LINK]);
     369                 :            :         }
     370                 :          0 :         pPop->InsertItem(CTX_INSERT, aContextStrings[ST_INSERT - ST_GLOBAL_CONTEXT_FIRST]);
     371         [ #  # ]:          0 :         pPop->SetHelpId(CTX_INSERT, aHelpForMenu[CTX_INSERT]);
     372                 :          0 :         pPop->InsertSeparator() ;
     373                 :          0 :         pPop->InsertItem(CTX_DELETE, aContextStrings[ST_DELETE - ST_GLOBAL_CONTEXT_FIRST]);
     374         [ #  # ]:          0 :         pPop->SetHelpId(CTX_DELETE, aHelpForMenu[CTX_DELETE]);
     375                 :            : 
     376                 :            :         //evtl. disablen
     377                 :          0 :         pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX,  0 != (nEnableFlags & ENABLE_INSERT_IDX ));
     378                 :          0 :         pSubPop1->EnableItem(CTX_INSERT_TEXT,       0 != (nEnableFlags & ENABLE_INSERT_TEXT));
     379                 :          0 :         pSubPop1->EnableItem(CTX_INSERT_FILE,       0 != (nEnableFlags & ENABLE_INSERT_FILE));
     380                 :          0 :         pSubPop1->EnableItem(CTX_INSERT_NEW_FILE,   0 != (nEnableFlags & ENABLE_INSERT_FILE));
     381                 :            : 
     382                 :          0 :         pPop->EnableItem(CTX_UPDATE,    0 != (nEnableFlags & ENABLE_UPDATE));
     383                 :          0 :         pPop->EnableItem(CTX_INSERT,    0 != (nEnableFlags & ENABLE_INSERT_IDX));
     384                 :          0 :         pPop->EnableItem(CTX_EDIT,      0 != (nEnableFlags & ENABLE_EDIT));
     385                 :          0 :         pPop->EnableItem(CTX_DELETE,    0 != (nEnableFlags & ENABLE_DELETE));
     386                 :            : 
     387                 :            : 
     388                 :          0 :         pPop->SetPopupMenu( CTX_INSERT, pSubPop1 );
     389                 :          0 :         pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 );
     390                 :            :     }
     391                 :          0 :     return pPop;
     392                 :            : }
     393                 :            : 
     394                 :          0 : void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox)
     395                 :            : {
     396                 :          0 :     sal_uInt16 nEnableFlags = GetEnableFlags();
     397         [ #  # ]:          0 :     if(FN_GLOBAL_OPEN == nTbxId)
     398                 :            :     {
     399         [ #  # ]:          0 :         PopupMenu *pMenu = new PopupMenu;
     400         [ #  # ]:          0 :         for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; i++)
     401                 :            :         {
     402                 :          0 :             pMenu->InsertItem( i, aContextStrings[ST_INDEX  - ST_GLOBAL_CONTEXT_FIRST - CTX_INSERT_ANY_INDEX + i] );
     403         [ #  # ]:          0 :             pMenu->SetHelpId(i, aHelpForMenu[i] );
     404                 :            :         }
     405                 :          0 :         pMenu->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
     406                 :          0 :         pMenu->EnableItem(CTX_INSERT_TEXT,      0 != (nEnableFlags & ENABLE_INSERT_TEXT));
     407                 :          0 :         pMenu->EnableItem(CTX_INSERT_FILE,      0 != (nEnableFlags & ENABLE_INSERT_FILE));
     408                 :          0 :         pMenu->EnableItem(CTX_INSERT_NEW_FILE,  0 != (nEnableFlags & ENABLE_INSERT_FILE));
     409                 :          0 :         pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
     410 [ #  # ][ #  # ]:          0 :         pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft());
     411         [ #  # ]:          0 :         delete pMenu;
     412                 :          0 :         pBox->EndSelection();
     413                 :          0 :         pBox->Invalidate();
     414                 :            :     }
     415         [ #  # ]:          0 :     else if(FN_GLOBAL_UPDATE == nTbxId)
     416                 :            :     {
     417         [ #  # ]:          0 :         PopupMenu *pMenu = new PopupMenu;
     418         [ #  # ]:          0 :         for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
     419                 :            :         {
     420                 :          0 :             pMenu->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
     421         [ #  # ]:          0 :             pMenu->SetHelpId(i, aHelpForMenu[i] );
     422                 :            :         }
     423                 :          0 :         pMenu->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
     424                 :          0 :         pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
     425 [ #  # ][ #  # ]:          0 :         pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft());
     426         [ #  # ]:          0 :         delete pMenu;
     427                 :          0 :         pBox->EndSelection();
     428                 :          0 :         pBox->Invalidate();
     429                 :            :     }
     430                 :          0 : }
     431                 :            : 
     432                 :          0 : sal_uInt16  SwGlobalTree::GetEnableFlags() const
     433                 :            : {
     434                 :          0 :     SvLBoxEntry* pEntry = FirstSelected();
     435                 :          0 :     sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount();
     436                 :          0 :     sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
     437         [ #  # ]:          0 :     SvLBoxEntry* pPrevEntry = pEntry ? Prev(pEntry) : 0;
     438                 :            : 
     439                 :          0 :     sal_uInt16 nRet = 0;
     440 [ #  # ][ #  # ]:          0 :     if(nSelCount == 1 || !nEntryCount)
     441                 :          0 :         nRet |= ENABLE_INSERT_IDX|ENABLE_INSERT_FILE;
     442         [ #  # ]:          0 :     if(nSelCount == 1)
     443                 :            :     {
     444                 :          0 :         nRet |= ENABLE_EDIT;
     445         [ #  # ]:          0 :         if( ((SwGlblDocContent*)pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN &&
           [ #  #  #  # ]
                 [ #  # ]
     446                 :          0 :                     (!pPrevEntry || ((SwGlblDocContent*)pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN))
     447                 :          0 :             nRet |= ENABLE_INSERT_TEXT;
     448         [ #  # ]:          0 :         if( GLBLDOC_SECTION == ((SwGlblDocContent*)pEntry->GetUserData())->GetType() )
     449                 :          0 :             nRet |= ENABLE_EDIT_LINK;
     450                 :            :     }
     451         [ #  # ]:          0 :     else if(!nEntryCount)
     452                 :            :     {
     453                 :          0 :         nRet |= ENABLE_INSERT_TEXT;
     454                 :            :     }
     455         [ #  # ]:          0 :     if(nEntryCount)
     456                 :          0 :         nRet |= ENABLE_UPDATE|ENABLE_DELETE;
     457         [ #  # ]:          0 :     if(nSelCount)
     458                 :          0 :         nRet |= ENABLE_UPDATE_SEL;
     459                 :          0 :     return nRet;
     460                 :            : }
     461                 :            : 
     462                 :          0 : void     SwGlobalTree::RequestHelp( const HelpEvent& rHEvt )
     463                 :            : {
     464                 :          0 :     sal_Bool bParent = sal_True;
     465                 :          0 :     Update(sal_True);
     466                 :          0 :     Display(sal_True);
     467         [ #  # ]:          0 :     if( rHEvt.GetMode() & HELPMODE_QUICK )
     468                 :            :     {
     469 [ #  # ][ #  # ]:          0 :         Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
     470         [ #  # ]:          0 :         SvLBoxEntry* pEntry = GetEntry( aPos );
     471                 :            :         const SwGlblDocContent* pCont = pEntry ?
     472         [ #  # ]:          0 :                             (const SwGlblDocContent*)pEntry->GetUserData() : 0;
     473 [ #  # ][ #  # ]:          0 :         if( pCont &&  GLBLDOC_SECTION == pCont->GetType())
                 [ #  # ]
     474                 :            :         {
     475                 :          0 :             bParent = sal_False;
     476                 :            :             SvLBoxTab* pTab;
     477         [ #  # ]:          0 :             SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
     478 [ #  # ][ #  # ]:          0 :             if(pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
         [ #  # ][ #  # ]
     479                 :            :             {
     480                 :          0 :                 const SwSection* pSect = pCont->GetSection();
     481 [ #  # ][ #  # ]:          0 :                 String sEntry = pSect->GetLinkFileName().GetToken(0, sfx2::cTokenSeperator);
     482         [ #  # ]:          0 :                 if(!pSect->IsConnectFlag())
     483         [ #  # ]:          0 :                     sEntry.Insert(aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST], 0 );
     484         [ #  # ]:          0 :                 Point aEntryPos = GetEntryPosition( pEntry );
     485                 :            : 
     486         [ #  # ]:          0 :                 aEntryPos.X() = GetTabPos( pEntry, pTab );
     487         [ #  # ]:          0 :                 Size aSize( pItem->GetSize( this, pEntry ) );
     488                 :            : 
     489 [ #  # ][ #  # ]:          0 :                 if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width())
     490         [ #  # ]:          0 :                     aSize.Width() = GetSizePixel().Width() - aEntryPos.X();
     491                 :            : 
     492         [ #  # ]:          0 :                 aEntryPos = OutputToScreenPixel(aEntryPos);
     493         [ #  # ]:          0 :                 Rectangle aItemRect( aEntryPos, aSize );
     494 [ #  # ][ #  # ]:          0 :                 if(Help::IsBalloonHelpEnabled())
     495                 :            :                 {
     496                 :          0 :                     aEntryPos.X() += aSize.Width();
     497         [ #  # ]:          0 :                     Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry );
     498                 :            :                 }
     499                 :            :                 else
     500                 :            :                     Help::ShowQuickHelp( this, aItemRect, sEntry,
     501 [ #  # ][ #  # ]:          0 :                         QUICKHELP_LEFT|QUICKHELP_VCENTER );
     502                 :            :             }
     503                 :            :         }
     504                 :            :     }
     505                 :            : 
     506         [ #  # ]:          0 :     if(bParent)
     507                 :          0 :         SvTreeListBox::RequestHelp(rHEvt);
     508                 :          0 : }
     509                 :            : 
     510                 :          0 : void     SwGlobalTree::SelectHdl()
     511                 :            : {
     512                 :            : 
     513                 :          0 :     sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount();
     514                 :          0 :     SvLBoxEntry* pSel = FirstSelected();
     515         [ #  # ]:          0 :     sal_uInt16 nAbsPos = pSel ? (sal_uInt16)GetModel()->GetAbsPos(pSel) : 0;
     516                 :          0 :     SwNavigationPI* pNavi = GetParentWindow();
     517                 :          0 :     sal_Bool bReadonly = !pActiveShell ||
     518 [ #  # ][ #  # ]:          0 :                 pActiveShell->GetView().GetDocShell()->IsReadOnly();
     519 [ #  # ][ #  # ]:          0 :     pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_EDIT,  nSelCount == 1 && !bReadonly);
     520 [ #  # ][ #  # ]:          0 :     pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_OPEN,  nSelCount <= 1 && !bReadonly);
     521 [ #  # ][ #  # ]:          0 :     pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_UPDATE,  GetEntryCount() > 0 && !bReadonly);
     522                 :            :     pNavi->aGlobalToolBox.EnableItem(FN_ITEM_UP,
     523 [ #  # ][ #  # ]:          0 :                     nSelCount == 1 && nAbsPos && !bReadonly);
                 [ #  # ]
     524                 :            :     pNavi->aGlobalToolBox.EnableItem(FN_ITEM_DOWN,
     525 [ #  # ][ #  # ]:          0 :                     nSelCount == 1 && nAbsPos < ((sal_uInt16)GetEntryCount()) - 1 && !bReadonly);
                 [ #  # ]
     526                 :            : 
     527                 :          0 : }
     528                 :            : 
     529                 :          0 : void     SwGlobalTree::DeselectHdl()
     530                 :            : {
     531                 :          0 :     SelectHdl();
     532                 :          0 : }
     533                 :            : 
     534                 :          0 : DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& ,
     535                 :            :                                                 SvLBoxEntry* pEntry )
     536                 :            : {
     537                 :          0 :     bIsInternalDrag = sal_True;
     538                 :          0 :     pDDSource = pEntry;
     539                 :          0 :     return SV_DRAGDROP_CTRL_MOVE;
     540                 :            : }
     541                 :            : 
     542                 :          0 : long     SwGlobalTree::GetTabPos( SvLBoxEntry*, SvLBoxTab* pTab)
     543                 :            : {
     544                 :          0 :     return pTab->GetPos() - GLBL_TABPOS_SUB;
     545                 :            : }
     546                 :            : 
     547                 :          0 : sal_Bool     SwGlobalTree::NotifyMoving(   SvLBoxEntry*  pTarget,
     548                 :            :                                         SvLBoxEntry*  pSource,
     549                 :            :                                         SvLBoxEntry*&,
     550                 :            :                                         sal_uLong&
     551                 :            :                                     )
     552                 :            : {
     553                 :          0 :     SvTreeList* _pModel = GetModel();
     554                 :          0 :     sal_uInt16 nSource = (sal_uInt16) _pModel->GetAbsPos(pSource);
     555         [ #  # ]:          0 :     sal_uInt16 nDest   = pTarget ? (sal_uInt16) _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->size();
     556                 :            : 
     557         [ #  # ]:          0 :     if( pActiveShell->MoveGlobalDocContent(
           [ #  #  #  # ]
     558                 :          0 :             *pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
     559                 :          0 :             Update( sal_False ))
     560                 :          0 :         Display();
     561                 :          0 :     return sal_False;
     562                 :            : }
     563                 :            : 
     564                 :          0 : sal_Bool     SwGlobalTree::NotifyCopying(  SvLBoxEntry*  /*pTarget*/,
     565                 :            :                                         SvLBoxEntry*  /*pEntry*/,
     566                 :            :                                         SvLBoxEntry*& /*rpNewParent*/,
     567                 :            :                                         sal_uLong&        /*rNewChildPos*/
     568                 :            :                                     )
     569                 :            : {
     570                 :          0 :     return sal_False;
     571                 :            : }
     572                 :            : 
     573                 :          0 : sal_Bool SwGlobalTree::NotifyAcceptDrop( SvLBoxEntry* pEntry)
     574                 :            : {
     575                 :          0 :     return pEntry != 0;
     576                 :            : }
     577                 :            : 
     578                 :          0 : void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt )
     579                 :            : {
     580         [ #  # ]:          0 :     if( 1 == GetSelectionCount() )
     581                 :          0 :         SvTreeListBox::StartDrag( nAction, rPt );
     582                 :          0 : }
     583                 :            : 
     584                 :          0 : void SwGlobalTree::DragFinished( sal_Int8 nAction )
     585                 :            : {
     586                 :          0 :     SvTreeListBox::DragFinished( nAction );
     587                 :          0 :     bIsInternalDrag = sal_False;
     588                 :          0 : }
     589                 :            : 
     590                 :            : /***************************************************************************
     591                 :            :     Beschreibung:   Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
     592                 :            :  *                  dann soll die Basisfunktion des Controls gerufen werden
     593                 :            : ***************************************************************************/
     594                 :          0 : void  SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt )
     595                 :            : {
     596                 :          0 :     Point aPos( rMEvt.GetPosPixel());
     597         [ #  # ]:          0 :     SvLBoxEntry* pEntry = GetEntry( aPos, sal_True );
     598 [ #  # ][ #  # ]:          0 :     if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
         [ #  # ][ #  # ]
                 [ #  # ]
     599         [ #  # ]:          0 :         Control::MouseButtonDown( rMEvt );
     600                 :            :     else
     601         [ #  # ]:          0 :         SvTreeListBox::MouseButtonDown( rMEvt );
     602                 :          0 : }
     603                 :            : 
     604                 :          0 : void     SwGlobalTree::GetFocus()
     605                 :            : {
     606         [ #  # ]:          0 :     if(Update( sal_False ))
     607                 :          0 :         Display();
     608                 :          0 :     SvTreeListBox::GetFocus();
     609                 :          0 : }
     610                 :            : 
     611                 :          0 : void     SwGlobalTree::KeyInput(const KeyEvent& rKEvt)
     612                 :            : {
     613                 :          0 :     const KeyCode aCode = rKEvt.GetKeyCode();
     614         [ #  # ]:          0 :     if(aCode.GetCode() == KEY_RETURN)
     615                 :            :     {
     616         [ #  # ]:          0 :         switch(aCode.GetModifier())
     617                 :            :         {
     618                 :            :             case KEY_MOD2:
     619                 :            :                 // Boxen umschalten
     620 [ #  # ][ #  # ]:          0 :                 GetParentWindow()->ToggleTree();
     621                 :          0 :             break;
     622                 :            :         }
     623                 :            :     }
     624                 :            :     else
     625         [ #  # ]:          0 :         SvTreeListBox::KeyInput(rKEvt);
     626                 :          0 : }
     627                 :            : 
     628                 :          0 : void SwGlobalTree::Clear()
     629                 :            : {
     630                 :          0 :     pEmphasisEntry = 0;
     631                 :          0 :     SvTreeListBox::Clear();
     632                 :          0 : }
     633                 :            : 
     634                 :          0 : void    SwGlobalTree::Display(sal_Bool bOnlyUpdateUserData)
     635                 :            : {
     636         [ #  # ]:          0 :     if(!bIsImageListInitialized)
     637                 :            :     {
     638 [ #  # ][ #  # ]:          0 :         aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
                 [ #  # ]
     639                 :          0 :         bIsImageListInitialized = sal_True;
     640                 :            :     }
     641                 :          0 :     sal_uInt16 nCount = pSwGlblDocContents->size();
     642 [ #  # ][ #  # ]:          0 :     if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->size())
                 [ #  # ]
     643                 :            :     {
     644                 :          0 :         SvLBoxEntry* pEntry = First();
     645         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < nCount; i++)
     646                 :            :         {
     647                 :          0 :             SwGlblDocContent* pCont = (*pSwGlblDocContents)[i];
     648                 :          0 :             pEntry->SetUserData(pCont);
     649                 :          0 :             pEntry = Next(pEntry);
     650                 :            :         }
     651                 :            :     }
     652                 :            :     else
     653                 :            :     {
     654         [ #  # ]:          0 :         SetUpdateMode( sal_False );
     655         [ #  # ]:          0 :         SvLBoxEntry* pOldSelEntry = FirstSelected();
     656         [ #  # ]:          0 :         String sEntryName;  // Name des Eintrags
     657                 :          0 :         sal_uInt16 nSelPos = USHRT_MAX;
     658         [ #  # ]:          0 :         if(pOldSelEntry)
     659                 :            :         {
     660 [ #  # ][ #  # ]:          0 :             sEntryName = GetEntryText(pOldSelEntry);
                 [ #  # ]
     661         [ #  # ]:          0 :             nSelPos = (sal_uInt16)GetModel()->GetAbsPos(pOldSelEntry);
     662                 :            :         }
     663         [ #  # ]:          0 :         Clear();
     664         [ #  # ]:          0 :         if(!pSwGlblDocContents)
     665         [ #  # ]:          0 :             Update( sal_False );
     666                 :            : 
     667                 :          0 :         SvLBoxEntry* pSelEntry = 0;
     668         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < nCount; i++)
     669                 :            :         {
     670         [ #  # ]:          0 :             SwGlblDocContent* pCont = (*pSwGlblDocContents)[i];
     671         [ #  # ]:          0 :             String sEntry;
     672         [ #  # ]:          0 :             Image aImage;
     673   [ #  #  #  # ]:          0 :             switch( pCont->GetType()  )
     674                 :            :             {
     675                 :            :                 case GLBLDOC_UNKNOWN:
     676                 :            :                 {
     677         [ #  # ]:          0 :                     sEntry = aContextStrings[ST_TEXT   - ST_GLOBAL_CONTEXT_FIRST];
     678 [ #  # ][ #  # ]:          0 :                     aImage = aEntryImages.GetImage(SID_SW_START + GLOBAL_CONTENT_TEXT);
                 [ #  # ]
     679                 :            :                 }
     680                 :          0 :                 break;
     681                 :            :                 case GLBLDOC_TOXBASE:
     682                 :            :                 {
     683                 :          0 :                     const SwTOXBase* pBase = pCont->GetTOX();
     684 [ #  # ][ #  # ]:          0 :                     sEntry = pBase->GetTitle();
     685 [ #  # ][ #  # ]:          0 :                     aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX);
                 [ #  # ]
     686                 :            :                 }
     687                 :          0 :                 break;
     688                 :            :                 case GLBLDOC_SECTION:
     689                 :            :                 {
     690                 :          0 :                     const SwSection* pSect = pCont->GetSection();
     691         [ #  # ]:          0 :                     sEntry = pSect->GetSectionName();
     692 [ #  # ][ #  # ]:          0 :                     aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION);
                 [ #  # ]
     693                 :            :                 }
     694                 :          0 :                 break;
     695                 :            :             }
     696                 :            :             SvLBoxEntry* pEntry = InsertEntry(sEntry, aImage, aImage,
     697         [ #  # ]:          0 :                         0, sal_False, LIST_APPEND, pCont);
     698 [ #  # ][ #  # ]:          0 :             if(sEntry == sEntryName)
     699                 :            :             {
     700                 :          0 :                 pSelEntry = pEntry;
     701                 :            :             }
     702 [ #  # ][ #  # ]:          0 :         }
     703         [ #  # ]:          0 :         if(pSelEntry)
     704                 :            :         {
     705         [ #  # ]:          0 :             Select(pSelEntry);
     706                 :            :         }
     707 [ #  # ][ #  # ]:          0 :         else if(nSelPos != USHRT_MAX && nSelPos < nCount)
     708                 :            :         {
     709 [ #  # ][ #  # ]:          0 :             Select(GetEntry(nSelPos));
     710                 :            :         }
     711         [ #  # ]:          0 :         else if(nCount)
     712 [ #  # ][ #  # ]:          0 :             Select(First());
     713                 :            :         else
     714         [ #  # ]:          0 :             SelectHdl();
     715 [ #  # ][ #  # ]:          0 :         SetUpdateMode( sal_True );
     716                 :            :     }
     717                 :          0 : }
     718                 :            : 
     719                 :          0 : void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const String* pFileName )
     720                 :            : {
     721         [ #  # ]:          0 :     Sequence< OUString > aFileNames;
     722         [ #  # ]:          0 :     if ( !pFileName )
     723                 :            :     {
     724         [ #  # ]:          0 :         pDefParentWin = Application::GetDefDialogParent();
     725         [ #  # ]:          0 :         Application::SetDefDialogParent( this );
     726 [ #  # ][ #  # ]:          0 :         delete pDocInserter;
     727                 :            :         pDocInserter = new ::sfx2::DocumentInserter(
     728 [ #  # ][ #  # ]:          0 :                 rtl::OUString("swriter"), true );
         [ #  # ][ #  # ]
     729 [ #  # ][ #  # ]:          0 :         pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) );
     730                 :            :     }
     731         [ #  # ]:          0 :     else if ( pFileName->Len() )
     732                 :            :     {
     733         [ #  # ]:          0 :         aFileNames.realloc(1);
     734         [ #  # ]:          0 :         INetURLObject aFileName;
     735 [ #  # ][ #  # ]:          0 :         aFileName.SetSmartURL( *pFileName );
     736 [ #  # ][ #  # ]:          0 :         aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE );
     737 [ #  # ][ #  # ]:          0 :         InsertRegion( pCont, aFileNames );
     738         [ #  # ]:          0 :     }
     739                 :          0 : }
     740                 :            : 
     741                 :          0 : void    SwGlobalTree::EditContent(const SwGlblDocContent* pCont )
     742                 :            : {
     743                 :          0 :     sal_uInt16 nSlot = 0;
     744   [ #  #  #  # ]:          0 :     switch( pCont->GetType() )
     745                 :            :     {
     746                 :            :         case GLBLDOC_UNKNOWN:
     747                 :          0 :             pActiveShell->GetView().GetEditWin().GrabFocus();
     748                 :          0 :         break;
     749                 :            :         case GLBLDOC_TOXBASE:
     750                 :            :         {
     751                 :          0 :             const SwTOXBase* pBase = pCont->GetTOX();
     752         [ #  # ]:          0 :             if(pBase)
     753                 :          0 :                 nSlot = FN_INSERT_MULTI_TOX;
     754                 :            :         }
     755                 :          0 :         break;
     756                 :            :         case GLBLDOC_SECTION:
     757                 :            :         {
     758                 :          0 :             OpenDoc(pCont);
     759                 :            : 
     760                 :          0 :             nSlot = 0;
     761                 :          0 :             pCont = 0;
     762                 :            :         }
     763                 :          0 :         break;
     764                 :            :     }
     765         [ #  # ]:          0 :     if(pCont)
     766                 :          0 :         GotoContent(pCont);
     767         [ #  # ]:          0 :     if(nSlot)
     768                 :            :     {
     769                 :          0 :         pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
     770         [ #  # ]:          0 :         if(Update( sal_False ))
     771                 :          0 :             Display();
     772                 :            :     }
     773                 :          0 : }
     774                 :            : 
     775                 :          0 : IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu)
     776                 :            : {
     777                 :          0 :     ExcecuteContextMenuAction( pMenu->GetCurItemId());
     778                 :          0 :     return sal_True;
     779                 :            : }
     780                 :            : 
     781                 :          0 : void    SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
     782                 :            : {
     783                 :          0 :     SvLBoxEntry* pEntry = FirstSelected();
     784         [ #  # ]:          0 :     SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
     785                 :            :     // wird waehrend des Dialogs ein RequestHelp gerufen,
     786                 :            :     // dann geht der Content verloren. Deshalb wird hier eine
     787                 :            :     // Kopie angelegt, in der nur die DocPos richtig gesetzt ist.
     788                 :          0 :     SwGlblDocContent* pContCopy = 0;
     789         [ #  # ]:          0 :     if(pCont)
     790         [ #  # ]:          0 :         pContCopy = new SwGlblDocContent(pCont->GetDocPos());
     791                 :          0 :     SfxDispatcher& rDispatch = *pActiveShell->GetView().GetViewFrame()->GetDispatcher();
     792                 :          0 :     sal_uInt16 nSlot = 0;
     793                 :          0 :     bool bDeleteContentCopy = true;
     794   [ #  #  #  #  :          0 :     switch( nSelectedPopupEntry )
          #  #  #  #  #  
                #  #  # ]
     795                 :            :     {
     796                 :            :         case CTX_UPDATE_SEL:
     797                 :            :         {
     798                 :            :             // zwei Durchlaeufe: zuerst die Bereiche, dann die Verzeichnisse
     799                 :            :             // aktualisieren
     800                 :          0 :             SvLBoxEntry* pSelEntry = FirstSelected();
     801         [ #  # ]:          0 :             while( pSelEntry )
     802                 :            :             {
     803                 :          0 :                 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
     804         [ #  # ]:          0 :                 if(GLBLDOC_SECTION == pContent->GetType() &&
           [ #  #  #  # ]
     805                 :          0 :                     pContent->GetSection()->IsConnected())
     806                 :            :                 {
     807                 :          0 :                     ((SwSection*)pContent->GetSection())->UpdateNow();
     808                 :            :                 }
     809                 :            : 
     810                 :          0 :                 pSelEntry = NextSelected(pSelEntry);
     811                 :            :             }
     812                 :          0 :             pSelEntry = FirstSelected();
     813         [ #  # ]:          0 :             while( pSelEntry )
     814                 :            :             {
     815                 :          0 :                 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
     816         [ #  # ]:          0 :                 if(GLBLDOC_TOXBASE == pContent->GetType())
     817                 :          0 :                     pActiveShell->UpdateTableOf(*pContent->GetTOX());
     818                 :          0 :                 pSelEntry = NextSelected(pSelEntry);
     819                 :            :             }
     820                 :            : 
     821                 :            :         }
     822                 :          0 :         break;
     823                 :            :         case CTX_UPDATE_INDEX:
     824                 :            :         {
     825                 :          0 :             nSlot = FN_UPDATE_TOX;
     826                 :            :         }
     827                 :          0 :         break;
     828                 :            :         case CTX_UPDATE_LINK:
     829                 :            :         case CTX_UPDATE_ALL:
     830                 :            :         {
     831                 :          0 :             pActiveShell->GetLinkManager().UpdateAllLinks(sal_True);
     832         [ #  # ]:          0 :             if(CTX_UPDATE_ALL == nSelectedPopupEntry)
     833                 :          0 :                 nSlot = FN_UPDATE_TOX;
     834                 :          0 :             pCont = 0;
     835                 :            :         }
     836                 :          0 :         break;
     837                 :            :         case CTX_EDIT:
     838                 :            :         {
     839                 :            :             OSL_ENSURE(pCont, "edit without entry ? " );
     840                 :          0 :             EditContent(pCont);
     841                 :            :         }
     842                 :          0 :         break;
     843                 :            :         case CTX_EDIT_LINK:
     844                 :            :         {
     845                 :            :             OSL_ENSURE(pCont, "edit without entry ? " );
     846                 :            :             SfxStringItem aName(FN_EDIT_REGION,
     847         [ #  # ]:          0 :                     pCont->GetSection()->GetSectionName());
     848 [ #  # ][ #  # ]:          0 :             rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L);
     849                 :            :         }
     850                 :          0 :         break;
     851                 :            :         case CTX_DELETE:
     852                 :            :         {
     853                 :            :             // sind mehrere Eintraege selektiert, dann muss nach jedem delete
     854                 :            :             // das Array neu gefuellt werden. Damit man sich nichts merken muss,
     855                 :            :             // beginnt das Loeschen am Ende
     856                 :          0 :             SvLBoxEntry* pSelEntry = LastSelected();
     857                 :          0 :             SwGlblDocContents* pTempContents  = 0;
     858                 :          0 :             pActiveShell->StartAction();
     859         [ #  # ]:          0 :             while(pSelEntry)
     860                 :            :             {
     861                 :            :                 pActiveShell->DeleteGlobalDocContent(
     862                 :            :                     pTempContents ? *pTempContents : *pSwGlblDocContents,
     863         [ #  # ]:          0 :                                      (sal_uInt16)GetModel()->GetAbsPos(pSelEntry));
     864                 :          0 :                 pSelEntry = PrevSelected(pSelEntry);
     865         [ #  # ]:          0 :                 if(pSelEntry)
     866                 :            :                 {
     867         [ #  # ]:          0 :                     pTempContents = new SwGlblDocContents;
     868                 :          0 :                     pActiveShell->GetGlobalDocContent(*pTempContents);
     869                 :            :                 }
     870                 :            :             }
     871         [ #  # ]:          0 :             delete pTempContents;
     872                 :          0 :             pActiveShell->EndAction();
     873                 :          0 :             pCont = 0;
     874                 :            :         }
     875                 :          0 :         break;
     876                 :            :         case CTX_INSERT_ANY_INDEX:
     877                 :            :         {
     878         [ #  # ]:          0 :             if(pContCopy)
     879                 :            :             {
     880                 :          0 :                 SfxItemSet aSet(pActiveShell->GetView().GetPool(),
     881                 :            :                             RES_COL, RES_COL,
     882                 :            :                             RES_BACKGROUND, RES_BACKGROUND,
     883                 :            :                             RES_FRM_SIZE, RES_FRM_SIZE,
     884                 :            :                             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
     885                 :            :                             RES_LR_SPACE, RES_LR_SPACE,
     886                 :            :                             FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
     887         [ #  # ]:          0 :                             0);
     888                 :            : 
     889         [ #  # ]:          0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     890                 :            :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
     891                 :            :                 AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX,
     892                 :            :                                                         this, aSet,
     893                 :            :                                                         *pActiveShell,
     894                 :            :                                                         0,
     895                 :            :                                                         USHRT_MAX,
     896         [ #  # ]:          0 :                                                         sal_True);
     897                 :            :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     898 [ #  # ][ #  # ]:          0 :                 if(RET_OK == pDlg->Execute())
     899                 :            :                 {
     900                 :            :                     SwTOXDescription&  rDesc = pDlg->GetTOXDescription(
     901 [ #  # ][ #  # ]:          0 :                                                 pDlg->GetCurrentTOXType());
     902         [ #  # ]:          0 :                     SwTOXMgr aMgr(pActiveShell);
     903                 :          0 :                     SwTOXBase* pToInsert = 0;
     904 [ #  # ][ #  # ]:          0 :                     if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet()))
                 [ #  # ]
     905         [ #  # ]:          0 :                         pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert );
     906                 :            :                 }
     907                 :          0 :                 pCont = 0;
     908 [ #  # ][ #  # ]:          0 :                 delete pDlg;
                 [ #  # ]
     909                 :            :             }
     910                 :            :         }
     911                 :          0 :         break;
     912                 :            :         case CTX_INSERT_FILE:
     913                 :            :         {
     914                 :          0 :             bDeleteContentCopy = false;
     915                 :          0 :             pDocContent = pContCopy;
     916                 :          0 :             InsertRegion( pContCopy );
     917                 :          0 :             pCont = NULL;
     918                 :            :         }
     919                 :          0 :         break;
     920                 :            :         case CTX_INSERT_NEW_FILE:
     921                 :            :         {
     922                 :          0 :             SfxViewFrame* pGlobFrm = pActiveShell->GetView().GetViewFrame();
     923         [ #  # ]:          0 :             SwGlobalFrameListener_Impl aFrmListener(*pGlobFrm);
     924                 :            : 
     925 [ #  # ][ #  # ]:          0 :             sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : (sal_uLong)-1;
     926                 :            :             // neues Dok anlegen
     927                 :            :             SfxStringItem aFactory(SID_NEWDOCDIRECT,
     928 [ #  # ][ #  # ]:          0 :                             SwDocShell::Factory().GetFilterContainer()->GetName());
         [ #  # ][ #  # ]
                 [ #  # ]
     929                 :            : 
     930                 :            :              const SfxFrameItem* pItem = (SfxFrameItem*)
     931                 :            :                             rDispatch.Execute(SID_NEWDOCDIRECT,
     932         [ #  # ]:          0 :                                 SFX_CALLMODE_SYNCHRON, &aFactory, 0L);
     933                 :            : 
     934                 :            :             // sichern unter
     935         [ #  # ]:          0 :             SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0;
     936 [ #  # ][ #  # ]:          0 :             SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0;
     937         [ #  # ]:          0 :             if( pFrame )
     938                 :            :             {
     939                 :            :                 const SfxBoolItem* pBool = (const SfxBoolItem*)
     940                 :            :                         pFrame->GetDispatcher()->Execute(
     941         [ #  # ]:          0 :                                 SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON );
     942         [ #  # ]:          0 :                 SfxObjectShell& rObj = *pFrame->GetObjectShell();
     943                 :          0 :                 const SfxMedium* pMedium = rObj.GetMedium();
     944 [ #  # ][ #  # ]:          0 :                 String sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI));
                 [ #  # ]
     945                 :            :                 // Bereich mit dem Dok-Namen einfuegen
     946                 :            :                 // eigenes Dok in den Vordergrund
     947                 :            : 
     948 [ #  # ][ #  # ]:          0 :                 if(aFrmListener.IsValid() && sNewFile.Len())
                 [ #  # ]
     949                 :            :                 {
     950         [ #  # ]:          0 :                     pGlobFrm->ToTop();
     951                 :            :                     // durch das Update sind die Eintraege invalid
     952         [ #  # ]:          0 :                     if(nEntryPos != (sal_uLong)-1)
     953                 :            :                     {
     954         [ #  # ]:          0 :                         Update( sal_False );
     955         [ #  # ]:          0 :                         Display();
     956 [ #  # ][ #  # ]:          0 :                         Select(GetModel()->GetEntryAtAbsPos(nEntryPos));
     957         [ #  # ]:          0 :                         pEntry = FirstSelected();
     958         [ #  # ]:          0 :                         pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
     959                 :            :                     }
     960                 :            :                     else
     961                 :            :                     {
     962                 :          0 :                         pEntry = 0;
     963                 :          0 :                         pCont = 0;
     964                 :            :                     }
     965         [ #  # ]:          0 :                     if(pBool->GetValue())
     966                 :            :                     {
     967         [ #  # ]:          0 :                         InsertRegion(pCont, &sNewFile);
     968         [ #  # ]:          0 :                         pFrame->ToTop();
     969                 :            :                     }
     970                 :            :                     else
     971                 :            :                         pFrame->GetDispatcher()->Execute(SID_CLOSEWIN,
     972         [ #  # ]:          0 :                                                 SFX_CALLMODE_SYNCHRON);
     973                 :            :                 }
     974                 :            :                 else
     975                 :            :                 {
     976         [ #  # ]:          0 :                     pFrame->ToTop();
     977                 :          0 :                     return;
     978 [ #  # ][ #  # ]:          0 :                 }
     979 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     980                 :            :         }
     981                 :          0 :         break;
     982                 :            :         case CTX_INSERT_TEXT:
     983                 :            :         {
     984         [ #  # ]:          0 :             if(pCont)
     985                 :          0 :                 pActiveShell->InsertGlobalDocContent(*pCont);
     986                 :            :             else
     987                 :            :             {
     988                 :          0 :                 pActiveShell->SplitNode(); // leeres Dokument
     989                 :          0 :                 pActiveShell->Up( sal_False, 1 );
     990                 :            :             }
     991                 :          0 :             pActiveShell->GetView().GetEditWin().GrabFocus();
     992                 :            :         }
     993                 :          0 :         break;
     994                 :            :         case CTX_UPDATE:
     995                 :          0 :             pCont = 0;
     996                 :          0 :         break;
     997                 :            :         default:;
     998                 :            :         // hier passiert nichts
     999                 :            :     }
    1000         [ #  # ]:          0 :     if(pCont)
    1001                 :          0 :         GotoContent(pCont);
    1002         [ #  # ]:          0 :     if(nSlot)
    1003                 :          0 :         rDispatch.Execute(nSlot);
    1004         [ #  # ]:          0 :     if(Update( sal_False ))
    1005                 :          0 :         Display();
    1006         [ #  # ]:          0 :     if ( bDeleteContentCopy )
    1007                 :          0 :         delete pContCopy;
    1008                 :            :     else
    1009                 :          0 :         bDeleteContentCopy = true;
    1010                 :            : }
    1011                 :            : 
    1012                 :          0 : IMPL_LINK_NOARG(SwGlobalTree, Timeout)
    1013                 :            : {
    1014 [ #  # ][ #  # ]:          0 :     if(!HasFocus() && Update( sal_False ))
                 [ #  # ]
    1015                 :          0 :         Display();
    1016                 :          0 :     return 0;
    1017                 :            : }
    1018                 :            : 
    1019                 :          0 : void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont)
    1020                 :            : {
    1021                 :          0 :     pActiveShell->EnterStdMode();
    1022                 :            : 
    1023   [ #  #  #  # ]:          0 :     switch( pCont->GetType()  )
    1024                 :            :     {
    1025                 :            :         case GLBLDOC_UNKNOWN:
    1026                 :          0 :             pActiveShell->GotoGlobalDocContent(*pCont);
    1027                 :          0 :         break;
    1028                 :            :         case GLBLDOC_TOXBASE:
    1029                 :            :         {
    1030         [ #  # ]:          0 :             String sName = pCont->GetTOX()->GetTOXName();
    1031 [ #  # ][ #  # ]:          0 :             if (!pActiveShell->GotoNextTOXBase(&sName))
    1032 [ #  # ][ #  # ]:          0 :                 pActiveShell->GotoPrevTOXBase(&sName);
    1033                 :            :         }
    1034                 :          0 :         break;
    1035                 :            :         case GLBLDOC_SECTION:
    1036                 :          0 :         break;
    1037                 :            :     }
    1038                 :            : 
    1039                 :          0 : }
    1040                 :            : 
    1041                 :          0 : void    SwGlobalTree::ShowTree()
    1042                 :            : {
    1043                 :          0 :     aUpdateTimer.Start();
    1044                 :          0 :     SvTreeListBox::Show();
    1045                 :          0 : }
    1046                 :            : 
    1047                 :          0 : void    SwGlobalTree::HideTree()
    1048                 :            : {
    1049                 :          0 :     aUpdateTimer.Stop();
    1050                 :          0 :     SvTreeListBox::Hide();
    1051                 :          0 : }
    1052                 :            : 
    1053                 :          0 : void    SwGlobalTree::ExecCommand(sal_uInt16 nCmd)
    1054                 :            : {
    1055                 :          0 :     SvLBoxEntry* pEntry = FirstSelected();
    1056                 :            :     OSL_ENSURE(pEntry, "gleich knallt's");
    1057         [ #  # ]:          0 :     if(FN_GLOBAL_EDIT == nCmd)
    1058                 :            :     {
    1059                 :            :         const SwGlblDocContent* pCont = (const SwGlblDocContent*)
    1060                 :          0 :                                                 pEntry->GetUserData();
    1061                 :          0 :         EditContent(pCont);
    1062                 :            :     }
    1063                 :            :     else
    1064                 :            :     {
    1065         [ #  # ]:          0 :         if(GetSelectionCount() == 1)
    1066                 :            :         {
    1067                 :          0 :             sal_Bool bMove = sal_False;
    1068                 :          0 :             sal_uInt16 nSource = (sal_uInt16)GetModel()->GetAbsPos(pEntry);
    1069                 :          0 :             sal_uInt16 nDest = nSource;
    1070      [ #  #  # ]:          0 :             switch(nCmd)
    1071                 :            :             {
    1072                 :            :                 case FN_ITEM_DOWN:
    1073                 :            :                 {
    1074                 :          0 :                     sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
    1075                 :          0 :                     bMove = nEntryCount > nSource + 1;
    1076                 :          0 :                     nDest+= 2;
    1077                 :            :                 }
    1078                 :          0 :                 break;
    1079                 :            :                 case FN_ITEM_UP:
    1080                 :            :                 {
    1081         [ #  # ]:          0 :                     if(nSource)
    1082                 :          0 :                         bMove = 0 != nSource;
    1083                 :          0 :                     nDest--;
    1084                 :            :                 }
    1085                 :          0 :                 break;
    1086                 :            :             }
    1087   [ #  #  #  #  :          0 :             if( bMove && pActiveShell->MoveGlobalDocContent(
           #  # ][ #  # ]
    1088                 :          0 :                 *pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
    1089                 :          0 :                     Update( sal_False ))
    1090                 :          0 :                 Display();
    1091                 :            :         }
    1092                 :            :     }
    1093                 :          0 : }
    1094                 :            : 
    1095                 :          0 : sal_Bool    SwGlobalTree::Update(sal_Bool bHard)
    1096                 :            : {
    1097                 :          0 :     SwView* pActView = GetParentWindow()->GetCreateView();
    1098                 :          0 :     sal_Bool bRet = sal_False;
    1099 [ #  # ][ #  # ]:          0 :     if(pActView && pActView->GetWrtShellPtr())
                 [ #  # ]
    1100                 :            :     {
    1101                 :          0 :         const SwWrtShell* pOldShell = pActiveShell;
    1102                 :          0 :         pActiveShell = pActView->GetWrtShellPtr();
    1103         [ #  # ]:          0 :         if(pActiveShell != pOldShell)
    1104                 :            :         {
    1105         [ #  # ]:          0 :             delete pSwGlblDocContents;
    1106                 :          0 :             pSwGlblDocContents = 0;
    1107                 :            :         }
    1108         [ #  # ]:          0 :         if(!pSwGlblDocContents)
    1109                 :            :         {
    1110         [ #  # ]:          0 :             pSwGlblDocContents = new SwGlblDocContents;
    1111                 :          0 :             bRet = sal_True;
    1112                 :          0 :             pActiveShell->GetGlobalDocContent(*pSwGlblDocContents);
    1113                 :            :         }
    1114                 :            :         else
    1115                 :            :         {
    1116                 :          0 :             sal_Bool bCopy = sal_False;
    1117         [ #  # ]:          0 :             SwGlblDocContents* pTempContents  = new SwGlblDocContents;
    1118                 :          0 :             pActiveShell->GetGlobalDocContent(*pTempContents);
    1119         [ #  # ]:          0 :             if(pTempContents->size() != pSwGlblDocContents->size() ||
           [ #  #  #  # ]
    1120                 :          0 :                     pTempContents->size() != GetEntryCount())
    1121                 :            :             {
    1122                 :          0 :                 bRet = sal_True;
    1123                 :          0 :                 bCopy = sal_True;
    1124                 :            :             }
    1125                 :            :             else
    1126                 :            :             {
    1127 [ #  # ][ #  # ]:          0 :                 for(sal_uInt16 i = 0; i < pTempContents->size() && !bCopy; i++)
                 [ #  # ]
    1128                 :            :                 {
    1129         [ #  # ]:          0 :                     SwGlblDocContent* pLeft = (*pTempContents)[i];
    1130         [ #  # ]:          0 :                     SwGlblDocContent* pRight = (*pSwGlblDocContents)[i];
    1131                 :          0 :                     GlobalDocContentType eType = pLeft->GetType();
    1132         [ #  # ]:          0 :                     SvLBoxEntry* pEntry = GetEntry(i);
    1133         [ #  # ]:          0 :                     String sTemp = GetEntryText(pEntry);
    1134 [ #  # ][ #  # ]:          0 :                     if (
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1135                 :          0 :                          eType != pRight->GetType() ||
    1136                 :            :                          (
    1137                 :            :                            eType == GLBLDOC_SECTION &&
    1138         [ #  # ]:          0 :                            pLeft->GetSection()->GetSectionName() != sTemp
    1139                 :            :                          ) ||
    1140                 :            :                          (
    1141                 :            :                            eType == GLBLDOC_TOXBASE &&
    1142 [ #  # ][ #  # ]:          0 :                            pLeft->GetTOX()->GetTitle() != sTemp
    1143                 :            :                          )
    1144                 :            :                        )
    1145                 :            :                     {
    1146                 :          0 :                         bCopy = bRet = sal_True;
    1147                 :            :                     }
    1148         [ #  # ]:          0 :                 }
    1149                 :            :             }
    1150 [ #  # ][ #  # ]:          0 :             if(bCopy || bHard)
    1151                 :            :             {
    1152                 :          0 :                 pSwGlblDocContents->DeleteAndDestroyAll();
    1153                 :          0 :                 pSwGlblDocContents->insert( *pTempContents );
    1154                 :          0 :                 pTempContents->clear();
    1155                 :            : 
    1156                 :            :             }
    1157         [ #  # ]:          0 :             delete pTempContents;
    1158                 :            :         }
    1159                 :            : 
    1160                 :            :     }
    1161                 :            :     else
    1162                 :            :     {
    1163                 :          0 :         Clear();
    1164         [ #  # ]:          0 :         if(pSwGlblDocContents)
    1165                 :          0 :             pSwGlblDocContents->DeleteAndDestroyAll();
    1166                 :            :     }
    1167                 :            :     // hier muss noch eine Veraenderungspruefung rein!
    1168                 :          0 :     return bRet;
    1169                 :            : }
    1170                 :            : 
    1171                 :          0 : void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont)
    1172                 :            : {
    1173         [ #  # ]:          0 :     String sFileName(pCont->GetSection()->GetLinkFileName().GetToken(0,
    1174         [ #  # ]:          0 :             sfx2::cTokenSeperator));
    1175                 :          0 :     sal_Bool bFound = sal_False;
    1176         [ #  # ]:          0 :     const SfxObjectShell* pCurr = SfxObjectShell::GetFirst();
    1177 [ #  # ][ #  # ]:          0 :     while( !bFound && pCurr )
                 [ #  # ]
    1178                 :            :     {
    1179 [ #  # ][ #  # ]:          0 :         if(pCurr->GetMedium() &&
                 [ #  # ]
    1180 [ #  # ][ #  # ]:          0 :             String(pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)) == sFileName)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1181                 :            :         {
    1182                 :          0 :             bFound = sal_True;
    1183                 :          0 :             SwGlobalTree::SetShowShell(pCurr);
    1184                 :            :             Application::PostUserEvent( STATIC_LINK(
    1185 [ #  # ][ #  # ]:          0 :                         this, SwGlobalTree, ShowFrameHdl ) );
    1186                 :          0 :             pCurr = 0;
    1187                 :            :         }
    1188                 :            :         else
    1189         [ #  # ]:          0 :             pCurr = SfxObjectShell::GetNext(*pCurr);
    1190                 :            :     }
    1191         [ #  # ]:          0 :     if(!bFound)
    1192                 :            :     {
    1193                 :            :         SfxStringItem aURL(SID_FILE_NAME,
    1194         [ #  # ]:          0 :             sFileName);
    1195         [ #  # ]:          0 :         SfxBoolItem aReadOnly(SID_DOC_READONLY, sal_False);
    1196 [ #  # ][ #  # ]:          0 :         SfxStringItem aTargetFrameName( SID_TARGETNAME, rtl::OUString("_blank") );
                 [ #  # ]
    1197 [ #  # ][ #  # ]:          0 :         SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle());
         [ #  # ][ #  # ]
    1198                 :          0 :         pActiveShell->GetView().GetViewFrame()->GetDispatcher()->
    1199                 :            :                 Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
    1200 [ #  # ][ #  # ]:          0 :                             &aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L);
         [ #  # ][ #  # ]
                 [ #  # ]
    1201         [ #  # ]:          0 :     }
    1202                 :          0 : }
    1203                 :            : 
    1204                 :          0 : IMPL_LINK_NOARG( SwGlobalTree, DoubleClickHdl)
    1205                 :            : {
    1206                 :          0 :     SvLBoxEntry* pEntry = GetCurEntry();
    1207                 :          0 :     SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
    1208         [ #  # ]:          0 :     if(pCont->GetType() == GLBLDOC_SECTION)
    1209                 :          0 :         OpenDoc(pCont);
    1210                 :            :     else
    1211                 :            :     {
    1212                 :          0 :         GotoContent(pCont);
    1213                 :          0 :         pActiveShell->GetView().GetEditWin().GrabFocus();
    1214                 :            :     }
    1215                 :          0 :     return 0;
    1216                 :            : }
    1217                 :            : 
    1218                 :          0 : IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG)
    1219                 :            : {
    1220         [ #  # ]:          0 :     if(SwGlobalTree::GetShowShell())
    1221                 :          0 :         SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop();
    1222                 :          0 :     SwGlobalTree::SetShowShell(0);
    1223                 :          0 :     return 0;
    1224                 :            : }
    1225                 :            : 
    1226                 :          0 : void SwGlobalTree::InitEntry(SvLBoxEntry* pEntry,
    1227                 :            :         const XubString& rStr ,const Image& rImg1,const Image& rImg2,
    1228                 :            :         SvLBoxButtonKind eButtonKind)
    1229                 :            : {
    1230                 :          0 :     sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
    1231                 :          0 :     SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
    1232                 :          0 :     SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
    1233 [ #  # ][ #  # ]:          0 :     SwLBoxString* pStr = new SwLBoxString( pEntry, 0, pCol->GetText() );
         [ #  # ][ #  # ]
    1234                 :          0 :     pEntry->ReplaceItem( pStr, nColToHilite );
    1235                 :          0 : }
    1236                 :            : 
    1237                 :          0 : void SwLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
    1238                 :            :     SvLBoxEntry* pEntry )
    1239                 :            : {
    1240                 :          0 :     SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
    1241         [ #  # ]:          0 :     if(pCont->GetType() == GLBLDOC_SECTION &&
           [ #  #  #  # ]
    1242                 :          0 :         !(pCont->GetSection())->IsConnectFlag() )
    1243                 :            :     {
    1244         [ #  # ]:          0 :         Font aOldFont( rDev.GetFont());
    1245         [ #  # ]:          0 :         Font aFont(aOldFont);
    1246                 :          0 :         Color aCol( COL_LIGHTRED );
    1247         [ #  # ]:          0 :         aFont.SetColor( aCol );
    1248         [ #  # ]:          0 :         rDev.SetFont( aFont );
    1249 [ #  # ][ #  # ]:          0 :         rDev.DrawText( rPos, GetText() );
                 [ #  # ]
    1250 [ #  # ][ #  # ]:          0 :         rDev.SetFont( aOldFont );
                 [ #  # ]
    1251                 :            :     }
    1252                 :            :     else
    1253                 :          0 :         SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
    1254                 :          0 : }
    1255                 :            : 
    1256                 :          0 : void    SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt )
    1257                 :            : {
    1258   [ #  #  #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
                 [ #  # ]
    1259                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1260                 :            :     {
    1261 [ #  # ][ #  # ]:          0 :         aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP));
                 [ #  # ]
    1262                 :          0 :         Update(sal_True);
    1263                 :            :     }
    1264                 :          0 :     SvTreeListBox::DataChanged( rDCEvt );
    1265                 :          0 : }
    1266                 :            : 
    1267                 :          0 : void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles )
    1268                 :            : {
    1269                 :          0 :     sal_Int32 nFiles = _rFiles.getLength();
    1270         [ #  # ]:          0 :     if ( nFiles )
    1271                 :            :     {
    1272                 :          0 :         sal_Bool bMove = sal_False;
    1273         [ #  # ]:          0 :         if ( !_pContent )
    1274                 :            :         {
    1275         [ #  # ]:          0 :             SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
    1276                 :          0 :             _pContent = (SwGlblDocContent*)pLast->GetUserData();
    1277                 :          0 :             bMove = sal_True;
    1278                 :            :         }
    1279         [ #  # ]:          0 :         String sFilePassword;
    1280                 :          0 :         sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
    1281                 :          0 :         const OUString* pFileNames = _rFiles.getConstArray();
    1282 [ #  # ][ #  # ]:          0 :         SwWrtShell& rSh = GetParentWindow()->GetCreateView()->GetWrtShell();
    1283         [ #  # ]:          0 :         rSh.StartAction();
    1284                 :            :         // after insertion of the first new content the 'pCont' parameter becomes invalid
    1285                 :            :         // find the index of the 'anchor' content to always use a current anchor content
    1286                 :          0 :         size_t nAnchorContent = pSwGlblDocContents->size() - 1;
    1287         [ #  # ]:          0 :         if ( !bMove )
    1288                 :            :         {
    1289         [ #  # ]:          0 :             for (size_t nContent = 0; nContent < pSwGlblDocContents->size();
    1290                 :            :                     ++nContent)
    1291                 :            :             {
    1292 [ #  # ][ #  # ]:          0 :                 if( *_pContent == *(*pSwGlblDocContents)[ nContent ] )
    1293                 :            :                 {
    1294                 :          0 :                     nAnchorContent = nContent;
    1295                 :          0 :                     break;
    1296                 :            :                 }
    1297                 :            :             }
    1298                 :            :         }
    1299         [ #  # ]:          0 :         SwGlblDocContents aTempContents;
    1300         [ #  # ]:          0 :         for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile )
    1301                 :            :         {
    1302                 :            :             //update the global document content after each inserted document
    1303         [ #  # ]:          0 :             rSh.GetGlobalDocContent(aTempContents);
    1304                 :          0 :             SwGlblDocContent* pAnchorContent = 0;
    1305                 :            :             OSL_ENSURE(aTempContents.size() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed");
    1306         [ #  # ]:          0 :             if ( aTempContents.size() > (nAnchorContent + nFile) )
    1307         [ #  # ]:          0 :                 pAnchorContent = aTempContents[nAnchorContent + nFile];
    1308                 :            :             else
    1309         [ #  # ]:          0 :                 pAnchorContent = aTempContents.back();
    1310         [ #  # ]:          0 :             String sFileName(pFileNames[nFile]);
    1311         [ #  # ]:          0 :             INetURLObject aFileUrl;
    1312 [ #  # ][ #  # ]:          0 :             aFileUrl.SetSmartURL( sFileName );
    1313                 :            :             String sSectionName(String(aFileUrl.GetLastName(
    1314                 :            :                 INetURLObject::DECODE_UNAMBIGUOUS)).GetToken(0,
    1315 [ #  # ][ #  # ]:          0 :                 sfx2::cTokenSeperator));
         [ #  # ][ #  # ]
    1316         [ #  # ]:          0 :             sal_uInt16 nSectCount = rSh.GetSectionFmtCount();
    1317         [ #  # ]:          0 :             String sTempSectionName(sSectionName);
    1318                 :          0 :             sal_uInt16 nAddNumber = 0;
    1319                 :          0 :             sal_uInt16 nCount = 0;
    1320                 :            :             // evtl : und Index anhaengen, wenn der Bereichsname schon vergeben ist
    1321         [ #  # ]:          0 :             while ( nCount < nSectCount )
    1322                 :            :             {
    1323         [ #  # ]:          0 :                 const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount);
    1324 [ #  # ][ #  # ]:          0 :                 if ((rFmt.GetSection()->GetSectionName() == sTempSectionName)
         [ #  # ][ #  # ]
                 [ #  # ]
    1325         [ #  # ]:          0 :                     && rFmt.IsInNodesArr())
    1326                 :            :                 {
    1327                 :          0 :                     nCount = 0;
    1328                 :          0 :                     nAddNumber++;
    1329         [ #  # ]:          0 :                     sTempSectionName = sSectionName;
    1330         [ #  # ]:          0 :                     sTempSectionName += ':';
    1331 [ #  # ][ #  # ]:          0 :                     sTempSectionName += String::CreateFromInt32( nAddNumber );
                 [ #  # ]
    1332                 :            :                 }
    1333                 :            :                 else
    1334                 :          0 :                     nCount++;
    1335                 :            :             }
    1336                 :            : 
    1337         [ #  # ]:          0 :             if ( nAddNumber )
    1338         [ #  # ]:          0 :                 sSectionName = sTempSectionName;
    1339                 :            : 
    1340         [ #  # ]:          0 :             SwSectionData aSectionData(CONTENT_SECTION, sSectionName);
    1341                 :          0 :             aSectionData.SetProtectFlag(true);
    1342                 :          0 :             aSectionData.SetHidden(false);
    1343                 :            : 
    1344         [ #  # ]:          0 :             aSectionData.SetLinkFileName(sFileName);
    1345                 :          0 :             aSectionData.SetType(FILE_LINK_SECTION);
    1346         [ #  # ]:          0 :             aSectionData.SetLinkFilePassword( sFilePassword );
    1347                 :            : 
    1348         [ #  # ]:          0 :             rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData );
    1349 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
                 [ #  # ]
    1350         [ #  # ]:          0 :         if ( bMove )
    1351                 :            :         {
    1352         [ #  # ]:          0 :             Update( sal_False );
    1353                 :            :             rSh.MoveGlobalDocContent(
    1354         [ #  # ]:          0 :                 *pSwGlblDocContents, nEntryCount, nEntryCount + (sal_uInt16)nFiles, nEntryCount - (sal_uInt16)nFiles );
    1355                 :            :         }
    1356         [ #  # ]:          0 :         rSh.EndAction();
    1357         [ #  # ]:          0 :         Update( sal_False );
    1358 [ #  # ][ #  # ]:          0 :         Display();
                 [ #  # ]
    1359                 :            :     }
    1360                 :          0 : }
    1361                 :            : 
    1362                 :          0 : IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
    1363                 :            : {
    1364                 :          0 :     Application::SetDefDialogParent( pDefParentWin );
    1365         [ #  # ]:          0 :     if ( ERRCODE_NONE == _pFileDlg->GetError() )
    1366                 :            :     {
    1367                 :          0 :         SfxMediumList* pMedList = pDocInserter->CreateMediumList();
    1368         [ #  # ]:          0 :         if ( pMedList )
    1369                 :            :         {
    1370         [ #  # ]:          0 :             Sequence< OUString >aFileNames( pMedList->size() );
    1371         [ #  # ]:          0 :             OUString* pFileNames = aFileNames.getArray();
    1372                 :          0 :             sal_Int32 nPos = 0;
    1373         [ #  # ]:          0 :             for ( size_t i = 0, n = pMedList->size(); i < n; ++i )
    1374                 :            :             {
    1375         [ #  # ]:          0 :                 SfxMedium* pMed = pMedList->at( i );
    1376 [ #  # ][ #  # ]:          0 :                 String sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
                 [ #  # ]
    1377         [ #  # ]:          0 :                 sFileName += sfx2::cTokenSeperator;
    1378 [ #  # ][ #  # ]:          0 :                 sFileName += pMed->GetFilter()->GetFilterName();
    1379         [ #  # ]:          0 :                 sFileName += sfx2::cTokenSeperator;
    1380         [ #  # ]:          0 :                 pFileNames[nPos++] = sFileName;
    1381         [ #  # ]:          0 :             }
    1382         [ #  # ]:          0 :             delete pMedList;
    1383         [ #  # ]:          0 :             InsertRegion( pDocContent, aFileNames );
    1384         [ #  # ]:          0 :             DELETEZ( pDocContent );
    1385                 :            :         }
    1386                 :            :     }
    1387                 :          0 :     return 0;
    1388                 :            : }
    1389                 :            : 
    1390                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10