LCOV - code coverage report
Current view: top level - sw/source/core/inc - txmsrt.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 30 56.7 %
Date: 2012-08-25 Functions: 8 25 32.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 24 25.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                 :            : #ifndef SW_TXMSRT_HXX
      29                 :            : #define SW_TXMSRT_HXX
      30                 :            : 
      31                 :            : #include <i18npool/lang.h>
      32                 :            : #include <tox.hxx>
      33                 :            : 
      34                 :            : #include <com/sun/star/lang/Locale.hpp>
      35                 :            : 
      36                 :            : 
      37                 :            : class CharClass;
      38                 :            : class SwCntntNode;
      39                 :            : class SwTxtNode;
      40                 :            : class SwTxtTOXMark;
      41                 :            : class SwIndex;
      42                 :            : class SwFmtFld;
      43                 :            : class IndexEntrySupplierWrapper;
      44                 :            : 
      45                 :            : enum TOXSortType
      46                 :            : {
      47                 :            :     TOX_SORT_INDEX,
      48                 :            :     TOX_SORT_CUSTOM,
      49                 :            :     TOX_SORT_CONTENT,
      50                 :            :     TOX_SORT_PARA,
      51                 :            :     TOX_SORT_TABLE,
      52                 :            :     TOX_SORT_AUTHORITY
      53                 :            : };
      54                 :            : 
      55                 :            : struct SwTOXSource
      56                 :            : {
      57                 :            :     const SwCntntNode* pNd;
      58                 :            :     xub_StrLen nPos;
      59                 :            :     sal_Bool bMainEntry;
      60                 :            : 
      61                 :          2 :     SwTOXSource( const SwCntntNode* pNode, xub_StrLen n, sal_Bool bMain )
      62                 :          2 :         : pNd(pNode), nPos(n), bMainEntry(bMain)
      63                 :            :     {
      64                 :          2 :     }
      65                 :            : };
      66                 :            : 
      67                 :            : typedef std::vector<SwTOXSource> SwTOXSources;
      68                 :            : 
      69                 :            : class SwTOXInternational
      70                 :            : {
      71                 :            :     IndexEntrySupplierWrapper* pIndexWrapper;
      72                 :            :     CharClass* pCharClass;
      73                 :            :     LanguageType eLang;
      74                 :            :     String sSortAlgorithm;
      75                 :            :     sal_uInt16 nOptions;
      76                 :            : 
      77                 :            :     void Init();
      78                 :            : 
      79                 :            : public:
      80                 :            :     SwTOXInternational( LanguageType nLang, sal_uInt16 nOptions,
      81                 :            :                         const String& rSortAlgorithm );
      82                 :            :     SwTOXInternational( const SwTOXInternational& );
      83                 :            :     ~SwTOXInternational();
      84                 :            : 
      85                 :            :     sal_Int32 Compare( const String& rTxt1, const String& rTxtReading1,
      86                 :            :                        const ::com::sun::star::lang::Locale& rLocale1,
      87                 :            :                        const String& rTxt2, const String& rTxtReading2,
      88                 :            :                        const ::com::sun::star::lang::Locale& rLocale2 ) const;
      89                 :            : 
      90                 :          0 :     inline sal_Bool IsEqual( const String& rTxt1, const String& rTxtReading1,
      91                 :            :                          const ::com::sun::star::lang::Locale& rLocale1,
      92                 :            :                          const String& rTxt2, const String& rTxtReading2,
      93                 :            :                          const ::com::sun::star::lang::Locale& rLocale2 ) const
      94                 :            :     {
      95                 :            :         return 0 == Compare( rTxt1, rTxtReading1, rLocale1,
      96                 :          0 :                              rTxt2, rTxtReading2, rLocale2 );
      97                 :            :     }
      98                 :            : 
      99                 :          0 :     inline sal_Bool IsLess( const String& rTxt1, const String& rTxtReading1,
     100                 :            :                         const ::com::sun::star::lang::Locale& rLocale1,
     101                 :            :                         const String& rTxt2, const String& rTxtReading2,
     102                 :            :                         const ::com::sun::star::lang::Locale& rLocale2 ) const
     103                 :            :     {
     104                 :            :         return -1 == Compare( rTxt1, rTxtReading1, rLocale1,
     105                 :          0 :                               rTxt2, rTxtReading2, rLocale2 );
     106                 :            :     }
     107                 :            : 
     108                 :            :     String GetIndexKey( const String& rTxt, const String& rTxtReading,
     109                 :            :                         const ::com::sun::star::lang::Locale& rLcl ) const;
     110                 :            : 
     111                 :            :     String GetFollowingText( sal_Bool bMorePages ) const;
     112                 :            : 
     113                 :            :     String ToUpper( const String& rStr, xub_StrLen nPos ) const;
     114                 :            :     inline sal_Bool IsNumeric( const String& rStr ) const;
     115                 :            : };
     116                 :            : 
     117                 :            : /*--------------------------------------------------------------------
     118                 :            :      Beschreibung: Klassen fuer die Sortierung der Verzeichnisse
     119                 :            :  --------------------------------------------------------------------*/
     120                 :            : 
     121                 :            : struct SwTOXSortTabBase
     122                 :            : {
     123                 :            :     SwTOXSources aTOXSources;
     124                 :            :     ::com::sun::star::lang::Locale aLocale;
     125                 :            :     const SwTxtNode* pTOXNd;
     126                 :            :     const SwTxtTOXMark* pTxtMark;
     127                 :            :     const SwTOXInternational* pTOXIntl;
     128                 :            :     sal_uLong nPos;
     129                 :            :     xub_StrLen nCntPos;
     130                 :            :     sal_uInt16 nType;
     131                 :            :     static sal_uInt16 nOpt;
     132                 :            : 
     133                 :            :     SwTOXSortTabBase( TOXSortType nType,
     134                 :            :                       const SwCntntNode* pTOXSrc,
     135                 :            :                       const SwTxtTOXMark* pTxtMark,
     136                 :            :                       const SwTOXInternational* pIntl,
     137                 :            :                       const ::com::sun::star::lang::Locale* pLocale = NULL );
     138 [ +  - ][ +  - ]:          2 :     virtual ~SwTOXSortTabBase() {}
                 [ -  + ]
     139                 :            : 
     140                 :          2 :     sal_uInt16  GetType() const         { return nType; }
     141                 :          8 :     sal_uInt16  GetOptions() const      { return nOpt; }
     142                 :            : 
     143                 :            :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0) const;
     144                 :            :     virtual sal_uInt16  GetLevel()  const = 0;
     145                 :            :     virtual sal_Bool    operator==( const SwTOXSortTabBase& );
     146                 :            :     virtual sal_Bool    operator<( const SwTOXSortTabBase& );
     147                 :            : 
     148                 :            :     virtual String  GetURL() const;
     149                 :            : 
     150                 :            :     inline void GetTxt( String&, String& ) const;
     151                 :            :     inline const ::com::sun::star::lang::Locale& GetLocale() const;
     152                 :            : 
     153                 :            : private:
     154                 :            :     sal_Bool bValidTxt;
     155                 :            :     String sSortTxt;
     156                 :            :     String sSortTxtReading;
     157                 :            : 
     158                 :            :     virtual void GetText_Impl( String&, String& ) const = 0;
     159                 :            : };
     160                 :            : 
     161                 :          4 : inline void SwTOXSortTabBase::GetTxt( String& rSortTxt,
     162                 :            :                                       String& rSortTxtReading ) const
     163                 :            : {
     164         [ +  + ]:          4 :     if( !bValidTxt )
     165                 :            :     {
     166                 :          2 :         SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this;
     167                 :          2 :         pThis->GetText_Impl( pThis->sSortTxt, pThis->sSortTxtReading );
     168                 :          2 :         pThis->bValidTxt = sal_True;
     169                 :            :     }
     170                 :            : 
     171                 :          4 :     rSortTxt = sSortTxt;
     172                 :          4 :     rSortTxtReading = sSortTxtReading;
     173                 :          4 : }
     174                 :            : 
     175                 :          2 : inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
     176                 :            : {
     177                 :          2 :     return aLocale;
     178                 :            : }
     179                 :            : 
     180                 :            : /*--------------------------------------------------------------------
     181                 :            :      Beschreibung: fuer Sortierung nach Text
     182                 :            :  --------------------------------------------------------------------*/
     183                 :            : 
     184                 :            : struct SwTOXIndex : public SwTOXSortTabBase
     185                 :            : {
     186                 :            :     SwTOXIndex( const SwTxtNode&, const SwTxtTOXMark*, sal_uInt16 nOptions, sal_uInt8 nKeyLevel,
     187                 :            :                 const SwTOXInternational& rIntl,
     188                 :            :                 const ::com::sun::star::lang::Locale& rLocale );
     189         [ -  + ]:          4 :     virtual ~SwTOXIndex() {}
     190                 :            : 
     191                 :            : 
     192                 :            :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     193                 :            :     virtual sal_uInt16  GetLevel() const;
     194                 :            :     virtual sal_Bool    operator==( const SwTOXSortTabBase& );
     195                 :            :     virtual sal_Bool    operator<( const SwTOXSortTabBase& );
     196                 :            : 
     197                 :            : private:
     198                 :            :     virtual void GetText_Impl( String&, String& ) const;
     199                 :            : 
     200                 :            :     sal_uInt8   nKeyLevel;
     201                 :            : };
     202                 :            : 
     203                 :            : struct SwTOXCustom : public SwTOXSortTabBase
     204                 :            : {
     205                 :            :     SwTOXCustom( const String& rKey, const String& rReading, sal_uInt16 nLevel,
     206                 :            :                  const SwTOXInternational& rIntl,
     207                 :            :                  const ::com::sun::star::lang::Locale& rLocale );
     208 [ #  # ][ #  # ]:          0 :     virtual ~SwTOXCustom() {}
                 [ #  # ]
     209                 :            : 
     210                 :            :     virtual sal_uInt16 GetLevel() const;
     211                 :            :     virtual sal_Bool   operator==( const SwTOXSortTabBase& );
     212                 :            :     virtual sal_Bool   operator<( const SwTOXSortTabBase& );
     213                 :            : 
     214                 :            : private:
     215                 :            :     virtual void GetText_Impl( String&, String& ) const;
     216                 :            : 
     217                 :            :     String  aKey;
     218                 :            :     String  sReading;
     219                 :            :     sal_uInt16  nLev;
     220                 :            : };
     221                 :            : 
     222                 :            : /*--------------------------------------------------------------------
     223                 :            :      Beschreibung: fuer Sortierung nach Position
     224                 :            :  --------------------------------------------------------------------*/
     225                 :            : 
     226                 :            : struct SwTOXContent : public SwTOXSortTabBase
     227                 :            : {
     228                 :            :     SwTOXContent( const SwTxtNode&, const SwTxtTOXMark*,
     229                 :            :                 const SwTOXInternational& rIntl );
     230         [ #  # ]:          0 :     virtual ~SwTOXContent() {}
     231                 :            : 
     232                 :            :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     233                 :            :     virtual sal_uInt16  GetLevel() const;
     234                 :            : private:
     235                 :            :     virtual void GetText_Impl( String&, String& ) const;
     236                 :            : 
     237                 :            : };
     238                 :            : 
     239                 :            : struct SwTOXPara : public SwTOXSortTabBase
     240                 :            : {
     241                 :            :     SwTOXPara( const SwCntntNode&, SwTOXElement, sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER );
     242         [ #  # ]:          0 :     virtual ~SwTOXPara() {}
     243                 :            : 
     244                 :          0 :     void    SetStartIndex( xub_StrLen nSet)     { nStartIndex = nSet;}
     245                 :          0 :     void    SetEndIndex( xub_StrLen nSet )      { nEndIndex = nSet;}
     246                 :            : 
     247                 :            :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     248                 :            :     virtual sal_uInt16  GetLevel() const;
     249                 :            : 
     250                 :            :     virtual String  GetURL() const;
     251                 :            : private:
     252                 :            :     virtual void GetText_Impl( String&, String& ) const;
     253                 :            : 
     254                 :            :     SwTOXElement eType;
     255                 :            :     sal_uInt16 m_nLevel;
     256                 :            :     xub_StrLen nStartIndex;
     257                 :            :     xub_StrLen nEndIndex;
     258                 :            : };
     259                 :            : 
     260                 :            : struct SwTOXTable : public SwTOXSortTabBase
     261                 :            : {
     262                 :            :     SwTOXTable( const SwCntntNode& rNd );
     263         [ #  # ]:          0 :     virtual ~SwTOXTable() {}
     264                 :            : 
     265                 :          0 :     void    SetLevel(sal_uInt16 nSet){nLevel = nSet;}
     266                 :            : 
     267                 :            :     virtual sal_uInt16  GetLevel() const;
     268                 :            : 
     269                 :            :     virtual String  GetURL() const;
     270                 :            : private:
     271                 :            :     virtual void GetText_Impl( String&, String& ) const;
     272                 :            : 
     273                 :            :     sal_uInt16 nLevel;
     274                 :            : };
     275                 :            : 
     276                 :            : struct SwTOXAuthority : public SwTOXSortTabBase
     277                 :            : {
     278                 :            : private:
     279                 :            :     SwFmtFld& m_rField;
     280                 :            :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     281                 :            :     virtual void GetText_Impl( String&, String& ) const;
     282                 :            : 
     283                 :            : public:
     284                 :            :     SwTOXAuthority( const SwCntntNode& rNd, SwFmtFld& rField, const SwTOXInternational& rIntl );
     285         [ #  # ]:          0 :     virtual ~SwTOXAuthority() {}
     286                 :            : 
     287                 :          0 :     SwFmtFld& GetFldFmt() {return m_rField;}
     288                 :            : 
     289                 :            :     virtual sal_Bool    operator==( const SwTOXSortTabBase& );
     290                 :            :     virtual sal_Bool    operator<( const SwTOXSortTabBase& );
     291                 :            :     virtual sal_uInt16  GetLevel() const;
     292                 :            : };
     293                 :            : 
     294                 :            : 
     295                 :            : #endif // SW_TXMSRT_HXX
     296                 :            : 
     297                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10