LCOV - code coverage report
Current view: top level - sw/source/core/tox - tox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 309 425 72.7 %
Date: 2012-08-25 Functions: 34 44 77.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 369 856 43.1 %

           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                 :            : 
      30                 :            : #include <comphelper/string.hxx>
      31                 :            : #include <tools/resid.hxx>
      32                 :            : #include <hintids.hxx>
      33                 :            : #include <swtypes.hxx>
      34                 :            : #include <txtatr.hxx>
      35                 :            : #include <ndtxt.hxx>
      36                 :            : #include <txttxmrk.hxx>
      37                 :            : #include <tox.hxx>
      38                 :            : #include <poolfmt.hrc>
      39                 :            : #include <doc.hxx>
      40                 :            : #include <docary.hxx>
      41                 :            : #include <paratr.hxx>
      42                 :            : #include <editeng/tstpitem.hxx>
      43                 :            : #include <SwStyleNameMapper.hxx>
      44                 :            : #include <hints.hxx> // SwPtrMsgPoolItem
      45                 :            : #include <algorithm>
      46                 :            : #include <functional>
      47                 :            : #include <switerator.hxx>
      48                 :            : 
      49                 :            : using namespace std;
      50                 :            : 
      51                 :            : const sal_Char* SwForm::aFormEntry      = "<E>";
      52                 :            : const sal_Char* SwForm::aFormTab        = "<T>";
      53                 :            : const sal_Char* SwForm::aFormPageNums   = "<#>";
      54                 :            : const sal_Char* SwForm::aFormLinkStt    = "<LS>";
      55                 :            : const sal_Char* SwForm::aFormLinkEnd    = "<LE>";
      56                 :            : const sal_Char* SwForm::aFormEntryNum   = "<E#>";
      57                 :            : const sal_Char* SwForm::aFormEntryTxt   = "<ET>";
      58                 :            : const sal_Char* SwForm::aFormChapterMark= "<C>";
      59                 :            : const sal_Char* SwForm::aFormText       = "<X>";
      60                 :            : const sal_Char* SwForm::aFormAuth       = "<A>";
      61                 :            : sal_uInt8 SwForm::nFormTabLen            = 3;
      62                 :            : sal_uInt8 SwForm::nFormEntryLen          = 3;
      63                 :            : sal_uInt8 SwForm::nFormPageNumsLen       = 3;
      64                 :            : sal_uInt8 SwForm::nFormLinkSttLen        = 4;
      65                 :            : sal_uInt8 SwForm::nFormLinkEndLen        = 4;
      66                 :            : sal_uInt8 SwForm::nFormEntryNumLen       = 4;
      67                 :            : sal_uInt8 SwForm::nFormEntryTxtLen       = 4;
      68                 :            : sal_uInt8 SwForm::nFormChapterMarkLen    = 3;
      69                 :            : sal_uInt8 SwForm::nFormTextLen           = 3;
      70                 :            : sal_uInt8 SwForm::nFormAuthLen           = 5;
      71                 :            : 
      72 [ +  + ][ -  + ]:       4627 : TYPEINIT2( SwTOXMark, SfxPoolItem, SwClient );    // fuers rtti
                 [ -  + ]
      73                 :            : 
      74                 :            : struct PatternIni
      75                 :            : {
      76                 :            :     sal_uInt16 n1;
      77                 :            :     sal_uInt16 n2;
      78                 :            :     sal_uInt16 n3;
      79                 :            :     sal_uInt16 n4;
      80                 :            :     sal_uInt16 n5;
      81                 :            : };
      82                 :            : const PatternIni aPatternIni[] =
      83                 :            : {
      84                 :            :     {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX},    //Header - no pattern
      85                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},   //AUTH_TYPE_ARTICLE,
      86                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_BOOK,
      87                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_BOOKLET,
      88                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CONFERENCE,
      89                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_INBOOK,
      90                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_INCOLLECTION,
      91                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_INPROCEEDINGS,
      92                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_JOURNAL,
      93                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_MANUAL,
      94                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_MASTERSTHESIS,
      95                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_MISC,
      96                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_PHDTHESIS,
      97                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_PROCEEDINGS,
      98                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_TECHREPORT,
      99                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_UNPUBLISHED,
     100                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_EMAIL,
     101                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, AUTH_FIELD_URL, USHRT_MAX},//AUTH_TYPE_WWW,
     102                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CUSTOM1,
     103                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CUSTOM2,
     104                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CUSTOM3,
     105                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CUSTOM4,
     106                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_TYPE_CUSTOM5,
     107                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_YEAR,
     108                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_URL,
     109                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_CUSTOM1,
     110                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_CUSTOM2,
     111                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_CUSTOM3,
     112                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_CUSTOM4,
     113                 :            :     {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX},     //AUTH_FIELD_CUSTOM5,
     114                 :            :     {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}
     115                 :            : };
     116                 :            : 
     117                 :         88 : SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId)
     118                 :            : {
     119         [ +  - ]:         88 :     SwFormTokens aRet;
     120                 :            : 
     121                 :         88 :     PatternIni aIni = aPatternIni[nTypeId];
     122                 :            :     sal_uInt16 nVals[5];
     123                 :         88 :     nVals[0] = aIni.n1;
     124                 :         88 :     nVals[1] = aIni.n2;
     125                 :         88 :     nVals[2] = aIni.n3;
     126                 :         88 :     nVals[3] = aIni.n4;
     127                 :         88 :     nVals[4] = aIni.n5;
     128                 :            : 
     129         [ +  - ]:         88 :     SwFormToken aStartToken( TOKEN_AUTHORITY );
     130                 :         88 :     aStartToken.nAuthorityField = AUTH_FIELD_IDENTIFIER;
     131         [ +  - ]:         88 :     aRet.push_back( aStartToken );
     132         [ +  - ]:         88 :     SwFormToken aSeparatorToken( TOKEN_TEXT );
     133         [ +  - ]:         88 :     aSeparatorToken.sText = rtl::OUString(": ");
     134         [ +  - ]:         88 :     aRet.push_back( aSeparatorToken );
     135         [ +  - ]:         88 :     SwFormToken aTextToken( TOKEN_TEXT );
     136         [ +  - ]:         88 :     aTextToken.sText = rtl::OUString(", ");
     137                 :            : 
     138         [ +  - ]:        444 :     for(sal_uInt16 i = 0; i < 5 ; i++)
     139                 :            :     {
     140         [ +  + ]:        356 :         if(nVals[i] == USHRT_MAX)
     141                 :            :             break;
     142         [ +  + ]:        268 :         if( i > 0 )
     143         [ +  - ]:        180 :             aRet.push_back( aTextToken );
     144                 :            : 
     145                 :            :          // -> #i21237#
     146         [ +  - ]:        268 :         SwFormToken aToken(TOKEN_AUTHORITY);
     147                 :            : 
     148                 :        268 :         aToken.nAuthorityField = nVals[i];
     149         [ +  - ]:        268 :         aRet.push_back(aToken);
     150                 :            :         // <- #i21237#
     151         [ +  - ]:        268 :     }
     152                 :            : 
     153 [ +  - ][ +  - ]:         88 :     return aRet;
                 [ +  - ]
     154                 :            : }
     155                 :            : /*--------------------------------------------------------------------
     156                 :            :      TOX dtor and ctor
     157                 :            :  --------------------------------------------------------------------*/
     158                 :            : 
     159                 :            : 
     160                 :            : /// pool default constructor
     161                 :         73 : SwTOXMark::SwTOXMark()
     162                 :            :     : SfxPoolItem( RES_TXTATR_TOXMARK )
     163                 :            :     , SwModify( 0 )
     164                 :            :     ,
     165                 :            :     pTxtAttr( 0 ),
     166                 :            :     bAutoGenerated(sal_False),
     167 [ +  - ][ +  - ]:         73 :     bMainEntry(sal_False)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     168                 :            : {
     169                 :         73 : }
     170                 :            : 
     171                 :            : 
     172                 :         70 : SwTOXMark::SwTOXMark( const SwTOXType* pTyp )
     173                 :            :     : SfxPoolItem( RES_TXTATR_TOXMARK )
     174                 :            :     , SwModify( const_cast<SwTOXType*>(pTyp) )
     175                 :            :     ,
     176                 :            :     pTxtAttr( 0 ), nLevel( 0 ),
     177                 :            :     bAutoGenerated(sal_False),
     178 [ +  - ][ +  - ]:         70 :     bMainEntry(sal_False)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     179                 :            : {
     180                 :         70 : }
     181                 :            : 
     182                 :            : 
     183                 :        410 : SwTOXMark::SwTOXMark( const SwTOXMark& rCopy )
     184                 :            :     : SfxPoolItem( RES_TXTATR_TOXMARK )
     185                 :            :     , SwModify(rCopy.GetRegisteredInNonConst())
     186                 :            :     ,
     187                 :            :     aPrimaryKey( rCopy.aPrimaryKey ), aSecondaryKey( rCopy.aSecondaryKey ),
     188                 :            :     aTextReading( rCopy.aTextReading ),
     189                 :            :     aPrimaryKeyReading( rCopy.aPrimaryKeyReading ),
     190                 :            :     aSecondaryKeyReading( rCopy.aSecondaryKeyReading ),
     191                 :            :     pTxtAttr( 0 ), nLevel( rCopy.nLevel ),
     192                 :            :     bAutoGenerated( rCopy.bAutoGenerated),
     193 [ +  - ][ +  - ]:        410 :     bMainEntry(rCopy.bMainEntry)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     194                 :            : {
     195                 :            :     // Copy AlternativString
     196         [ +  - ]:        410 :     aAltText = rCopy.aAltText;
     197                 :        410 : }
     198                 :            : 
     199                 :            : 
     200 [ +  - ][ +  - ]:        553 : SwTOXMark::~SwTOXMark()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     201                 :            : {
     202         [ -  + ]:       1002 : }
     203                 :            : 
     204                 :            : 
     205                 :          0 : void SwTOXMark::RegisterToTOXType( SwTOXType& rMark )
     206                 :            : {
     207                 :          0 :     rMark.Add(this);
     208                 :          0 : }
     209                 :            : 
     210                 :         12 : int SwTOXMark::operator==( const SfxPoolItem& rAttr ) const
     211                 :            : {
     212                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "Attributes are not the same" );
     213                 :         12 :     return GetRegisteredIn() == ((SwTOXMark&)rAttr).GetRegisteredIn();
     214                 :            : }
     215                 :            : 
     216                 :            : 
     217                 :        376 : SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const
     218                 :            : {
     219         [ +  - ]:        376 :     return new SwTOXMark( *this );
     220                 :            : }
     221                 :            : 
     222                 :          0 : void SwTOXMark::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew)
     223                 :            : {
     224                 :          0 :     NotifyClients(pOld, pNew);
     225 [ #  # ][ #  # ]:          0 :     if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
                 [ #  # ]
     226                 :            :     {   // invalidate cached uno object
     227                 :            :         SetXTOXMark(::com::sun::star::uno::Reference<
     228         [ #  # ]:          0 :                         ::com::sun::star::text::XDocumentIndexMark>(0));
     229                 :            :     }
     230                 :          0 : }
     231                 :            : 
     232                 :         78 : void SwTOXMark::InvalidateTOXMark()
     233                 :            : {
     234                 :            :     SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
     235         [ +  - ]:         78 :         &static_cast<SwModify&>(*this) ); // cast to base class!
     236 [ +  - ][ +  - ]:         78 :     NotifyClients(&aMsgHint, &aMsgHint);
     237                 :         78 : }
     238                 :            : 
     239                 :          2 : String SwTOXMark::GetText() const
     240                 :            : {
     241                 :          2 :     String aStr;
     242         [ -  + ]:          2 :     if( aAltText.Len() )
     243         [ #  # ]:          0 :         aStr = aAltText;
     244 [ +  - ][ +  - ]:          2 :     else if( pTxtAttr && pTxtAttr->GetpTxtNd() )
                 [ +  - ]
     245                 :            :     {
     246         [ +  - ]:          2 :         xub_StrLen* pEndIdx = pTxtAttr->GetEnd();
     247                 :            :         OSL_ENSURE( pEndIdx, "TOXMark without mark!");
     248         [ +  - ]:          2 :         if( pEndIdx )
     249                 :            :         {
     250                 :          2 :             const xub_StrLen nStt = *pTxtAttr->GetStart();
     251 [ +  - ][ +  - ]:          2 :             aStr = pTxtAttr->GetpTxtNd()->GetExpandTxt( nStt, *pEndIdx-nStt );
                 [ +  - ]
     252                 :            :         }
     253                 :            :     }
     254                 :          2 :     return aStr;
     255                 :            : }
     256                 :            : 
     257                 :          4 : void SwTOXMark::InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType )
     258                 :            : {
     259         [ +  - ]:          4 :     SwIterator<SwTOXMark,SwTOXType> aIter(rType);
     260         [ +  - ]:          4 :     SwTOXMark* pMark = aIter.First();
     261         [ -  + ]:          4 :     while( pMark )
     262                 :            :     {
     263         [ #  # ]:          0 :         if(pMark->GetTxtTOXMark())
     264         [ #  # ]:          0 :             aMarks.push_back(pMark);
     265         [ #  # ]:          0 :         pMark = aIter.Next();
     266         [ +  - ]:          4 :     }
     267                 :          4 : }
     268                 :            : 
     269                 :            : /*--------------------------------------------------------------------
     270                 :            :   Manage types of TOX
     271                 :            :  --------------------------------------------------------------------*/
     272                 :            : 
     273                 :      11165 : SwTOXType::SwTOXType( TOXTypes eTyp, const String& rName )
     274                 :            :     : SwModify(0),
     275                 :            :     aName(rName),
     276         [ +  - ]:      11165 :     eType(eTyp)
     277                 :            : {
     278                 :      11165 : }
     279                 :            : 
     280                 :            : 
     281                 :          0 : SwTOXType::SwTOXType(const SwTOXType& rCopy)
     282                 :          0 :     : SwModify( (SwModify*)rCopy.GetRegisteredIn() ),
     283                 :            :     aName(rCopy.aName),
     284         [ #  # ]:          0 :     eType(rCopy.eType)
     285                 :            : {
     286                 :          0 : }
     287                 :            : 
     288                 :            : /*--------------------------------------------------------------------
     289                 :            :     Edit forms
     290                 :            :   --------------------------------------------------------------------*/
     291                 :            : 
     292                 :         86 : SwForm::SwForm( TOXTypes eTyp ) // #i21237#
     293         [ +  - ]:         86 :     : eType( eTyp ), nFormMaxLevel( SwForm::GetFormMaxLevel( eTyp )),
     294                 :            : //  nFirstTabPos( lNumIndent ),
     295 [ +  - ][ +  + ]:       4042 :     bCommaSeparated(sal_False)
         [ +  - ][ +  +  
          #  #  #  #  #  
                #  #  # ]
     296                 :            : {
     297                 :            :     //bHasFirstTabPos =
     298                 :         86 :     bGenerateTabPos = sal_False;
     299                 :         86 :     bIsRelTabPos = sal_True;
     300                 :            : 
     301                 :            :     // The table of contents has a certain number of headlines + headings
     302                 :            :     // The user has 10 levels + headings
     303                 :            :     // Keyword has 3 levels + headings+ separator
     304                 :            :     // Indexes of tables, object illustrations and authorities consist of a heading and one level
     305                 :            : 
     306                 :            :     sal_uInt16 nPoolId;
     307   [ +  +  +  +  :         86 :     switch( eType )
             +  +  +  - ]
     308                 :            :     {
     309                 :         12 :     case TOX_INDEX:         nPoolId = STR_POOLCOLL_TOX_IDXH;    break;
     310                 :          4 :     case TOX_USER:          nPoolId = STR_POOLCOLL_TOX_USERH;   break;
     311                 :         54 :     case TOX_CONTENT:       nPoolId = STR_POOLCOLL_TOX_CNTNTH;  break;
     312                 :          4 :     case TOX_ILLUSTRATIONS: nPoolId = STR_POOLCOLL_TOX_ILLUSH;  break;
     313                 :          4 :     case TOX_OBJECTS      : nPoolId = STR_POOLCOLL_TOX_OBJECTH; break;
     314                 :          4 :     case TOX_TABLES       : nPoolId = STR_POOLCOLL_TOX_TABLESH; break;
     315                 :          4 :     case TOX_AUTHORITIES  : nPoolId = STR_POOLCOLL_TOX_AUTHORITIESH;    break;
     316                 :            :     default:
     317                 :            :         OSL_ENSURE( !this, "invalid TOXTyp");
     318                 :         86 :         return ;
     319                 :            :     }
     320                 :            : 
     321         [ +  - ]:         86 :     SwFormTokens aTokens;
     322         [ +  + ]:         86 :     if (TOX_CONTENT == eType)
     323                 :            :     {
     324         [ +  - ]:         54 :         SwFormToken aLinkStt (TOKEN_LINK_START);
     325 [ +  - ][ +  - ]:         54 :         aLinkStt.sCharStyleName = String(SW_RES(STR_POOLCHR_TOXJUMP));
                 [ +  - ]
     326         [ +  - ]:         54 :         aTokens.push_back(aLinkStt);
     327 [ +  - ][ +  - ]:         54 :         aTokens.push_back(SwFormToken(TOKEN_ENTRY_NO));
                 [ +  - ]
     328 [ +  - ][ +  - ]:         54 :         aTokens.push_back(SwFormToken(TOKEN_ENTRY_TEXT));
         [ +  - ][ +  - ]
     329                 :            :     }
     330                 :            :     else
     331 [ +  - ][ +  - ]:         32 :         aTokens.push_back(SwFormToken(TOKEN_ENTRY));
                 [ +  - ]
     332                 :            : 
     333         [ +  + ]:         86 :     if (TOX_AUTHORITIES != eType)
     334                 :            :     {
     335         [ +  - ]:         82 :         SwFormToken aToken(TOKEN_TAB_STOP);
     336                 :         82 :         aToken.nTabStopPosition = 0;
     337                 :            : 
     338                 :            :         // #i36870# right aligned tab for all
     339                 :         82 :         aToken.cTabFillChar = '.';
     340                 :         82 :         aToken.eTabAlign = SVX_TAB_ADJUST_END;
     341                 :            : 
     342         [ +  - ]:         82 :         aTokens.push_back(aToken);
     343 [ +  - ][ +  - ]:         82 :         aTokens.push_back(SwFormToken(TOKEN_PAGE_NUMS));
         [ +  - ][ +  - ]
     344                 :            :     }
     345                 :            : 
     346         [ +  + ]:         86 :     if (TOX_CONTENT == eType)
     347 [ +  - ][ +  - ]:         54 :         aTokens.push_back(SwFormToken(TOKEN_LINK_END));
                 [ +  - ]
     348                 :            : 
     349 [ +  - ][ +  - ]:         86 :     SetTemplate( 0, SW_RESSTR( nPoolId++ ));
         [ +  - ][ +  - ]
     350                 :            : 
     351         [ +  + ]:         86 :     if(TOX_INDEX == eType)
     352                 :            :     {
     353         [ +  + ]:         60 :         for( sal_uInt16 i = 1; i < 5; ++i  )
     354                 :            :         {
     355         [ +  + ]:         48 :             if(1 == i)
     356                 :            :             {
     357         [ +  - ]:         12 :                 SwFormTokens aTmpTokens;
     358         [ +  - ]:         12 :                 SwFormToken aTmpToken(TOKEN_ENTRY);
     359         [ +  - ]:         12 :                 aTmpTokens.push_back(aTmpToken);
     360                 :            : 
     361         [ +  - ]:         12 :                 SetPattern( i, aTmpTokens );
     362 [ +  - ][ +  - ]:         12 :                 SetTemplate( i, SW_RESSTR( STR_POOLCOLL_TOX_IDXBREAK    ));
         [ +  - ][ +  - ]
                 [ +  - ]
     363                 :            :             }
     364                 :            :             else
     365                 :            :             {
     366         [ +  - ]:         36 :                 SetPattern( i, aTokens );
     367 [ +  - ][ +  - ]:         36 :                 SetTemplate( i, SW_RESSTR( STR_POOLCOLL_TOX_IDX1 + i - 2 ));
         [ +  - ][ +  - ]
     368                 :            :             }
     369                 :            :         }
     370                 :            :     }
     371                 :            :     else
     372         [ +  + ]:        754 :         for( sal_uInt16 i = 1; i < GetFormMax(); ++i, ++nPoolId )    // Number 0 is the title
     373                 :            :         {
     374         [ +  + ]:        680 :             if(TOX_AUTHORITIES == eType)
     375 [ +  - ][ +  - ]:         88 :                 SetPattern(i, lcl_GetAuthPattern(i));
     376                 :            :             else
     377         [ +  - ]:        592 :                 SetPattern( i, aTokens );
     378                 :            : 
     379 [ +  + ][ +  + ]:        680 :             if( TOX_CONTENT == eType && 6 == i )
     380                 :         54 :                 nPoolId = STR_POOLCOLL_TOX_CNTNT6;
     381 [ +  + ][ +  + ]:        626 :             else if( TOX_USER == eType && 6 == i )
     382                 :          4 :                 nPoolId = STR_POOLCOLL_TOX_USER6;
     383         [ +  + ]:        622 :             else if( TOX_AUTHORITIES == eType )
     384                 :         88 :                 nPoolId = STR_POOLCOLL_TOX_AUTHORITIES1;
     385 [ +  - ][ +  - ]:        680 :             SetTemplate( i, SW_RESSTR( nPoolId ) );
         [ +  - ][ +  - ]
     386                 :         86 :         }
     387   [ #  #  #  #  :          0 : }
             #  #  #  # ]
     388                 :            : 
     389                 :            : 
     390                 :        654 : SwForm::SwForm(const SwForm& rForm)
     391 [ +  - ][ +  + ]:      30738 :     : eType( rForm.eType )
         [ +  - ][ +  +  
          #  #  #  #  #  
                #  #  # ]
     392                 :            : {
     393         [ +  - ]:        654 :     *this = rForm;
     394   [ #  #  #  #  :        654 : }
             #  #  #  # ]
     395                 :            : 
     396                 :            : 
     397                 :        966 : SwForm& SwForm::operator=(const SwForm& rForm)
     398                 :            : {
     399                 :        966 :     eType = rForm.eType;
     400                 :        966 :     nFormMaxLevel = rForm.nFormMaxLevel;
     401                 :            : //  nFirstTabPos = rForm.nFirstTabPos;
     402                 :            : //  bHasFirstTabPos = rForm.bHasFirstTabPos;
     403                 :        966 :     bGenerateTabPos = rForm.bGenerateTabPos;
     404                 :        966 :     bIsRelTabPos = rForm.bIsRelTabPos;
     405                 :        966 :     bCommaSeparated = rForm.bCommaSeparated;
     406         [ +  + ]:      10944 :     for(sal_uInt16 i=0; i < nFormMaxLevel; ++i)
     407                 :            :     {
     408                 :       9978 :         aPattern[i] = rForm.aPattern[i];
     409                 :       9978 :         aTemplate[i] = rForm.aTemplate[i];
     410                 :            :     }
     411                 :        966 :     return *this;
     412                 :            : }
     413                 :            : 
     414                 :         86 : sal_uInt16 SwForm::GetFormMaxLevel( TOXTypes eTOXType )
     415                 :            : {
     416                 :         86 :     sal_uInt16 nRet = 0;
     417   [ +  +  +  +  :         86 :     switch( eTOXType )
                   +  - ]
     418                 :            :     {
     419                 :         12 :         case TOX_INDEX:         nRet = 5;                   break;
     420                 :          4 :         case TOX_USER:          nRet = MAXLEVEL+1;          break;
     421                 :         54 :         case TOX_CONTENT:       nRet = MAXLEVEL+1;          break;
     422                 :            :         case TOX_ILLUSTRATIONS:
     423                 :            :         case TOX_OBJECTS      :
     424                 :         12 :         case TOX_TABLES       : nRet = 2; break;
     425                 :          4 :         case TOX_AUTHORITIES  : nRet = AUTH_TYPE_END + 1;       break;
     426                 :            :     }
     427                 :         86 :     return nRet;
     428                 :            : }
     429                 :            : 
     430                 :            : // #i21237#
     431                 :          0 : bool operator == (const SwFormToken & rToken, FormTokenType eType)
     432                 :            : {
     433                 :          0 :     return rToken.eTokenType == eType;
     434                 :            : }
     435                 :            : 
     436                 :            : //-----------------------------------------------------------------------------
     437                 :          0 : void SwForm::AdjustTabStops(SwDoc& rDoc, sal_Bool bInsertNewTapStops) // #i21237#
     438                 :            : {
     439         [ #  # ]:          0 :     for(sal_uInt16 nLevel = 1; nLevel < GetFormMax(); nLevel++)
     440                 :            :     {
     441                 :          0 :         const String& sTemplateName = GetTemplate(nLevel);
     442                 :            : 
     443                 :          0 :         SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( sTemplateName );
     444         [ #  # ]:          0 :         if( !pColl )
     445                 :            :         {
     446                 :            :             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName
     447                 :          0 :                 ( sTemplateName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); // #i21237#
     448         [ #  # ]:          0 :             if( USHRT_MAX != nId )
     449                 :          0 :                 pColl = rDoc.GetTxtCollFromPool( nId );
     450                 :            :         }
     451                 :            : 
     452                 :          0 :         const SvxTabStopItem* pTabStops = 0;
     453                 :          0 :         sal_uInt16 nTabCount = 0;
     454 [ #  # ][ #  # ]:          0 :         if( pColl &&
         [ #  # ][ #  # ]
     455                 :          0 :             0 != ( pTabStops = &pColl->GetTabStops(sal_False) ) &&
     456                 :            :             0 != ( nTabCount = pTabStops->Count() ) )
     457                 :            :         {
     458                 :            :             // #i21237#
     459 [ #  # ][ #  # ]:          0 :             SwFormTokens aCurrentPattern = GetPattern(nLevel);
     460                 :          0 :             SwFormTokens::iterator aIt = aCurrentPattern.begin();
     461                 :            : 
     462                 :          0 :             sal_Bool bChanged = sal_False;
     463                 :            : 
     464         [ #  # ]:          0 :             for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab)
     465                 :            :             {
     466         [ #  # ]:          0 :                 const SvxTabStop& rTab = (*pTabStops)[nTab];
     467                 :            : 
     468                 :            :                 // #i29178#
     469                 :            :                 // For Word import, we do not want to replace existing tokens,
     470                 :            :                 // we insert new tabstop tokens without a tabstop character:
     471         [ #  # ]:          0 :                 if ( bInsertNewTapStops )
     472                 :            :                 {
     473         [ #  # ]:          0 :                     if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() )
     474                 :            :                     {
     475                 :          0 :                         bChanged = sal_True;
     476         [ #  # ]:          0 :                         SwFormToken aToken(TOKEN_TAB_STOP);
     477                 :          0 :                         aToken.bWithTab = sal_False;
     478                 :          0 :                         aToken.nTabStopPosition = rTab.GetTabPos();
     479                 :          0 :                         aToken.eTabAlign = rTab.GetAdjustment();
     480                 :          0 :                         aToken.cTabFillChar = rTab.GetFill();
     481 [ #  # ][ #  # ]:          0 :                         aCurrentPattern.push_back(aToken);
     482                 :            :                     }
     483                 :            :                 }
     484                 :            :                 else
     485                 :            :                 {
     486                 :            :                     aIt = find_if(aIt, aCurrentPattern.end(),
     487                 :            :                                   SwFormTokenEqualToFormTokenType
     488         [ #  # ]:          0 :                                   (TOKEN_TAB_STOP));
     489 [ #  # ][ #  # ]:          0 :                     if ( aIt != aCurrentPattern.end() )
     490                 :            :                     {
     491                 :          0 :                         bChanged = sal_True;
     492         [ #  # ]:          0 :                         aIt->nTabStopPosition = rTab.GetTabPos();
     493         [ #  # ]:          0 :                         aIt->eTabAlign = nTab == nTabCount - 1 &&
     494                 :          0 :                                          SVX_TAB_ADJUST_RIGHT == rTab.GetAdjustment() ?
     495                 :            :                                          SVX_TAB_ADJUST_END :
     496   [ #  #  #  # ]:          0 :                                          rTab.GetAdjustment();
     497         [ #  # ]:          0 :                         aIt->cTabFillChar = rTab.GetFill();
     498         [ #  # ]:          0 :                         ++aIt;
     499                 :            :                     }
     500                 :            :                     else
     501                 :          0 :                         break; // no more tokens to replace
     502                 :            :                 }
     503                 :            :             }
     504                 :            : 
     505         [ #  # ]:          0 :             if(bChanged)
     506         [ #  # ]:          0 :                 SetPattern(nLevel, aCurrentPattern); // #i21237#
     507                 :            :         }
     508                 :            :     }
     509                 :          0 : }
     510                 :            : /*--------------------------------------------------------------------
     511                 :            :   Ctor TOXBase
     512                 :            :  --------------------------------------------------------------------*/
     513                 :            : 
     514                 :            : 
     515                 :         38 : SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm,
     516                 :            :                      sal_uInt16 nCreaType, const String& rTitle )
     517                 :            :     : SwClient((SwModify*)pTyp),
     518                 :            :     aForm(rForm),
     519                 :            :     aTitle(rTitle),
     520         [ +  - ]:         38 :     eLanguage((LanguageType)::GetAppLanguage()),
     521                 :            :     nCreateType(nCreaType),
     522                 :            :     nOLEOptions(0),
     523                 :            :     eCaptionDisplay(CAPTION_COMPLETE),
     524                 :            :     bProtected( sal_True ),
     525                 :            :     bFromChapter(sal_False),
     526                 :            :     bFromObjectNames(sal_False),
     527 [ +  - ][ +  - ]:        456 :     bLevelFromChapter(sal_False)
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  -  
             #  #  #  # ]
     528                 :            : {
     529                 :         38 :     aData.nOptions = 0;
     530   [ #  #  #  # ]:         38 : }
     531                 :            : 
     532                 :            : 
     533                 :         48 : SwTOXBase::SwTOXBase( const SwTOXBase& rSource, SwDoc* pDoc )
     534 [ +  - ][ +  - ]:        528 :     : SwClient( rSource.GetRegisteredInNonConst() )
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  -  
             #  #  #  # ]
     535                 :            : {
     536         [ +  - ]:         48 :     CopyTOXBase( pDoc, rSource );
     537   [ #  #  #  # ]:         48 : }
     538                 :            : 
     539                 :          0 : void SwTOXBase::RegisterToTOXType( SwTOXType& rType )
     540                 :            : {
     541                 :          0 :     rType.Add( this );
     542                 :          0 : }
     543                 :            : 
     544                 :         48 : SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource )
     545                 :            : {
     546                 :         48 :     SwTOXType* pType = (SwTOXType*)rSource.GetTOXType();
     547 [ #  # ][ -  + ]:         48 :     if( pDoc && USHRT_MAX == pDoc->GetTOXTypes().GetPos( pType ))
                 [ -  + ]
     548                 :            :     {
     549                 :            :         // type not in pDoc, so create it now
     550                 :          0 :         const SwTOXTypes& rTypes = pDoc->GetTOXTypes();
     551                 :          0 :         sal_Bool bFound = sal_False;
     552         [ #  # ]:          0 :         for( sal_uInt16 n = rTypes.size(); n; )
     553                 :            :         {
     554                 :          0 :             const SwTOXType* pCmp = rTypes[ --n ];
     555         [ #  # ]:          0 :             if( pCmp->GetType() == pType->GetType() &&
           [ #  #  #  # ]
     556                 :          0 :                 pCmp->GetTypeName() == pType->GetTypeName() )
     557                 :            :             {
     558                 :          0 :                 pType = (SwTOXType*)pCmp;
     559                 :          0 :                 bFound = sal_True;
     560                 :          0 :                 break;
     561                 :            :             }
     562                 :            :         }
     563                 :            : 
     564         [ #  # ]:          0 :         if( !bFound )
     565                 :          0 :             pType = (SwTOXType*)pDoc->InsertTOXType( *pType );
     566                 :            :     }
     567                 :         48 :     pType->Add( this );
     568                 :            : 
     569                 :         48 :     nCreateType = rSource.nCreateType;
     570                 :         48 :     aTitle      = rSource.aTitle;
     571                 :         48 :     aForm       = rSource.aForm;
     572                 :         48 :     bProtected  = rSource.bProtected;
     573                 :         48 :     bFromChapter = rSource.bFromChapter;
     574                 :         48 :     bFromObjectNames = rSource.bFromObjectNames;
     575                 :         48 :     sMainEntryCharStyle = rSource.sMainEntryCharStyle;
     576                 :         48 :     sSequenceName = rSource.sSequenceName;
     577                 :         48 :     eCaptionDisplay = rSource.eCaptionDisplay;
     578                 :         48 :     nOLEOptions = rSource.nOLEOptions;
     579                 :         48 :     eLanguage = rSource.eLanguage;
     580                 :         48 :     sSortAlgorithm = rSource.sSortAlgorithm;
     581                 :         48 :     bLevelFromChapter = rSource.bLevelFromChapter;
     582                 :            : 
     583         [ +  + ]:        528 :     for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
     584                 :        480 :         aStyleNames[i] = rSource.aStyleNames[i];
     585                 :            : 
     586                 :            :     // its the same data type!
     587                 :         48 :     aData.nOptions =  rSource.aData.nOptions;
     588                 :            : 
     589 [ -  + ][ #  # ]:         48 :     if( !pDoc || pDoc->IsCopyIsMove() )
                 [ +  - ]
     590                 :         48 :         aName = rSource.GetTOXName();
     591                 :            :     else
     592         [ #  # ]:          0 :         aName = pDoc->GetUniqueTOXBaseName( *pType, &rSource.GetTOXName() );
     593                 :            : 
     594                 :         48 :     return *this;
     595                 :            : }
     596                 :            : 
     597                 :            : /*--------------------------------------------------------------------
     598                 :            :   TOX specific functions
     599                 :            :  --------------------------------------------------------------------*/
     600                 :            : 
     601 [ +  - ][ +  - ]:       1032 : SwTOXBase::~SwTOXBase()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     602                 :            : {
     603                 :            : //    if( GetTOXType()->GetType() == TOX_USER  )
     604                 :            : //        delete aData.pTemplateName;
     605 [ +  - ][ +  + ]:       1080 : }
                 [ -  + ]
           [ #  #  #  # ]
     606                 :            : 
     607                 :         30 : void SwTOXBase::SetTitle(const String& rTitle)
     608                 :         30 :     {   aTitle = rTitle; }
     609                 :            : 
     610                 :            : 
     611                 :          0 : SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
     612                 :            : {
     613                 :          0 :     aForm = rSource.aForm;
     614                 :          0 :     aName = rSource.aName;
     615                 :          0 :     aTitle = rSource.aTitle;
     616                 :          0 :     sMainEntryCharStyle = rSource.sMainEntryCharStyle;
     617         [ #  # ]:          0 :     for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
     618                 :          0 :         aStyleNames[nLevel] = rSource.aStyleNames[nLevel];
     619                 :          0 :     sSequenceName = rSource.sSequenceName;
     620                 :          0 :     eLanguage = rSource.eLanguage;
     621                 :          0 :     sSortAlgorithm = rSource.sSortAlgorithm;
     622                 :          0 :     aData = rSource.aData;
     623                 :          0 :     nCreateType = rSource.nCreateType;
     624                 :          0 :     nOLEOptions = rSource.nOLEOptions;
     625                 :          0 :     eCaptionDisplay = rSource.eCaptionDisplay;
     626                 :          0 :     bProtected = rSource.bProtected;
     627                 :          0 :     bFromChapter = rSource.bFromChapter;
     628                 :          0 :     bFromObjectNames = rSource.bFromObjectNames;
     629                 :          0 :     bLevelFromChapter = rSource.bLevelFromChapter;
     630                 :            : 
     631         [ #  # ]:          0 :     if (rSource.GetAttrSet())
     632                 :          0 :         SetAttrSet(*rSource.GetAttrSet());
     633                 :            : 
     634                 :          0 :     return *this;
     635                 :            : }
     636                 :            : 
     637                 :        982 : String SwFormToken::GetString() const
     638                 :            : {
     639                 :        982 :     String sRet;
     640                 :            : 
     641                 :        982 :     sal_Bool bAppend = sal_True;
     642   [ +  +  +  +  :        982 :     switch( eTokenType )
          +  +  -  -  -  
                +  -  - ]
     643                 :            :     {
     644                 :            :         case TOKEN_ENTRY_NO:
     645         [ +  - ]:         40 :             sRet.AssignAscii( SwForm::aFormEntryNum );
     646                 :         40 :         break;
     647                 :            :         case TOKEN_ENTRY_TEXT:
     648         [ +  - ]:         40 :             sRet.AssignAscii( SwForm::aFormEntryTxt );
     649                 :         40 :         break;
     650                 :            :         case TOKEN_ENTRY:
     651         [ +  - ]:         70 :             sRet.AssignAscii( SwForm::aFormEntry );
     652                 :         70 :         break;
     653                 :            :         case TOKEN_TAB_STOP:
     654         [ +  - ]:        104 :             sRet.AssignAscii( SwForm::aFormTab );
     655                 :        104 :         break;
     656                 :            :         case TOKEN_TEXT:
     657         [ +  - ]:        268 :             sRet.AssignAscii( SwForm::aFormText );
     658                 :        268 :         break;
     659                 :            :         case TOKEN_PAGE_NUMS:
     660         [ +  - ]:        104 :             sRet.AssignAscii( SwForm::aFormPageNums );
     661                 :        104 :         break;
     662                 :            :         case TOKEN_CHAPTER_INFO:
     663         [ #  # ]:          0 :             sRet.AssignAscii( SwForm::aFormChapterMark );
     664                 :          0 :         break;
     665                 :            :         case TOKEN_LINK_START:
     666         [ #  # ]:          0 :             sRet.AssignAscii( SwForm::aFormLinkStt );
     667                 :          0 :         break;
     668                 :            :         case TOKEN_LINK_END:
     669         [ #  # ]:          0 :             sRet.AssignAscii( SwForm::aFormLinkEnd );
     670                 :          0 :         break;
     671                 :            :         case TOKEN_AUTHORITY:
     672                 :            :         {
     673         [ +  - ]:        356 :             sRet.AssignAscii( SwForm::aFormAuth );
     674         [ +  - ]:        356 :             String sTmp( String::CreateFromInt32( nAuthorityField ));
     675         [ +  + ]:        356 :             if( sTmp.Len() < 2 )
     676         [ +  - ]:        176 :                 sTmp.Insert('0', 0);
     677 [ +  - ][ +  - ]:        356 :             sRet.Insert( sTmp, 2 );
     678                 :            :         }
     679                 :        356 :         break;
     680                 :            :         case TOKEN_END:
     681                 :          0 :         break;
     682                 :            :     }
     683         [ +  - ]:        982 :     sRet.Erase( sRet.Len() - 1 );
     684         [ +  - ]:        982 :     sRet += ' ';
     685         [ +  - ]:        982 :     sRet += sCharStyleName;
     686         [ +  - ]:        982 :     sRet += ',';
     687 [ +  - ][ +  - ]:        982 :     sRet += String::CreateFromInt32( nPoolId );
                 [ +  - ]
     688         [ +  - ]:        982 :     sRet += ',';
     689                 :            : 
     690                 :            :     // TabStopPosition and TabAlign or ChapterInfoFormat
     691         [ +  + ]:        982 :     if(TOKEN_TAB_STOP == eTokenType)
     692                 :            :     {
     693 [ +  - ][ +  - ]:        104 :         sRet += String::CreateFromInt32( nTabStopPosition );
                 [ +  - ]
     694         [ +  - ]:        104 :         sRet += ',';
     695 [ +  - ][ +  - ]:        104 :         sRet += String::CreateFromInt32( static_cast< sal_Int32 >(eTabAlign) );
                 [ +  - ]
     696         [ +  - ]:        104 :         sRet += ',';
     697         [ +  - ]:        104 :         sRet += cTabFillChar;
     698         [ +  - ]:        104 :         sRet += ',';
     699 [ +  - ][ +  - ]:        104 :         sRet += String::CreateFromInt32( bWithTab );
                 [ +  - ]
     700                 :            :     }
     701         [ -  + ]:        878 :     else if(TOKEN_CHAPTER_INFO == eTokenType)
     702                 :            :     {
     703 [ #  # ][ #  # ]:          0 :         sRet += String::CreateFromInt32( nChapterFormat );
                 [ #  # ]
     704                 :            :         // add maximum permitted level
     705         [ #  # ]:          0 :         sRet += ',';
     706 [ #  # ][ #  # ]:          0 :         sRet += String::CreateFromInt32( nOutlineLevel );
                 [ #  # ]
     707                 :            :     }
     708         [ +  + ]:        878 :     else if(TOKEN_TEXT == eTokenType)
     709                 :            :     {
     710                 :            :         //append Text if Len() > 0 only!
     711         [ +  - ]:        268 :         if( sText.Len() )
     712                 :            :         {
     713         [ +  - ]:        268 :             sRet += TOX_STYLE_DELIMITER;
     714 [ +  - ][ +  - ]:        268 :             String sTmp(comphelper::string::remove(sText, TOX_STYLE_DELIMITER));
     715         [ +  - ]:        268 :             sRet += sTmp;
     716 [ +  - ][ +  - ]:        268 :             sRet += TOX_STYLE_DELIMITER;
     717                 :            :         }
     718                 :            :         else
     719                 :          0 :             bAppend = sal_False;
     720                 :            :     }
     721         [ +  + ]:        610 :     else if(TOKEN_ENTRY_NO == eTokenType)
     722                 :            :     {
     723 [ +  - ][ +  - ]:         40 :         sRet += String::CreateFromInt32( nChapterFormat );
                 [ +  - ]
     724                 :            :         // add maximum permitted level
     725         [ +  - ]:         40 :         sRet += ',';
     726 [ +  - ][ +  - ]:         40 :         sRet += String::CreateFromInt32( nOutlineLevel );
                 [ +  - ]
     727                 :            :     }
     728                 :            : 
     729         [ +  - ]:        982 :     if(bAppend)
     730                 :            :     {
     731         [ +  - ]:        982 :         sRet += '>';
     732                 :            :     }
     733                 :            :     else
     734                 :            :     {
     735                 :            :         // don't append empty text tokens
     736         [ #  # ]:          0 :         sRet.Erase();
     737                 :            :     }
     738                 :            : 
     739                 :        982 :     return sRet;
     740                 :            : }
     741                 :            : 
     742                 :            : // -> #i21237#
     743                 :        198 : SwFormTokensHelper::SwFormTokensHelper(const String & rPattern)
     744                 :            : {
     745                 :        198 :     xub_StrLen nCurPatternPos = 0;
     746                 :        198 :     xub_StrLen nCurPatternLen = 0;
     747                 :            : 
     748         [ +  + ]:       1180 :     while (nCurPatternPos < rPattern.Len())
     749                 :            :     {
     750                 :        982 :         nCurPatternPos = nCurPatternPos + nCurPatternLen;
     751                 :            : 
     752         [ +  - ]:        982 :         SwFormToken aToken = BuildToken(rPattern, nCurPatternPos);
     753         [ +  - ]:        982 :         aTokens.push_back(aToken);
     754         [ +  - ]:        982 :     }
     755                 :        198 : }
     756                 :            : 
     757                 :        982 : SwFormToken SwFormTokensHelper::BuildToken( const String & sPattern,
     758                 :            :                                            xub_StrLen & nCurPatternPos ) const
     759                 :            : {
     760         [ +  - ]:        982 :     String sToken( SearchNextToken(sPattern, nCurPatternPos) );
     761                 :        982 :     nCurPatternPos = nCurPatternPos + sToken.Len();
     762                 :            :     xub_StrLen nTokenLen;
     763         [ +  - ]:        982 :     FormTokenType eTokenType = GetTokenType(sToken, &nTokenLen);
     764                 :            : 
     765                 :            :     // at this point sPattern contains the
     766                 :            :     // character style name, the PoolId, tab stop position, tab stop alignment, chapter info format
     767                 :            :     // the form is: CharStyleName, PoolId[, TabStopPosition|ChapterInfoFormat[, TabStopAlignment[, TabFillChar]]]
     768                 :            :     // in text tokens the form differs from the others: CharStyleName, PoolId[,\0xffinserted text\0xff]
     769         [ +  - ]:        982 :     SwFormToken eRet( eTokenType );
     770         [ +  - ]:        982 :     String sAuthFieldEnum = sToken.Copy( 2, 2 );
     771 [ +  - ][ +  - ]:        982 :     sToken = sToken.Copy( nTokenLen, sToken.Len() - nTokenLen - 1);
                 [ +  - ]
     772                 :            : 
     773 [ +  - ][ +  - ]:        982 :     eRet.sCharStyleName = sToken.GetToken( 0, ',');
                 [ +  - ]
     774         [ +  - ]:        982 :     String sTmp( sToken.GetToken( 1, ',' ));
     775         [ +  - ]:        982 :     if( sTmp.Len() )
     776         [ +  - ]:        982 :         eRet.nPoolId = static_cast<sal_uInt16>(sTmp.ToInt32());
     777                 :            : 
     778   [ +  +  +  -  :        982 :     switch( eTokenType )
                   +  + ]
     779                 :            :     {
     780                 :            : //i53420
     781                 :            :     case TOKEN_ENTRY_NO:
     782 [ +  - ][ +  - ]:         40 :         if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
         [ +  - ][ +  - ]
     783         [ +  - ]:         40 :             eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32());
     784 [ +  - ][ +  - ]:         40 :         if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
         [ +  - ][ +  - ]
     785         [ +  - ]:         40 :             eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine
     786                 :         40 :         break;
     787                 :            : 
     788                 :            :     case TOKEN_TEXT:
     789                 :            :         {
     790         [ +  - ]:        268 :             xub_StrLen nStartText = sToken.Search( TOX_STYLE_DELIMITER );
     791         [ +  - ]:        268 :             if( STRING_NOTFOUND != nStartText )
     792                 :            :             {
     793                 :            :                 xub_StrLen nEndText = sToken.Search( TOX_STYLE_DELIMITER,
     794         [ +  - ]:        268 :                                                 nStartText + 1);
     795         [ +  - ]:        268 :                 if( STRING_NOTFOUND != nEndText )
     796                 :            :                 {
     797                 :            :                     eRet.sText = sToken.Copy( nStartText + 1,
     798 [ +  - ][ +  - ]:        268 :                                                 nEndText - nStartText - 1);
                 [ +  - ]
     799                 :            :                 }
     800                 :            :             }
     801                 :            :         }
     802                 :        268 :         break;
     803                 :            : 
     804                 :            :     case TOKEN_TAB_STOP:
     805 [ +  - ][ +  - ]:        104 :         if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
         [ +  - ][ +  - ]
     806         [ +  - ]:        104 :             eRet.nTabStopPosition = sTmp.ToInt32();
     807                 :            : 
     808 [ +  - ][ +  - ]:        104 :         if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
         [ +  - ][ +  - ]
     809         [ +  - ]:        104 :             eRet.eTabAlign = static_cast<SvxTabAdjust>(sTmp.ToInt32());
     810                 :            : 
     811 [ +  - ][ +  - ]:        104 :         if( (sTmp = sToken.GetToken( 4, ',' ) ).Len() )
         [ +  - ][ +  - ]
     812                 :        104 :             eRet.cTabFillChar = sTmp.GetChar(0);
     813                 :            : 
     814 [ +  - ][ +  - ]:        104 :         if( (sTmp = sToken.GetToken( 5, ',' ) ).Len() )
         [ +  - ][ +  - ]
     815         [ +  - ]:        104 :             eRet.bWithTab = 0 != sTmp.ToInt32();
     816                 :        104 :         break;
     817                 :            : 
     818                 :            :     case TOKEN_CHAPTER_INFO:
     819 [ #  # ][ #  # ]:          0 :         if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
         [ #  # ][ #  # ]
     820         [ #  # ]:          0 :             eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32()); //SwChapterFormat;
     821                 :            :  //i53420
     822 [ #  # ][ #  # ]:          0 :         if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
         [ #  # ][ #  # ]
     823         [ #  # ]:          0 :             eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine
     824                 :            : 
     825                 :          0 :         break;
     826                 :            : 
     827                 :            :     case TOKEN_AUTHORITY:
     828         [ +  - ]:        356 :         eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.ToInt32());
     829                 :        356 :         break;
     830                 :        214 :     default: break;
     831                 :            :     }
     832 [ +  - ][ +  - ]:        982 :     return eRet;
                 [ +  - ]
     833                 :            : }
     834                 :            : 
     835                 :        982 : String SwFormTokensHelper::SearchNextToken( const String & sPattern,
     836                 :            :                                             xub_StrLen nStt ) const
     837                 :            : {
     838                 :            :     //it's not so easy - it doesn't work if the text part contains a '>'
     839                 :            :     //sal_uInt16 nTokenEnd = sPattern.Search('>');
     840                 :            : 
     841                 :        982 :     String aResult;
     842                 :            : 
     843         [ +  - ]:        982 :     xub_StrLen nEnd = sPattern.Search( '>', nStt );
     844         [ -  + ]:        982 :     if( STRING_NOTFOUND == nEnd )
     845                 :            :     {
     846                 :          0 :         nEnd = sPattern.Len();
     847                 :            :     }
     848                 :            :     else
     849                 :            :     {
     850         [ +  - ]:        982 :         xub_StrLen nTextSeparatorFirst = sPattern.Search( TOX_STYLE_DELIMITER, nStt );
     851         [ +  + ]:        982 :         if( STRING_NOTFOUND != nTextSeparatorFirst )
     852                 :            :         {
     853                 :            :             xub_StrLen nTextSeparatorSecond = sPattern.Search( TOX_STYLE_DELIMITER,
     854         [ +  - ]:        536 :                                                                nTextSeparatorFirst + 1 );
     855 [ +  - ][ +  + ]:        536 :             if( STRING_NOTFOUND != nTextSeparatorSecond &&
     856                 :            :                 nEnd > nTextSeparatorFirst )
     857         [ +  - ]:        268 :                 nEnd = sPattern.Search( '>', nTextSeparatorSecond );
     858                 :            :         }
     859                 :            : 
     860                 :        982 :         ++nEnd;
     861                 :            : 
     862 [ +  - ][ +  - ]:        982 :         aResult = sPattern.Copy( nStt, nEnd - nStt );
                 [ +  - ]
     863                 :            :     }
     864                 :            : 
     865                 :        982 :     return aResult;
     866                 :            : }
     867                 :            : 
     868                 :        982 : FormTokenType SwFormTokensHelper::GetTokenType(const String & sToken,
     869                 :            :                                                xub_StrLen * pTokenLen) const
     870                 :            : {
     871                 :            :     static struct
     872                 :            :     {
     873                 :            :         const sal_Char* pNm;
     874                 :            :         sal_uInt16 nLen;
     875                 :            :         sal_uInt16 nOffset;
     876                 :            :         FormTokenType eToken;
     877                 :            :     } const aTokenArr[] = {
     878                 :            :         { SwForm::aFormTab,       SwForm::nFormEntryLen,      1, TOKEN_TAB_STOP },
     879                 :            :         { SwForm::aFormPageNums,  SwForm::nFormPageNumsLen,   1, TOKEN_PAGE_NUMS },
     880                 :            :         { SwForm::aFormLinkStt,   SwForm::nFormLinkSttLen,    1, TOKEN_LINK_START },
     881                 :            :         { SwForm::aFormLinkEnd,   SwForm::nFormLinkEndLen,    1, TOKEN_LINK_END },
     882                 :            :         { SwForm::aFormEntryNum,  SwForm::nFormEntryNumLen,   1, TOKEN_ENTRY_NO },
     883                 :            :         { SwForm::aFormEntryTxt,  SwForm::nFormEntryTxtLen,   1, TOKEN_ENTRY_TEXT },
     884                 :            :         { SwForm::aFormChapterMark,SwForm::nFormChapterMarkLen,1,TOKEN_CHAPTER_INFO },
     885                 :            :         { SwForm::aFormText,      SwForm::nFormTextLen,       1, TOKEN_TEXT },
     886                 :            :         { SwForm::aFormEntry,     SwForm::nFormEntryLen,      1, TOKEN_ENTRY },
     887                 :            :         { SwForm::aFormAuth,      SwForm::nFormAuthLen,       3, TOKEN_AUTHORITY },
     888                 :            :         { 0,                      0,                          0, TOKEN_END }
     889 [ +  + ][ +  - ]:        982 :     };
     890                 :            : 
     891                 :        982 :     FormTokenType eTokenType = TOKEN_TEXT;
     892                 :        982 :     xub_StrLen nTokenLen = 0;
     893                 :            :     const sal_Char* pNm;
     894         [ +  - ]:       7086 :     for( int i = 0; 0 != ( pNm = aTokenArr[ i ].pNm ); ++i )
     895         [ +  + ]:       7086 :         if( COMPARE_EQUAL == sToken.CompareToAscii( pNm,
     896                 :       7086 :                             aTokenArr[ i ].nLen - aTokenArr[ i ].nOffset ))
     897                 :            :         {
     898                 :        982 :             eTokenType = aTokenArr[ i ].eToken;
     899                 :        982 :             nTokenLen = aTokenArr[ i ].nLen;
     900                 :        982 :             break;
     901                 :            :         }
     902                 :            : 
     903                 :            :     OSL_ENSURE( pNm, "wrong token" );
     904         [ +  - ]:        982 :     if (pTokenLen)
     905                 :        982 :         *pTokenLen = nTokenLen;
     906                 :            : 
     907                 :        982 :     return eTokenType;
     908                 :            : }
     909                 :            : 
     910                 :            : // <- #i21237#
     911                 :            : 
     912                 :        728 : void SwForm::SetPattern(sal_uInt16 nLevel, const SwFormTokens& rTokens)
     913                 :            : {
     914                 :            :     OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
     915                 :        728 :     aPattern[nLevel] = rTokens;
     916                 :        728 : }
     917                 :            : 
     918                 :        198 : void SwForm::SetPattern(sal_uInt16 nLevel, const String & rStr)
     919                 :            : {
     920                 :            :     OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
     921                 :            : 
     922         [ +  - ]:        198 :     SwFormTokensHelper aHelper(rStr);
     923         [ +  - ]:        198 :     aPattern[nLevel] = aHelper.GetTokens();
     924                 :        198 : }
     925                 :            : 
     926                 :        124 : const SwFormTokens& SwForm::GetPattern(sal_uInt16 nLevel) const
     927                 :            : {
     928                 :            :     OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
     929                 :        124 :     return aPattern[nLevel];
     930                 :            : }
     931                 :            : 
     932                 :          0 : sal_uInt16 SwTOXTypes::GetPos(const SwTOXType* pTOXType) const
     933                 :            : {
     934         [ #  # ]:          0 :     const_iterator it = std::find(begin(), end(), pTOXType);
     935 [ #  # ][ #  # ]:          0 :     return it == end() ? USHRT_MAX : it - begin();
         [ #  # ][ #  # ]
                 [ #  # ]
     936                 :            : }
     937                 :            : 
     938                 :       1458 : SwTOXTypes::~SwTOXTypes()
     939                 :            : {
     940 [ +  - ][ +  - ]:       1458 :     for(const_iterator it = begin(); it != end(); ++it)
                 [ -  + ]
     941 [ #  # ][ #  # ]:          0 :         delete *it;
     942                 :       1458 : }
     943                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10