LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - txmsrt.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 30 0.0 %
Date: 2012-12-27 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef SW_TXMSRT_HXX
      20             : #define SW_TXMSRT_HXX
      21             : 
      22             : #include <i18npool/lang.h>
      23             : #include <tox.hxx>
      24             : 
      25             : #include <com/sun/star/lang/Locale.hpp>
      26             : 
      27             : 
      28             : class CharClass;
      29             : class SwCntntNode;
      30             : class SwTxtNode;
      31             : class SwTxtTOXMark;
      32             : class SwIndex;
      33             : class SwFmtFld;
      34             : class IndexEntrySupplierWrapper;
      35             : 
      36             : enum TOXSortType
      37             : {
      38             :     TOX_SORT_INDEX,
      39             :     TOX_SORT_CUSTOM,
      40             :     TOX_SORT_CONTENT,
      41             :     TOX_SORT_PARA,
      42             :     TOX_SORT_TABLE,
      43             :     TOX_SORT_AUTHORITY
      44             : };
      45             : 
      46             : struct SwTOXSource
      47             : {
      48             :     const SwCntntNode* pNd;
      49             :     xub_StrLen nPos;
      50             :     sal_Bool bMainEntry;
      51             : 
      52           0 :     SwTOXSource( const SwCntntNode* pNode, xub_StrLen n, sal_Bool bMain )
      53           0 :         : pNd(pNode), nPos(n), bMainEntry(bMain)
      54             :     {
      55           0 :     }
      56             : };
      57             : 
      58             : typedef std::vector<SwTOXSource> SwTOXSources;
      59             : 
      60             : class SwTOXInternational
      61             : {
      62             :     IndexEntrySupplierWrapper* pIndexWrapper;
      63             :     CharClass* pCharClass;
      64             :     LanguageType eLang;
      65             :     String sSortAlgorithm;
      66             :     sal_uInt16 nOptions;
      67             : 
      68             :     void Init();
      69             : 
      70             : public:
      71             :     SwTOXInternational( LanguageType nLang, sal_uInt16 nOptions,
      72             :                         const String& rSortAlgorithm );
      73             :     SwTOXInternational( const SwTOXInternational& );
      74             :     ~SwTOXInternational();
      75             : 
      76             :     sal_Int32 Compare( const String& rTxt1, const String& rTxtReading1,
      77             :                        const ::com::sun::star::lang::Locale& rLocale1,
      78             :                        const String& rTxt2, const String& rTxtReading2,
      79             :                        const ::com::sun::star::lang::Locale& rLocale2 ) const;
      80             : 
      81           0 :     inline bool IsEqual( const String& rTxt1, const String& rTxtReading1,
      82             :                          const ::com::sun::star::lang::Locale& rLocale1,
      83             :                          const String& rTxt2, const String& rTxtReading2,
      84             :                          const ::com::sun::star::lang::Locale& rLocale2 ) const
      85             :     {
      86             :         return 0 == Compare( rTxt1, rTxtReading1, rLocale1,
      87           0 :                              rTxt2, rTxtReading2, rLocale2 );
      88             :     }
      89             : 
      90           0 :     inline bool IsLess( 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 -1 == Compare( rTxt1, rTxtReading1, rLocale1,
      96           0 :                               rTxt2, rTxtReading2, rLocale2 );
      97             :     }
      98             : 
      99             :     String GetIndexKey( const String& rTxt, const String& rTxtReading,
     100             :                         const ::com::sun::star::lang::Locale& rLcl ) const;
     101             : 
     102             :     String GetFollowingText( sal_Bool bMorePages ) const;
     103             : 
     104             :     String ToUpper( const String& rStr, xub_StrLen nPos ) const;
     105             :     inline sal_Bool IsNumeric( const String& rStr ) const;
     106             : };
     107             : 
     108             : /*--------------------------------------------------------------------
     109             :      Beschreibung: Klassen fuer die Sortierung der Verzeichnisse
     110             :  --------------------------------------------------------------------*/
     111             : 
     112             : struct SwTOXSortTabBase
     113             : {
     114             :     SwTOXSources aTOXSources;
     115             :     ::com::sun::star::lang::Locale aLocale;
     116             :     const SwTxtNode* pTOXNd;
     117             :     const SwTxtTOXMark* pTxtMark;
     118             :     const SwTOXInternational* pTOXIntl;
     119             :     sal_uLong nPos;
     120             :     xub_StrLen nCntPos;
     121             :     sal_uInt16 nType;
     122             :     static sal_uInt16 nOpt;
     123             : 
     124             :     SwTOXSortTabBase( TOXSortType nType,
     125             :                       const SwCntntNode* pTOXSrc,
     126             :                       const SwTxtTOXMark* pTxtMark,
     127             :                       const SwTOXInternational* pIntl,
     128             :                       const ::com::sun::star::lang::Locale* pLocale = NULL );
     129           0 :     virtual ~SwTOXSortTabBase() {}
     130             : 
     131           0 :     sal_uInt16  GetType() const         { return nType; }
     132           0 :     sal_uInt16  GetOptions() const      { return nOpt; }
     133             : 
     134             :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0) const;
     135             :     virtual sal_uInt16  GetLevel()  const = 0;
     136             :     virtual bool    operator==( const SwTOXSortTabBase& );
     137             :     virtual bool    operator<( const SwTOXSortTabBase& );
     138             : 
     139             :     virtual String  GetURL() const;
     140             : 
     141             :     inline void GetTxt( String&, String& ) const;
     142             :     inline const ::com::sun::star::lang::Locale& GetLocale() const;
     143             : 
     144             : private:
     145             :     sal_Bool bValidTxt;
     146             :     String sSortTxt;
     147             :     String sSortTxtReading;
     148             : 
     149             :     virtual void GetText_Impl( String&, String& ) const = 0;
     150             : };
     151             : 
     152           0 : inline void SwTOXSortTabBase::GetTxt( String& rSortTxt,
     153             :                                       String& rSortTxtReading ) const
     154             : {
     155           0 :     if( !bValidTxt )
     156             :     {
     157           0 :         SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this;
     158           0 :         pThis->GetText_Impl( pThis->sSortTxt, pThis->sSortTxtReading );
     159           0 :         pThis->bValidTxt = sal_True;
     160             :     }
     161             : 
     162           0 :     rSortTxt = sSortTxt;
     163           0 :     rSortTxtReading = sSortTxtReading;
     164           0 : }
     165             : 
     166           0 : inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
     167             : {
     168           0 :     return aLocale;
     169             : }
     170             : 
     171             : /*--------------------------------------------------------------------
     172             :      Beschreibung: fuer Sortierung nach Text
     173             :  --------------------------------------------------------------------*/
     174             : 
     175             : struct SwTOXIndex : public SwTOXSortTabBase
     176             : {
     177             :     SwTOXIndex( const SwTxtNode&, const SwTxtTOXMark*, sal_uInt16 nOptions, sal_uInt8 nKeyLevel,
     178             :                 const SwTOXInternational& rIntl,
     179             :                 const ::com::sun::star::lang::Locale& rLocale );
     180           0 :     virtual ~SwTOXIndex() {}
     181             : 
     182             : 
     183             :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     184             :     virtual sal_uInt16  GetLevel() const;
     185             :     virtual bool    operator==( const SwTOXSortTabBase& );
     186             :     virtual bool    operator<( const SwTOXSortTabBase& );
     187             : 
     188             : private:
     189             :     virtual void GetText_Impl( String&, String& ) const;
     190             : 
     191             :     sal_uInt8   nKeyLevel;
     192             : };
     193             : 
     194             : struct SwTOXCustom : public SwTOXSortTabBase
     195             : {
     196             :     SwTOXCustom( const String& rKey, const String& rReading, sal_uInt16 nLevel,
     197             :                  const SwTOXInternational& rIntl,
     198             :                  const ::com::sun::star::lang::Locale& rLocale );
     199           0 :     virtual ~SwTOXCustom() {}
     200             : 
     201             :     virtual sal_uInt16 GetLevel() const;
     202             :     virtual bool   operator==( const SwTOXSortTabBase& );
     203             :     virtual bool   operator<( const SwTOXSortTabBase& );
     204             : 
     205             : private:
     206             :     virtual void GetText_Impl( String&, String& ) const;
     207             : 
     208             :     String  aKey;
     209             :     String  sReading;
     210             :     sal_uInt16  nLev;
     211             : };
     212             : 
     213             : /*--------------------------------------------------------------------
     214             :      Beschreibung: fuer Sortierung nach Position
     215             :  --------------------------------------------------------------------*/
     216             : 
     217             : struct SwTOXContent : public SwTOXSortTabBase
     218             : {
     219             :     SwTOXContent( const SwTxtNode&, const SwTxtTOXMark*,
     220             :                 const SwTOXInternational& rIntl );
     221           0 :     virtual ~SwTOXContent() {}
     222             : 
     223             :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     224             :     virtual sal_uInt16  GetLevel() const;
     225             : private:
     226             :     virtual void GetText_Impl( String&, String& ) const;
     227             : 
     228             : };
     229             : 
     230             : struct SwTOXPara : public SwTOXSortTabBase
     231             : {
     232             :     SwTOXPara( const SwCntntNode&, SwTOXElement, sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER );
     233           0 :     virtual ~SwTOXPara() {}
     234             : 
     235           0 :     void    SetStartIndex( xub_StrLen nSet)     { nStartIndex = nSet;}
     236           0 :     void    SetEndIndex( xub_StrLen nSet )      { nEndIndex = nSet;}
     237             : 
     238             :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     239             :     virtual sal_uInt16  GetLevel() const;
     240             : 
     241             :     virtual String  GetURL() const;
     242             : private:
     243             :     virtual void GetText_Impl( String&, String& ) const;
     244             : 
     245             :     SwTOXElement eType;
     246             :     sal_uInt16 m_nLevel;
     247             :     xub_StrLen nStartIndex;
     248             :     xub_StrLen nEndIndex;
     249             : };
     250             : 
     251             : struct SwTOXTable : public SwTOXSortTabBase
     252             : {
     253             :     SwTOXTable( const SwCntntNode& rNd );
     254           0 :     virtual ~SwTOXTable() {}
     255             : 
     256           0 :     void    SetLevel(sal_uInt16 nSet){nLevel = nSet;}
     257             : 
     258             :     virtual sal_uInt16  GetLevel() const;
     259             : 
     260             :     virtual String  GetURL() const;
     261             : private:
     262             :     virtual void GetText_Impl( String&, String& ) const;
     263             : 
     264             :     sal_uInt16 nLevel;
     265             : };
     266             : 
     267             : struct SwTOXAuthority : public SwTOXSortTabBase
     268             : {
     269             : private:
     270             :     SwFmtFld& m_rField;
     271             :     virtual void    FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
     272             :     virtual void GetText_Impl( String&, String& ) const;
     273             : 
     274             : public:
     275             :     SwTOXAuthority( const SwCntntNode& rNd, SwFmtFld& rField, const SwTOXInternational& rIntl );
     276           0 :     virtual ~SwTOXAuthority() {}
     277             : 
     278           0 :     SwFmtFld& GetFldFmt() {return m_rField;}
     279             : 
     280             :     virtual bool    operator==( const SwTOXSortTabBase& );
     281             :     virtual bool    operator<( const SwTOXSortTabBase& );
     282             :     virtual sal_uInt16  GetLevel() const;
     283             : };
     284             : 
     285             : 
     286             : #endif // SW_TXMSRT_HXX
     287             : 
     288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10