LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/svtools - treelist.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 107 182 58.8 %
Date: 2012-08-25 Functions: 47 74 63.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 27 76 35.5 %

           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                 :            : #ifndef _SVTREELIST_HXX
      30                 :            : #define _SVTREELIST_HXX
      31                 :            : 
      32                 :            : #include <limits.h>
      33                 :            : #include "svtools/svtdllapi.h"
      34                 :            : #include <tools/solar.h>
      35                 :            : #include <vector>
      36                 :            : #include <boost/ptr_container/ptr_map.hpp>
      37                 :            : 
      38                 :            : #include <tools/link.hxx>
      39                 :            : #include <tools/string.hxx>
      40                 :            : #include <tools/debug.hxx>
      41                 :            : 
      42                 :            : #define LISTACTION_INSERTED         1
      43                 :            : #define LISTACTION_REMOVING         2
      44                 :            : #define LISTACTION_REMOVED          3
      45                 :            : #define LISTACTION_MOVING           4
      46                 :            : #define LISTACTION_MOVED            5
      47                 :            : #define LISTACTION_CLEARING         6
      48                 :            : #define LISTACTION_INSERTED_TREE    7
      49                 :            : #define LISTACTION_INVALIDATE_ENTRY 8
      50                 :            : #define LISTACTION_RESORTING        9
      51                 :            : #define LISTACTION_RESORTED         10
      52                 :            : #define LISTACTION_CLEARED          11
      53                 :            : 
      54                 :            : #define SV_TREELIST_ROOT_ENTRY  (SvListEntry*)0
      55                 :            : #define SV_TREELIST_ERROR        0xFFFFFFFF
      56                 :            : 
      57                 :            : // Entryflags, die an der View haengen
      58                 :            : #define SVLISTENTRYFLAG_SELECTED        0x0001
      59                 :            : #define SVLISTENTRYFLAG_EXPANDED        0x0002
      60                 :            : #define SVLISTENTRYFLAG_FOCUSED         0x0004
      61                 :            : #define SVLISTENTRYFLAG_CURSORED        0x0008
      62                 :            : #define SVLISTENTRYFLAG_NOT_SELECTABLE  0x0010
      63                 :            : 
      64                 :            : class SvListEntry;
      65                 :            : 
      66                 :            : //=============================================================================
      67                 :            : 
      68                 :            : typedef ::std::vector< SvListEntry* > SvTreeEntryList_impl;
      69                 :            : 
      70                 :        126 : class SVT_DLLPUBLIC SvTreeEntryList
      71                 :            : {
      72                 :            : private:
      73                 :            :     SvTreeEntryList_impl    maEntryList;
      74                 :            :     size_t                  maCurrent;
      75                 :            : 
      76                 :            : public:
      77                 :        126 :                     SvTreeEntryList() { maCurrent = 0; };
      78                 :            :                     SvTreeEntryList( SvTreeEntryList& rList );
      79                 :            : 
      80                 :            :     void            DestroyAll();
      81                 :          0 :     void            push_back( SvListEntry* pItem )
      82                 :          0 :                     { maEntryList.push_back( pItem ); }
      83                 :       2398 :     void            insert( SvListEntry* pItem, size_t i )
      84                 :            :                     {
      85         [ -  + ]:       2398 :                         if ( i < maEntryList.size() ) {
      86 [ #  # ][ #  # ]:          0 :                             maEntryList.insert( maEntryList.begin() + i, pItem );
      87                 :            :                         } else {
      88                 :       2398 :                             maEntryList.push_back( pItem );
      89                 :            :                         }
      90                 :       2398 :                     }
      91                 :          0 :     void            remove( SvListEntry* pItem )
      92                 :            :                     {
      93 [ #  # ][ #  # ]:          0 :                         for ( SvTreeEntryList_impl::iterator it = maEntryList.begin();
      94                 :          0 :                               it != maEntryList.end();
      95                 :            :                               ++it
      96                 :            :                         ) {
      97         [ #  # ]:          0 :                             if ( *it == pItem ) {
      98         [ #  # ]:          0 :                                 maEntryList.erase( it );
      99                 :          0 :                                 break;
     100                 :            :                             }
     101                 :            :                         }
     102                 :          0 :                     }
     103                 :          0 :     void            remove( size_t i )
     104                 :            :                     {
     105         [ #  # ]:          0 :                         if ( i < maEntryList.size() ) {
     106 [ #  # ][ #  # ]:          0 :                             maEntryList.erase( maEntryList.begin() + i );
     107                 :            :                         }
     108                 :          0 :                     }
     109                 :          0 :     void            replace( SvListEntry* pNew, SvListEntry* pOld )
     110                 :            :                     {
     111         [ #  # ]:          0 :                         for ( size_t i = 0, n = maEntryList.size(); i < n; ++i ) {
     112         [ #  # ]:          0 :                             if ( maEntryList[ i ] == pOld ) {
     113                 :          0 :                                 maEntryList[ i ] = pNew;
     114                 :          0 :                                 break;
     115                 :            :                             }
     116                 :            :                         }
     117                 :          0 :                     }
     118                 :          0 :     void            clear() { maEntryList.clear(); }
     119                 :            : 
     120                 :       2398 :     bool            empty() { return maEntryList.empty(); }
     121                 :            : 
     122                 :      32860 :     size_t          size() { return maEntryList.size(); }
     123                 :          0 :     size_t          GetPos( SvListEntry* pItem )
     124                 :            :                     {
     125         [ #  # ]:          0 :                         for ( size_t i = 0, n = maEntryList.size(); i < n; ++i ) {
     126         [ #  # ]:          0 :                             if ( maEntryList[ i ] == pItem ) {
     127                 :          0 :                                 return i;
     128                 :            :                             }
     129                 :            :                         }
     130                 :          0 :                         return (size_t)~0;
     131                 :            :                     }
     132                 :            : 
     133                 :      40976 :     SvListEntry*    operator[]( size_t i )
     134         [ +  + ]:      40976 :                     { return i < maEntryList.size() ? maEntryList[ i ] : NULL; }
     135                 :        126 :     SvListEntry*    First()
     136                 :            :                     {
     137                 :        126 :                         maCurrent = 0;
     138         [ +  - ]:        126 :                         return ( maCurrent < maEntryList.size() ) ? maEntryList[ 0 ] : NULL;
     139                 :            :                     }
     140                 :       2398 :     SvListEntry*    Next()
     141                 :            :                     {
     142         [ +  + ]:       2398 :                         return ( maCurrent+1 < maEntryList.size() ) ? maEntryList[ ++maCurrent ] : NULL;
     143                 :            :                     }
     144         [ -  + ]:        415 :     SvListEntry*    last() { return maEntryList.empty() ? NULL : maEntryList.back(); }
     145                 :            : };
     146                 :            : 
     147                 :            : //=============================================================================
     148                 :            : 
     149                 :            : class SVT_DLLPUBLIC SvListEntry
     150                 :            : {
     151                 :            : friend class SvTreeList;
     152                 :            : friend class SvListView;
     153                 :            : 
     154                 :            : private:
     155                 :            :     SvListEntry*        pParent;
     156                 :            :     SvTreeEntryList*    pChildren;
     157                 :            :     sal_uLong           nAbsPos;
     158                 :            :     sal_uLong           nListPos;
     159                 :            : 
     160                 :            :     void                SetListPositions();
     161                 :          0 :     void                InvalidateChildrensListPositions()
     162                 :            :     {
     163                 :          0 :         nListPos |= 0x80000000;
     164                 :          0 :     }
     165                 :            : 
     166                 :            : public:
     167                 :            :                         SvListEntry();
     168                 :            :                         SvListEntry( const SvListEntry& );
     169                 :            :     virtual             ~SvListEntry();
     170                 :        194 :     sal_Bool            HasChildren() { return (sal_Bool)(pChildren!=0); }
     171                 :          0 :     sal_Bool            HasChildListPos() const
     172                 :            :     {
     173 [ #  # ][ #  # ]:          0 :         if( pParent && !(pParent->nListPos & 0x80000000) )
     174                 :          0 :             return sal_True;
     175                 :          0 :         else return sal_False;
     176                 :            :     }
     177                 :            : 
     178                 :      29109 :     sal_uLong           GetChildListPos() const
     179                 :            :     {
     180 [ +  - ][ -  + ]:      29109 :         if( pParent && (pParent->nListPos & 0x80000000) )
     181                 :          0 :             pParent->SetListPositions();
     182                 :      29109 :         return ( nListPos & 0x7fffffff );
     183                 :            :     }
     184                 :            : 
     185                 :            :     virtual void        Clone( SvListEntry* pSource );
     186                 :            : };
     187                 :            : 
     188                 :            : class SvListView;
     189                 :            : 
     190                 :            : class SvViewData
     191                 :            : {
     192                 :            : friend class SvTreeList;
     193                 :            : friend class SvListView;
     194                 :            : 
     195                 :            :     sal_uLong           nVisPos;
     196                 :            : protected:
     197                 :            :     sal_uInt16          nFlags;
     198                 :            : public:
     199                 :            :                         SvViewData();
     200                 :            :                         SvViewData( const SvViewData& );
     201                 :            :     virtual             ~SvViewData();
     202                 :            : 
     203                 :      10053 :     sal_Bool            IsSelected() const
     204                 :      10053 :     { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_SELECTED) != 0; }
     205                 :            : 
     206                 :      11248 :     sal_Bool            IsExpanded() const
     207                 :      11248 :     { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_EXPANDED) != 0; }
     208                 :            : 
     209                 :          0 :     sal_Bool            HasFocus() const
     210                 :          0 :     { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_FOCUSED) != 0; }
     211                 :            : 
     212                 :       3648 :     sal_Bool            IsCursored() const
     213                 :       3648 :     { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_CURSORED) != 0; }
     214                 :            : 
     215                 :        246 :     bool                IsSelectable() const
     216                 :        246 :     { return (bool)(nFlags & SVLISTENTRYFLAG_NOT_SELECTABLE) == 0; }
     217                 :            : 
     218                 :        128 :     void                SetFocus( sal_Bool bFocus)
     219                 :            :     {
     220         [ +  + ]:        128 :         if ( !bFocus )
     221                 :          2 :             nFlags &= (~SVLISTENTRYFLAG_FOCUSED);
     222                 :            :         else
     223                 :        126 :             nFlags |= SVLISTENTRYFLAG_FOCUSED;
     224                 :        128 :     }
     225                 :            : 
     226                 :            :     void                SetCursored( sal_Bool bCursored )
     227                 :            :     {
     228                 :            :         if ( !bCursored )
     229                 :            :             nFlags &= (~SVLISTENTRYFLAG_CURSORED);
     230                 :            :         else
     231                 :            :             nFlags |= SVLISTENTRYFLAG_CURSORED;
     232                 :            :     }
     233                 :            : 
     234                 :       6718 :     sal_uInt16          GetFlags() const
     235                 :       6718 :     { return nFlags; }
     236                 :            : 
     237                 :          0 :     void                SetSelectable( bool bSelectable )
     238                 :            :     {
     239         [ #  # ]:          0 :         if( bSelectable )
     240                 :          0 :             nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE);
     241                 :            :         else
     242                 :          0 :             nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE;
     243                 :          0 :     }
     244                 :            : };
     245                 :            : 
     246                 :            : enum SvSortMode { SortAscending, SortDescending, SortNone };
     247                 :            : 
     248                 :            : // Rueckgabewerte Sortlink:
     249                 :            : // siehe International::Compare( pLeft, pRight )
     250                 :            : // ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) )
     251                 :            : struct SvSortData
     252                 :            : {
     253                 :            :     SvListEntry* pLeft;
     254                 :            :     SvListEntry* pRight;
     255                 :            : };
     256                 :            : 
     257                 :            : typedef ::std::vector< SvListView* > SvListView_impl;
     258                 :            : 
     259                 :            : class SVT_DLLPUBLIC SvTreeList
     260                 :            : {
     261                 :            :     friend class        SvListView;
     262                 :            : 
     263                 :            :     SvListView_impl     aViewList;
     264                 :            :     sal_uLong           nEntryCount;
     265                 :            : 
     266                 :            :     Link                aCloneLink;
     267                 :            :     Link                aCompareLink;
     268                 :            :     SvSortMode          eSortMode;
     269                 :            : 
     270                 :            :     sal_uInt16          nRefCount;
     271                 :            : 
     272                 :            :     sal_Bool            bAbsPositionsValid;
     273                 :            : 
     274                 :        669 :     SvListEntry*        FirstVisible() const { return First(); }
     275                 :            :     SvListEntry*        NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
     276                 :            :     SvListEntry*        PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
     277                 :            :     SvListEntry*        LastVisible( const SvListView*,sal_uInt16* pDepth=0 ) const;
     278                 :            :     SvListEntry*        NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
     279                 :            :     SvListEntry*        PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
     280                 :            : 
     281                 :            :     sal_Bool            IsEntryVisible( const SvListView*,SvListEntry* pEntry ) const;
     282                 :            :     SvListEntry*        GetEntryAtVisPos( const SvListView*,sal_uLong nVisPos ) const;
     283                 :            :     sal_uLong           GetVisiblePos( const SvListView*,SvListEntry* pEntry ) const;
     284                 :            :     sal_uLong           GetVisibleCount( SvListView* ) const;
     285                 :            :     sal_uLong           GetVisibleChildCount( const SvListView*,SvListEntry* pParent ) const;
     286                 :            : 
     287                 :            :     SvListEntry*        FirstSelected( const SvListView*) const;
     288                 :            :     SvListEntry*        NextSelected( const SvListView*,SvListEntry* pEntry ) const;
     289                 :            :     SvListEntry*        PrevSelected( const SvListView*,SvListEntry* pEntry ) const;
     290                 :            :     SvListEntry*        LastSelected( const SvListView*) const;
     291                 :            : 
     292                 :            :     sal_Bool            Select( SvListView*,SvListEntry* pEntry, sal_Bool bSelect=sal_True );
     293                 :            :     void                SelectAll( SvListView*,sal_Bool bSelect ); // ruft nicht Select-Hdl
     294                 :            :     sal_uLong           GetChildSelectionCount( const SvListView*,SvListEntry* pParent ) const;
     295                 :            : 
     296                 :            :     void                Expand( SvListView*,SvListEntry* pParent );
     297                 :            :     void                Collapse( SvListView*,SvListEntry* pParent );
     298                 :            : 
     299                 :            :     SVT_DLLPRIVATE void SetAbsolutePositions();
     300                 :            :     SVT_DLLPRIVATE      SvTreeEntryList*CloneChildren(
     301                 :            :                             SvTreeEntryList* pChildren,
     302                 :            :                             SvListEntry* pNewParent,
     303                 :            :                             sal_uLong& nCloneCount
     304                 :            :                         ) const;
     305                 :            : 
     306                 :            :     SVT_DLLPRIVATE void SetListPositions( SvTreeEntryList* );
     307                 :            : 
     308                 :            :     // rPos wird bei SortModeNone nicht geaendert
     309                 :            :     SVT_DLLPRIVATE void GetInsertionPos(
     310                 :            :                             SvListEntry* pEntry,
     311                 :            :                             SvListEntry* pParent,
     312                 :            :                             sal_uLong& rPos
     313                 :            :                         );
     314                 :            : 
     315                 :            :     SVT_DLLPRIVATE void ResortChildren( SvListEntry* pParent );
     316                 :            : 
     317                 :            : protected:
     318                 :            :     SvListEntry*        pRootItem;
     319                 :            : 
     320                 :            : public:
     321                 :            : 
     322                 :            :                         SvTreeList();
     323                 :            :     virtual             ~SvTreeList();
     324                 :            : 
     325                 :            :     void                InsertView( SvListView* );
     326                 :            :     void                RemoveView( SvListView* );
     327                 :            :     sal_uLong           GetViewCount() const
     328                 :            :     { return aViewList.size(); }
     329                 :            : 
     330                 :            :     SvListView*         GetView( sal_uLong nPos ) const
     331                 :            :     { return ( nPos < aViewList.size() ) ? aViewList[ nPos ] : NULL; }
     332                 :            : 
     333                 :            :     void                Broadcast(
     334                 :            :                             sal_uInt16 nActionId,
     335                 :            :                             SvListEntry* pEntry1=0,
     336                 :            :                             SvListEntry* pEntry2=0,
     337                 :            :                             sal_uLong nPos=0
     338                 :            :                         );
     339                 :            : 
     340                 :            :     // informiert alle Listener
     341                 :            :     void                InvalidateEntry( SvListEntry* );
     342                 :            : 
     343                 :          0 :     sal_uLong           GetEntryCount() const { return nEntryCount; }
     344                 :            :     SvListEntry*        First() const;
     345                 :            :     SvListEntry*        Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
     346                 :            :     SvListEntry*        Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
     347                 :            :     SvListEntry*        Last() const;
     348                 :            : 
     349                 :            :     SvListEntry*        FirstChild( SvListEntry* pParent ) const;
     350                 :            :     SvListEntry*        NextSibling( SvListEntry* pEntry ) const;
     351                 :            :     SvListEntry*        PrevSibling( SvListEntry* pEntry ) const;
     352                 :            :     SvListEntry*        LastSibling( SvListEntry* pEntry ) const;
     353                 :            : 
     354                 :            :     sal_uLong           Insert( SvListEntry* pEntry,SvListEntry* pPar,sal_uLong nPos=ULONG_MAX);
     355                 :       2392 :     sal_uLong           Insert( SvListEntry* pEntry,sal_uLong nRootPos = ULONG_MAX )
     356                 :       2392 :     { return Insert(pEntry, pRootItem, nRootPos ); }
     357                 :            : 
     358                 :            :     void                InsertTree( SvListEntry* pTree, SvListEntry* pTargetParent, sal_uLong nListPos );
     359                 :            : 
     360                 :            :     // Entries muessen im gleichen Model stehen!
     361                 :            :     void                Move( SvListEntry* pSource, SvListEntry* pTarget );
     362                 :            : 
     363                 :            :     // erzeugt ggf. Child-List
     364                 :            :     sal_uLong           Move( SvListEntry* pSource, SvListEntry* pTargetParent, sal_uLong nListPos);
     365                 :            :     void                Copy( SvListEntry* pSource, SvListEntry* pTarget );
     366                 :            :     sal_uLong           Copy( SvListEntry* pSource, SvListEntry* pTargetParent, sal_uLong nListPos);
     367                 :            : 
     368                 :            :     sal_Bool            Remove( SvListEntry* pEntry );
     369                 :            :     void                Clear();
     370                 :            : 
     371                 :            :     sal_Bool            HasChildren( SvListEntry* pEntry ) const;
     372                 :          0 :     sal_Bool            HasParent( SvListEntry* pEntry ) const
     373                 :          0 :     { return (sal_Bool)(pEntry->pParent!=pRootItem); }
     374                 :            : 
     375                 :            :     sal_Bool            IsChild( SvListEntry* pParent, SvListEntry* pChild ) const;
     376                 :            :     SvListEntry*        GetEntry( SvListEntry* pParent, sal_uLong nPos ) const;
     377                 :            :     SvListEntry*        GetEntry( sal_uLong nRootPos ) const;
     378                 :            :     SvListEntry*        GetEntryAtAbsPos( sal_uLong nAbsPos ) const;
     379                 :            :     SvListEntry*        GetParent( SvListEntry* pEntry ) const;
     380                 :            :     SvListEntry*        GetRootLevelParent( SvListEntry* pEntry ) const;
     381                 :            :     SvTreeEntryList*    GetChildList( SvListEntry* pParent ) const;
     382                 :            : 
     383                 :            :     sal_uLong           GetAbsPos( SvListEntry* pEntry ) const;
     384                 :          0 :     sal_uLong           GetRelPos( SvListEntry* pChild ) const
     385                 :          0 :     { return pChild->GetChildListPos(); }
     386                 :            : 
     387                 :            :     sal_uLong           GetChildCount( SvListEntry* pParent ) const;
     388                 :            :     sal_uInt16          GetDepth( SvListEntry* pEntry ) const;
     389                 :          0 :     sal_Bool            IsAtRootDepth( SvListEntry* pEntry ) const
     390                 :          0 :     { return (sal_Bool)(pEntry->pParent==pRootItem); }
     391                 :            : 
     392                 :            :     // das Model ruft zum Clonen von Entries den Clone-Link auf,
     393                 :            :     // damit man sich nicht vom Model ableiten muss, wenn man
     394                 :            :     // sich von SvListEntry ableitet.
     395                 :            :     // Deklaration des Clone-Handlers:
     396                 :            :     // DECL_LINK(CloneHdl,SvListEntry*);
     397                 :            :     // der Handler muss einen SvListEntry* zurueckgeben
     398                 :            :     SvListEntry*        Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const;
     399                 :        246 :     void                SetCloneLink( const Link& rLink )
     400                 :        246 :     { aCloneLink=rLink; }
     401                 :            : 
     402                 :          0 :     const Link&         GetCloneLink() const
     403                 :          0 :     { return aCloneLink; }
     404                 :            : 
     405                 :            :     virtual SvListEntry*    CloneEntry( SvListEntry* ) const; // ruft den Clone-Link
     406                 :            :     virtual SvListEntry*    CreateEntry() const; // zum 'new'en von Entries
     407                 :            : 
     408                 :        126 :     sal_uInt16          GetRefCount() const { return nRefCount; }
     409                 :        124 :     void                SetRefCount( sal_uInt16 nRef ) { nRefCount = nRef; }
     410                 :            : 
     411                 :        244 :     void                SetSortMode( SvSortMode eMode ) { eSortMode = eMode; }
     412                 :          0 :     SvSortMode          GetSortMode() const { return eSortMode; }
     413                 :            :     virtual StringCompare   Compare( SvListEntry*, SvListEntry* ) const;
     414                 :        244 :     void                SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; }
     415                 :            :     const Link&         GetCompareHdl() const { return aCompareLink; }
     416                 :            :     void                Resort();
     417                 :            : 
     418                 :            :     void                CheckIntegrity() const;
     419                 :            : };
     420                 :            : 
     421                 :            : class SVT_DLLPUBLIC SvListView
     422                 :            : {
     423                 :            :     friend class SvTreeList;
     424                 :            : 
     425                 :            :     typedef boost::ptr_map<SvListEntry*, SvViewData> SvDataTable;
     426                 :            : 
     427                 :            :     sal_uLong           nVisibleCount;
     428                 :            :     sal_uLong           nSelectionCount;
     429                 :            :     sal_Bool            bVisPositionsValid;
     430                 :            : 
     431                 :            :     SVT_DLLPRIVATE void InitTable();
     432                 :            :     SVT_DLLPRIVATE void ClearTable();
     433                 :            :     SVT_DLLPRIVATE void RemoveViewData( SvListEntry* pParent );
     434                 :            : 
     435                 :            : protected:
     436                 :            :     SvDataTable maDataTable;  // Mapping SvListEntry -> ViewData
     437                 :            :     SvTreeList*         pModel;
     438                 :            : 
     439                 :            :     void                ActionMoving( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
     440                 :            :     void                ActionMoved( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
     441                 :            :     void                ActionInserted( SvListEntry* pEntry );
     442                 :            :     void                ActionInsertedTree( SvListEntry* pEntry );
     443                 :            :     void                ActionRemoving( SvListEntry* pEntry );
     444                 :            :     void                ActionRemoved( SvListEntry* pEntry );
     445                 :            :     void                ActionClear();
     446                 :            : 
     447                 :            : public:
     448                 :            : 
     449                 :            :                         SvListView();   // !!! setzt das Model auf 0
     450                 :            :     virtual             ~SvListView();
     451                 :            :     void                Clear();
     452                 :            :     SvTreeList*         GetModel() const { return pModel; }
     453                 :            :     virtual void        SetModel( SvTreeList* );
     454                 :            :     virtual void        ModelNotification(
     455                 :            :                             sal_uInt16 nActionId,
     456                 :            :                             SvListEntry* pEntry1,
     457                 :            :                             SvListEntry* pEntry2,
     458                 :            :                             sal_uLong nPos
     459                 :            :                         );
     460                 :            : 
     461                 :       1188 :     sal_uLong           GetVisibleCount() const
     462                 :       1188 :     { return pModel->GetVisibleCount( (SvListView*)this ); }
     463                 :            : 
     464                 :        669 :     SvListEntry*        FirstVisible() const
     465                 :        669 :     { return pModel->FirstVisible(); }
     466                 :            : 
     467                 :       6209 :     SvListEntry*        NextVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const
     468                 :       6209 :     { return pModel->NextVisible(this,pEntry,pDepth); }
     469                 :            : 
     470                 :        373 :     SvListEntry*        PrevVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const
     471                 :        373 :     { return pModel->PrevVisible(this,pEntry,pDepth); }
     472                 :            : 
     473                 :        373 :     SvListEntry*        LastVisible( sal_uInt16* pDepth=0 ) const
     474                 :        373 :     { return pModel->LastVisible(this,pDepth); }
     475                 :            : 
     476                 :          0 :     SvListEntry*        NextVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const
     477                 :          0 :     { return pModel->NextVisible(this,pEntry,rDelta); }
     478                 :            : 
     479                 :          0 :     SvListEntry*        PrevVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const
     480                 :          0 :     { return pModel->PrevVisible(this,pEntry,rDelta); }
     481                 :            : 
     482                 :       1764 :     sal_uLong           GetSelectionCount() const
     483                 :       1764 :     { return nSelectionCount; }
     484                 :            : 
     485                 :       1206 :     SvListEntry*        FirstSelected() const
     486                 :       1206 :     { return pModel->FirstSelected(this); }
     487                 :            : 
     488                 :          2 :     SvListEntry*        NextSelected( SvListEntry* pEntry ) const
     489                 :          2 :     { return pModel->NextSelected(this,pEntry); }
     490                 :            : 
     491                 :          0 :     SvListEntry*        PrevSelected( SvListEntry* pEntry ) const
     492                 :          0 :     { return pModel->PrevSelected(this,pEntry); }
     493                 :            : 
     494                 :          0 :     SvListEntry*        LastSelected() const
     495                 :          0 :     { return pModel->LastSelected(this); }
     496                 :          0 :     SvListEntry*        GetEntryAtAbsPos( sal_uLong nAbsPos ) const
     497                 :          0 :     { return pModel->GetEntryAtAbsPos(nAbsPos); }
     498                 :            : 
     499                 :        122 :     SvListEntry*        GetEntryAtVisPos( sal_uLong nVisPos ) const
     500                 :        122 :     { return pModel->GetEntryAtVisPos((SvListView*)this,nVisPos); }
     501                 :            : 
     502                 :          0 :     sal_uLong           GetAbsPos( SvListEntry* pEntry ) const
     503                 :          0 :     { return pModel->GetAbsPos(pEntry); }
     504                 :            : 
     505                 :       2488 :     sal_uLong           GetVisiblePos( SvListEntry* pEntry ) const
     506                 :       2488 :     { return pModel->GetVisiblePos((SvListView*)this,pEntry); }
     507                 :            : 
     508                 :          0 :     sal_uLong           GetVisibleChildCount(SvListEntry* pParent ) const
     509                 :          0 :     { return pModel->GetVisibleChildCount((SvListView*)this,pParent); }
     510                 :            : 
     511                 :          0 :     sal_uLong           GetChildSelectionCount( SvListEntry* pParent ) const
     512                 :          0 :     { return pModel->GetChildSelectionCount((SvListView*)this,pParent); }
     513                 :            : 
     514                 :          4 :     void                Expand( SvListEntry* pParent )
     515                 :          4 :     { pModel->Expand((SvListView*)this,pParent); }
     516                 :            : 
     517                 :          0 :     void                Collapse( SvListEntry* pParent )
     518                 :          0 :     { pModel->Collapse((SvListView*)this,pParent); }
     519                 :            : 
     520                 :        673 :     sal_Bool            Select( SvListEntry* pEntry, sal_Bool bSelect=sal_True )
     521                 :        673 :     { return pModel->Select((SvListView*)this,pEntry,bSelect); }
     522                 :            : 
     523                 :            :     // ruft nicht Select-Hdl
     524                 :          0 :     virtual void        SelectAll( sal_Bool bSelect, sal_Bool )
     525                 :          0 :     { pModel->SelectAll((SvListView*)this, bSelect); }
     526                 :            : 
     527                 :        803 :     sal_Bool            IsEntryVisible( SvListEntry* pEntry ) const
     528                 :        803 :     { return pModel->IsEntryVisible((SvListView*)this,pEntry); }
     529                 :            : 
     530                 :            :     sal_Bool            IsExpanded( SvListEntry* pEntry ) const;
     531                 :            :     sal_Bool            IsSelected( SvListEntry* pEntry ) const;
     532                 :            :     sal_Bool            HasEntryFocus( SvListEntry* pEntry ) const;
     533                 :            :     void                SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus );
     534                 :            :     const SvViewData*         GetViewData( SvListEntry* pEntry ) const;
     535                 :            :     SvViewData*         GetViewData( SvListEntry* pEntry );
     536                 :       1562 :     sal_Bool            HasViewData() const
     537                 :       1562 :     { return maDataTable.size() > 1; }  // eine ROOT gibts immer
     538                 :            : 
     539                 :            :     virtual SvViewData* CreateViewData( SvListEntry* pEntry );
     540                 :            :     virtual void        InitViewData( SvViewData*, SvListEntry* pEntry );
     541                 :            : 
     542                 :            :     virtual void        ModelHasCleared();
     543                 :            :     virtual void        ModelHasInserted( SvListEntry* pEntry );
     544                 :            :     virtual void        ModelHasInsertedTree( SvListEntry* pEntry );
     545                 :            :     virtual void        ModelIsMoving(
     546                 :            :                             SvListEntry* pSource,
     547                 :            :                             SvListEntry* pTargetParent,
     548                 :            :                             sal_uLong nPos
     549                 :            :                         );
     550                 :            :     virtual void        ModelHasMoved( SvListEntry* pSource );
     551                 :            :     virtual void        ModelIsRemoving( SvListEntry* pEntry );
     552                 :            :     virtual void        ModelHasRemoved( SvListEntry* pEntry );
     553                 :            :     virtual void        ModelHasEntryInvalidated( SvListEntry* pEntry );
     554                 :            : };
     555                 :            : 
     556                 :      11248 : inline sal_Bool SvListView::IsExpanded( SvListEntry* pEntry ) const
     557                 :            : {
     558                 :            :     DBG_ASSERT(pEntry,"IsExpanded:No Entry");
     559         [ +  - ]:      11248 :     SvDataTable::const_iterator itr = maDataTable.find(pEntry);
     560                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table");
     561         [ +  - ]:      11248 :     return itr->second->IsExpanded();
     562                 :            : }
     563                 :            : 
     564                 :       2662 : inline sal_Bool SvListView::IsSelected( SvListEntry* pEntry ) const
     565                 :            : {
     566                 :            :     DBG_ASSERT(pEntry,"IsExpanded:No Entry");
     567         [ +  - ]:       2662 :     SvDataTable::const_iterator itr = maDataTable.find(pEntry );
     568                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table");
     569         [ +  - ]:       2662 :     return itr->second->IsSelected();
     570                 :            : }
     571                 :            : 
     572                 :            : inline sal_Bool SvListView::HasEntryFocus( SvListEntry* pEntry ) const
     573                 :            : {
     574                 :            :     DBG_ASSERT(pEntry,"IsExpanded:No Entry");
     575                 :            :     SvDataTable::const_iterator itr = maDataTable.find(pEntry );
     576                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table");
     577                 :            :     return itr->second->HasFocus();
     578                 :            : }
     579                 :            : 
     580                 :          4 : inline void SvListView::SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus )
     581                 :            : {
     582                 :            :     DBG_ASSERT(pEntry,"SetEntryFocus:No Entry");
     583         [ +  - ]:          4 :     SvDataTable::iterator itr = maDataTable.find(pEntry);
     584                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table");
     585         [ +  - ]:          4 :     itr->second->SetFocus(bFocus);
     586                 :          4 : }
     587                 :            : 
     588                 :      36525 : inline const SvViewData* SvListView::GetViewData( SvListEntry* pEntry ) const
     589                 :            : {
     590                 :            : #ifndef DBG_UTIL
     591         [ +  - ]:      36525 :     return maDataTable.find( pEntry )->second;
     592                 :            : #else
     593                 :            :     SvDataTable::const_iterator itr = maDataTable.find( pEntry );
     594                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view");
     595                 :            :     return itr->second;
     596                 :            : #endif
     597                 :            : }
     598                 :            : 
     599                 :       3083 : inline SvViewData* SvListView::GetViewData( SvListEntry* pEntry )
     600                 :            : {
     601                 :            : #ifndef DBG_UTIL
     602         [ +  - ]:       3083 :     return maDataTable.find( pEntry )->second;
     603                 :            : #else
     604                 :            :     SvDataTable::iterator itr = maDataTable.find( pEntry );
     605                 :            :     DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view");
     606                 :            :     return itr->second;
     607                 :            : #endif
     608                 :            : }
     609                 :            : 
     610                 :          0 : inline sal_Bool SvTreeList::HasChildren( SvListEntry* pEntry ) const
     611                 :            : {
     612         [ #  # ]:          0 :     if ( !pEntry )
     613                 :          0 :         pEntry = pRootItem;
     614                 :          0 :     return (sal_Bool)(pEntry->pChildren != 0);
     615                 :            : }
     616                 :            : 
     617                 :       1878 : inline SvListEntry* SvTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos ) const
     618         [ +  + ]:       1878 : {   if ( !pParent )
     619                 :       1744 :         pParent = pRootItem;
     620                 :       1878 :     SvListEntry* pRet = 0;
     621         [ +  - ]:       1878 :     if ( pParent->pChildren )
     622                 :       1878 :         pRet = (*pParent->pChildren)[ nPos ];
     623                 :       1878 :     return pRet;
     624                 :            : }
     625                 :            : 
     626                 :        120 : inline SvListEntry* SvTreeList::GetEntry( sal_uLong nRootPos ) const
     627                 :            : {
     628                 :        120 :     SvListEntry* pRet = 0;
     629         [ +  - ]:        120 :     if ( nEntryCount )
     630                 :        120 :         pRet = (*pRootItem->pChildren)[ nRootPos ];
     631                 :        120 :     return pRet;
     632                 :            : }
     633                 :            : 
     634                 :       2416 : inline SvTreeEntryList* SvTreeList::GetChildList( SvListEntry* pParent ) const
     635                 :            : {
     636         [ +  + ]:       2416 :     if ( !pParent )
     637                 :          4 :         pParent = pRootItem;
     638                 :       2416 :     return pParent->pChildren;
     639                 :            : }
     640                 :            : 
     641                 :       2670 : inline SvListEntry* SvTreeList::GetParent( SvListEntry* pEntry ) const
     642                 :            : {
     643                 :       2670 :     SvListEntry* pParent = pEntry->pParent;
     644         [ +  + ]:       2670 :     if ( pParent==pRootItem )
     645                 :       2638 :         pParent = 0;
     646                 :       2670 :     return pParent;
     647                 :            : }
     648                 :            : 
     649                 :            : #define DECLARE_SVTREELIST( ClassName, Type )                                   \
     650                 :            : class ClassName : public SvTreeList                                             \
     651                 :            : {                                                                               \
     652                 :            : public:                                                                         \
     653                 :            :     Type        First() const                                                   \
     654                 :            :                     { return (Type)SvTreeList::First(); }                       \
     655                 :            :     Type        Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const         \
     656                 :            :                     { return (Type)SvTreeList::Next(pEntry,pDepth); }           \
     657                 :            :     Type        Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const         \
     658                 :            :                     { return (Type)SvTreeList::Prev(pEntry,pDepth); }           \
     659                 :            :     Type        Last() const                                                    \
     660                 :            :                     { return (Type)SvTreeList::Last(); }                        \
     661                 :            :                                                                                 \
     662                 :            :     Type        Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const      \
     663                 :            :                     { return (Type)SvTreeList::Clone(pEntry,nCloneCount); }     \
     664                 :            :     Type        GetEntry( SvListEntry* pParent, sal_uLong nPos ) const          \
     665                 :            :                     { return (Type)SvTreeList::GetEntry(pParent,nPos); }        \
     666                 :            :     Type        GetEntry( sal_uLong nRootPos ) const                            \
     667                 :            :                     { return (Type)SvTreeList::GetEntry(nRootPos); }            \
     668                 :            :     Type        GetParent( SvListEntry* pEntry ) const                          \
     669                 :            :                     { return (Type)SvTreeList::GetParent(pEntry); }             \
     670                 :            :     using SvTreeList::FirstChild;                                               \
     671                 :            :     Type        FirstChild( Type pParent ) const                                \
     672                 :            :                     { return (Type)SvTreeList::FirstChild(pParent); }           \
     673                 :            :     using SvTreeList::NextSibling;                                              \
     674                 :            :     Type        NextSibling( Type pEntry ) const                                \
     675                 :            :                     { return (Type)SvTreeList::NextSibling(pEntry); }           \
     676                 :            :     using SvTreeList::PrevSibling;                                              \
     677                 :            :     Type        PrevSibling( Type pEntry ) const                                \
     678                 :            :                     { return (Type)SvTreeList::PrevSibling(pEntry); }           \
     679                 :            :     using SvTreeList::LastSibling;                                              \
     680                 :            :     Type        LastSibling( Type pEntry ) const                                \
     681                 :            :                     { return (Type)SvTreeList::LastSibling(pEntry); }           \
     682                 :            :     Type        GetEntryAtAbsPos( sal_uLong nAbsPos ) const                     \
     683                 :            :                     { return (Type)SvTreeList::GetEntryAtAbsPos( nAbsPos); }    \
     684                 :            : };
     685                 :            : 
     686                 :            : #endif
     687                 :            : 
     688                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10