LCOV - code coverage report
Current view: top level - sw/source/core/inc - txmsrt.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 32 62.5 %
Date: 2015-06-13 12:38:46 Functions: 15 30 50.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 INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
      21             : 
      22             : #include <i18nlangtag/lang.h>
      23             : #include <tox.hxx>
      24             : 
      25             : #include <com/sun/star/lang/Locale.hpp>
      26             : 
      27             : class CharClass;
      28             : class SwContentNode;
      29             : class SwTextNode;
      30             : class SwTextTOXMark;
      31             : class SwIndex;
      32             : class SwFormatField;
      33             : class IndexEntrySupplierWrapper;
      34             : 
      35             : enum TOXSortType
      36             : {
      37             :     TOX_SORT_INDEX,
      38             :     TOX_SORT_CUSTOM,
      39             :     TOX_SORT_CONTENT,
      40             :     TOX_SORT_PARA,
      41             :     TOX_SORT_TABLE,
      42             :     TOX_SORT_AUTHORITY
      43             : };
      44             : 
      45             : struct SwTOXSource
      46             : {
      47             :     const SwContentNode* pNd;
      48             :     sal_Int32 nPos;
      49             :     bool bMainEntry;
      50             : 
      51           4 :     SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain )
      52           4 :         : pNd(pNode), nPos(n), bMainEntry(bMain)
      53             :     {
      54           4 :     }
      55             : };
      56             : 
      57             : typedef std::vector<SwTOXSource> SwTOXSources;
      58             : 
      59          24 : struct TextAndReading
      60             : {
      61             :     OUString sText;
      62             :     OUString sReading;
      63             : 
      64           7 :     TextAndReading() {}
      65             : 
      66           3 :     TextAndReading(const OUString& rText, const OUString& rReading)
      67             :     : sText(rText)
      68           3 :     , sReading(rReading)
      69           3 :     {}
      70             : };
      71             : 
      72             : class SwTOXInternational
      73             : {
      74             :     IndexEntrySupplierWrapper* pIndexWrapper;
      75             :     CharClass* pCharClass;
      76             :     LanguageType eLang;
      77             :     OUString sSortAlgorithm;
      78             :     sal_uInt16 nOptions;
      79             : 
      80             :     void Init();
      81             : 
      82             : public:
      83             :     SwTOXInternational( LanguageType nLang, sal_uInt16 nOptions,
      84             :                         const OUString& rSortAlgorithm );
      85             :     SwTOXInternational( const SwTOXInternational& );
      86             :     ~SwTOXInternational();
      87             : 
      88             :     sal_Int32 Compare( const TextAndReading& rTaR1,
      89             :                        const ::com::sun::star::lang::Locale& rLocale1,
      90             :                        const TextAndReading& rTaR2,
      91             :                        const ::com::sun::star::lang::Locale& rLocale2 ) const;
      92             : 
      93           0 :     inline bool IsEqual( const TextAndReading& rTaR1,
      94             :                          const ::com::sun::star::lang::Locale& rLocale1,
      95             :                          const TextAndReading& rTaR2,
      96             :                          const ::com::sun::star::lang::Locale& rLocale2 ) const
      97             :     {
      98           0 :         return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
      99             :     }
     100             : 
     101           0 :     inline bool IsLess( const TextAndReading& rTaR1,
     102             :                         const ::com::sun::star::lang::Locale& rLocale1,
     103             :                         const TextAndReading& rTaR2,
     104             :                         const ::com::sun::star::lang::Locale& rLocale2 ) const
     105             :     {
     106           0 :         return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
     107             :     }
     108             : 
     109             :     OUString GetIndexKey( const TextAndReading& rTaR,
     110             :                         const ::com::sun::star::lang::Locale& rLcl ) const;
     111             : 
     112             :     OUString GetFollowingText( bool bMorePages ) const;
     113             : 
     114             :     OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const;
     115             :     inline bool IsNumeric( const OUString& rStr ) const;
     116             : };
     117             : 
     118             : /**
     119             :  * Class for sorting directories
     120             :  */
     121             : struct SwTOXSortTabBase
     122             : {
     123             :     SwTOXSources aTOXSources;
     124             :     ::com::sun::star::lang::Locale aLocale;
     125             :     const SwTextNode* pTOXNd;
     126             :     const SwTextTOXMark* pTextMark;
     127             :     const SwTOXInternational* pTOXIntl;
     128             :     sal_uLong nPos;
     129             :     sal_Int32 nCntPos;
     130             :     sal_uInt16 nType;
     131             :     static sal_uInt16 nOpt;
     132             : 
     133             :     SwTOXSortTabBase( TOXSortType nType,
     134             :                       const SwContentNode* pTOXSrc,
     135             :                       const SwTextTOXMark* pTextMark,
     136             :                       const SwTOXInternational* pIntl,
     137             :                       const ::com::sun::star::lang::Locale* pLocale = NULL );
     138           6 :     virtual ~SwTOXSortTabBase() {}
     139             : 
     140           4 :     sal_uInt16  GetType() const         { return nType; }
     141           3 :     static sal_uInt16  GetOptions()     { return nOpt; }
     142             : 
     143             :     virtual void    FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0) const;
     144             :     virtual sal_uInt16  GetLevel()  const = 0;
     145             :     virtual bool    operator==( const SwTOXSortTabBase& );
     146             :     virtual bool    operator<( const SwTOXSortTabBase& );
     147             : 
     148             :     virtual OUString  GetURL() const;
     149             : 
     150             :     inline TextAndReading GetText() const;
     151             :     inline const ::com::sun::star::lang::Locale& GetLocale() const;
     152             : 
     153             : private:
     154             :     mutable bool bValidText;
     155             :     mutable TextAndReading m_aSort;
     156             : 
     157             :     virtual TextAndReading GetText_Impl() const = 0;
     158             : };
     159             : 
     160           5 : inline TextAndReading SwTOXSortTabBase::GetText() const
     161             : {
     162           5 :     if( !bValidText )
     163             :     {
     164             :         // 'this' is 'SwTOXSortTabBase const*', so the virtual
     165             :         // mechanism will call the derived class' GetText_Impl
     166           4 :         m_aSort = GetText_Impl();
     167           4 :         bValidText = true;
     168             :     }
     169           5 :     return m_aSort;
     170             : }
     171             : 
     172           1 : inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
     173             : {
     174           1 :     return aLocale;
     175             : }
     176             : 
     177             : /**
     178             :  * For sorting by text
     179             :  */
     180             : struct SwTOXIndex : public SwTOXSortTabBase
     181             : {
     182             :     SwTOXIndex( const SwTextNode&, const SwTextTOXMark*, sal_uInt16 nOptions, sal_uInt8 nKeyLevel,
     183             :                 const SwTOXInternational& rIntl,
     184             :                 const ::com::sun::star::lang::Locale& rLocale );
     185           2 :     virtual ~SwTOXIndex() {}
     186             : 
     187             :     virtual void    FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const SAL_OVERRIDE;
     188             :     virtual sal_uInt16  GetLevel() const SAL_OVERRIDE;
     189             :     virtual bool    operator==( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     190             :     virtual bool    operator<( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     191             : 
     192             : private:
     193             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     194             : 
     195             :     sal_uInt8   nKeyLevel;
     196             : };
     197             : 
     198             : struct SwTOXCustom : public SwTOXSortTabBase
     199             : {
     200             :     SwTOXCustom( const TextAndReading& rKey, sal_uInt16 nLevel,
     201             :                  const SwTOXInternational& rIntl,
     202             :                  const ::com::sun::star::lang::Locale& rLocale );
     203           0 :     virtual ~SwTOXCustom() {}
     204             : 
     205             :     virtual sal_uInt16 GetLevel() const SAL_OVERRIDE;
     206             :     virtual bool   operator==( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     207             :     virtual bool   operator<( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     208             : 
     209             : private:
     210             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     211             : 
     212             :     TextAndReading m_aKey;
     213             :     sal_uInt16  nLev;
     214             : };
     215             : 
     216             : /**
     217             :  * For sorting by position
     218             :  */
     219             : struct SwTOXContent : public SwTOXSortTabBase
     220             : {
     221             :     SwTOXContent( const SwTextNode&, const SwTextTOXMark*,
     222             :                 const SwTOXInternational& rIntl );
     223           0 :     virtual ~SwTOXContent() {}
     224             : 
     225             :     virtual void    FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const SAL_OVERRIDE;
     226             :     virtual sal_uInt16  GetLevel() const SAL_OVERRIDE;
     227             : private:
     228             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     229             : 
     230             : };
     231             : 
     232             : struct SwTOXPara : public SwTOXSortTabBase
     233             : {
     234             :     SwTOXPara( const SwContentNode&, SwTOXElement, sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER, const OUString& sSeqName = OUString() );
     235           6 :     virtual ~SwTOXPara() {}
     236             : 
     237           0 :     void    SetStartIndex(sal_Int32 nSet)    { nStartIndex = nSet; }
     238           0 :     void    SetEndIndex(sal_Int32 nSet)      { nEndIndex = nSet; }
     239             : 
     240             :     virtual void    FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const SAL_OVERRIDE;
     241             :     virtual sal_uInt16  GetLevel() const SAL_OVERRIDE;
     242             : 
     243             :     virtual OUString  GetURL() const SAL_OVERRIDE;
     244             : private:
     245             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     246             : 
     247             :     SwTOXElement eType;
     248             :     sal_uInt16 m_nLevel;
     249             :     sal_Int32 nStartIndex;
     250             :     sal_Int32 nEndIndex;
     251             :     OUString m_sSequenceName;
     252             : };
     253             : 
     254             : struct SwTOXTable : public SwTOXSortTabBase
     255             : {
     256             :     SwTOXTable( const SwContentNode& rNd );
     257           0 :     virtual ~SwTOXTable() {}
     258             : 
     259           0 :     void    SetLevel(sal_uInt16 nSet){nLevel = nSet;}
     260             : 
     261             :     virtual sal_uInt16  GetLevel() const SAL_OVERRIDE;
     262             : 
     263             :     virtual OUString  GetURL() const SAL_OVERRIDE;
     264             : private:
     265             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     266             : 
     267             :     sal_uInt16 nLevel;
     268             : };
     269             : 
     270             : struct SwTOXAuthority : public SwTOXSortTabBase
     271             : {
     272             : private:
     273             :     SwFormatField& m_rField;
     274             :     virtual void    FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const SAL_OVERRIDE;
     275             :     virtual TextAndReading GetText_Impl() const SAL_OVERRIDE;
     276             : 
     277             : public:
     278             :     SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl );
     279           0 :     virtual ~SwTOXAuthority() {}
     280             : 
     281           0 :     SwFormatField& GetFieldFormat() {return m_rField;}
     282             : 
     283             :     virtual bool    operator==( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     284             :     virtual bool    operator<( const SwTOXSortTabBase& ) SAL_OVERRIDE;
     285             :     virtual sal_uInt16  GetLevel() const SAL_OVERRIDE;
     286             : };
     287             : 
     288             : #endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11