LCOV - code coverage report
Current view: top level - sw/source/filter/html - htmlnum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 418 2.6 %
Date: 2012-08-25 Functions: 2 10 20.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 687 0.3 %

           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                 :            : #include <com/sun/star/style/NumberingType.hpp>
      30                 :            : #include <hintids.hxx>
      31                 :            : #include <svtools/htmltokn.h>
      32                 :            : #include <svtools/htmlkywd.hxx>
      33                 :            : #include <svtools/htmlout.hxx>
      34                 :            : #include <svl/urihelper.hxx>
      35                 :            : #include <editeng/brshitem.hxx>
      36                 :            : #include <editeng/lrspitem.hxx>
      37                 :            : #include <vcl/svapp.hxx>
      38                 :            : #include <vcl/wrkwin.hxx>
      39                 :            : #include <numrule.hxx>
      40                 :            : #include <doc.hxx>
      41                 :            : #include <docary.hxx>
      42                 :            : #include <poolfmt.hxx>
      43                 :            : #include <ndtxt.hxx>
      44                 :            : #include <paratr.hxx>
      45                 :            : 
      46                 :            : #include "htmlnum.hxx"
      47                 :            : #include "swcss1.hxx"
      48                 :            : #include "swhtml.hxx"
      49                 :            : #include "wrthtml.hxx"
      50                 :            : 
      51                 :            : #include <SwNodeNum.hxx>
      52                 :            : #include <rtl/strbuf.hxx>
      53                 :            : 
      54                 :            : using namespace ::com::sun::star;
      55                 :            : 
      56                 :            : // TODO: Unicode: Are these characters the correct ones?
      57                 :            : #define HTML_BULLETCHAR_DISC    (0xe008)
      58                 :            : #define HTML_BULLETCHAR_CIRCLE  (0xe009)
      59                 :            : #define HTML_BULLETCHAR_SQUARE  (0xe00b)
      60                 :            : 
      61                 :            : 
      62                 :            : // <UL TYPE=...>
      63                 :            : static HTMLOptionEnum aHTMLULTypeTable[] =
      64                 :            : {
      65                 :            :     { OOO_STRING_SVTOOLS_HTML_ULTYPE_disc,  HTML_BULLETCHAR_DISC        },
      66                 :            :     { OOO_STRING_SVTOOLS_HTML_ULTYPE_circle,    HTML_BULLETCHAR_CIRCLE      },
      67                 :            :     { OOO_STRING_SVTOOLS_HTML_ULTYPE_square,    HTML_BULLETCHAR_SQUARE      },
      68                 :            :     { 0,                    0                           }
      69                 :            : };
      70                 :            : 
      71                 :            : 
      72                 :          2 : void SwHTMLNumRuleInfo::Set( const SwTxtNode& rTxtNd )
      73                 :            : {
      74                 :          2 :     const SwNumRule* pTxtNdNumRule( rTxtNd.GetNumRule() );
      75         [ -  + ]:          2 :     if ( pTxtNdNumRule &&
           [ -  +  #  # ]
      76                 :          0 :          pTxtNdNumRule != rTxtNd.GetDoc()->GetOutlineNumRule() )
      77                 :            :     {
      78                 :          0 :         pNumRule = const_cast<SwNumRule*>(pTxtNdNumRule);
      79         [ #  # ]:          0 :         nDeep = static_cast< sal_uInt16 >(pNumRule ? rTxtNd.GetActualListLevel() + 1 : 0);
      80                 :          0 :         bNumbered = rTxtNd.IsCountedInList();
      81                 :            :         // #i57919# - correction of refactoring done by cws swnumtree:
      82                 :            :         // <bRestart> has to be set to <true>, if numbering is restarted at this
      83                 :            :         // text node and the start value equals <USHRT_MAX>.
      84                 :            :         // Start value <USHRT_MAX> indicates, that at this text node the numbering
      85                 :            :         // is restarted with the value given at the corresponding level.
      86 [ #  # ][ #  # ]:          0 :         bRestart = rTxtNd.IsListRestart() && !rTxtNd.HasAttrListRestartValue();
      87                 :            :     }
      88                 :            :     else
      89                 :            :     {
      90                 :          2 :         pNumRule = 0;
      91                 :          2 :         nDeep = 0;
      92                 :          2 :         bNumbered = bRestart = sal_False;
      93                 :            :     }
      94                 :          2 : }
      95                 :            : 
      96                 :            : 
      97                 :          0 : void SwHTMLParser::NewNumBulList( int nToken )
      98                 :            : {
      99                 :          0 :     SwHTMLNumRuleInfo& rInfo = GetNumInfo();
     100                 :            : 
     101                 :            :     // Erstmal einen neuen Absatz aufmachen
     102                 :          0 :     sal_Bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 0;
     103         [ #  # ]:          0 :     if( pPam->GetPoint()->nContent.GetIndex() )
     104 [ #  # ][ #  # ]:          0 :         AppendTxtNode( bSpace ? AM_SPACE : AM_NOSPACE, sal_False );
     105         [ #  # ]:          0 :     else if( bSpace )
     106         [ #  # ]:          0 :         AddParSpace();
     107                 :            : 
     108                 :            :     // Die Numerierung-Ebene erhoehen
     109                 :          0 :     rInfo.IncDepth();
     110                 :          0 :     sal_uInt8 nLevel = (sal_uInt8)( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
     111         [ #  # ]:          0 :                                                         : MAXLEVEL) - 1 );
     112                 :            : 
     113                 :            :     // ggf. ein Regelwerk anlegen
     114         [ #  # ]:          0 :     if( !rInfo.GetNumRule() )
     115                 :            :     {
     116 [ #  # ][ #  # ]:          0 :         sal_uInt16 nPos = pDoc->MakeNumRule( pDoc->GetUniqueNumRuleName() );
                 [ #  # ]
     117         [ #  # ]:          0 :         rInfo.SetNumRule( pDoc->GetNumRuleTbl()[nPos] );
     118                 :            :     }
     119                 :            : 
     120                 :            :     // das Format anpassen, falls es fuer den Level noch nicht
     121                 :            :     // geschehen ist!
     122         [ #  # ]:          0 :     sal_Bool bNewNumFmt = rInfo.GetNumRule()->GetNumFmt( nLevel ) == 0;
     123                 :          0 :     sal_Bool bChangeNumFmt = sal_False;
     124                 :            : 
     125                 :            :     // das default Numerierungsformat erstellen
     126 [ #  # ][ #  # ]:          0 :     SwNumFmt aNumFmt( rInfo.GetNumRule()->Get(nLevel) );
     127                 :          0 :     rInfo.SetNodeStartValue( nLevel );
     128         [ #  # ]:          0 :     if( bNewNumFmt )
     129                 :            :     {
     130                 :          0 :         sal_uInt16 nChrFmtPoolId = 0;
     131         [ #  # ]:          0 :         if( HTML_ORDERLIST_ON == nToken )
     132                 :            :         {
     133                 :          0 :             aNumFmt.SetNumberingType(SVX_NUM_ARABIC);
     134                 :          0 :             nChrFmtPoolId = RES_POOLCHR_NUM_LEVEL;
     135                 :            :         }
     136                 :            :         else
     137                 :            :         {
     138                 :            :             // Wir setzen hier eine Zeichenvorlage, weil die UI das auch
     139                 :            :             // so macht. Dadurch wurd immer auch eine 9pt-Schrift
     140                 :            :             // eingestellt, was in Netscape nicht der Fall ist. Bisher hat
     141                 :            :             // das noch niemanden gestoert.
     142                 :            :             // #i63395# - Only apply user defined default bullet font
     143 [ #  # ][ #  # ]:          0 :             if ( numfunc::IsDefBulletFontUserDefined() )
     144                 :            :             {
     145 [ #  # ][ #  # ]:          0 :                 aNumFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
     146                 :            :             }
     147                 :          0 :             aNumFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
     148                 :          0 :             aNumFmt.SetBulletChar( cBulletChar );       // das Bulletzeichen !!
     149                 :          0 :             nChrFmtPoolId = RES_POOLCHR_BUL_LEVEL;
     150                 :            :         }
     151                 :            : 
     152                 :          0 :         sal_uInt16 nAbsLSpace = HTML_NUMBUL_MARGINLEFT;
     153                 :            : 
     154                 :          0 :         short nFirstLineIndent  = HTML_NUMBUL_INDENT;
     155         [ #  # ]:          0 :         if( nLevel > 0 )
     156                 :            :         {
     157         [ #  # ]:          0 :             const SwNumFmt& rPrevNumFmt = rInfo.GetNumRule()->Get( nLevel-1 );
     158         [ #  # ]:          0 :             nAbsLSpace = nAbsLSpace + rPrevNumFmt.GetAbsLSpace();
     159         [ #  # ]:          0 :             nFirstLineIndent = rPrevNumFmt.GetFirstLineOffset();
     160                 :            :         }
     161                 :          0 :         aNumFmt.SetAbsLSpace( nAbsLSpace );
     162                 :          0 :         aNumFmt.SetFirstLineOffset( nFirstLineIndent );
     163 [ #  # ][ #  # ]:          0 :         aNumFmt.SetCharFmt( pCSS1Parser->GetCharFmtFromPool(nChrFmtPoolId) );
     164                 :            : 
     165                 :          0 :         bChangeNumFmt = sal_True;
     166                 :            :     }
     167         [ #  # ]:          0 :     else if( 1 != aNumFmt.GetStart() )
     168                 :            :     {
     169                 :            :         // Wenn die Ebene schon mal benutzt wurde, muss der Start-Wert
     170                 :            :         // ggf. hart am Absatz gesetzt werden.
     171                 :          0 :         rInfo.SetNodeStartValue( nLevel, 1 );
     172                 :            :     }
     173                 :            : 
     174                 :            :     // und es ggf. durch die Optionen veraendern
     175 [ #  # ][ #  # ]:          0 :     String aId, aStyle, aClass, aBulletSrc, aLang, aDir;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     176                 :          0 :     sal_Int16 eVertOri = text::VertOrientation::NONE;
     177                 :          0 :     sal_uInt16 nWidth=USHRT_MAX, nHeight=USHRT_MAX;
     178         [ #  # ]:          0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     179         [ #  # ]:          0 :     for (size_t i = rHTMLOptions.size(); i; )
     180                 :            :     {
     181         [ #  # ]:          0 :         const HTMLOption& rOption = rHTMLOptions[--i];
     182   [ #  #  #  #  :          0 :         switch( rOption.GetToken() )
          #  #  #  #  #  
                #  #  # ]
     183                 :            :         {
     184                 :            :         case HTML_O_ID:
     185         [ #  # ]:          0 :             aId = rOption.GetString();
     186                 :          0 :             break;
     187                 :            :         case HTML_O_TYPE:
     188 [ #  # ][ #  # ]:          0 :             if( bNewNumFmt && rOption.GetString().Len() )
                 [ #  # ]
     189                 :            :             {
     190      [ #  #  # ]:          0 :                 switch( nToken )
     191                 :            :                 {
     192                 :            :                 case HTML_ORDERLIST_ON:
     193                 :          0 :                     bChangeNumFmt = sal_True;
     194   [ #  #  #  #  :          0 :                     switch( rOption.GetString().GetChar(0) )
                      # ]
     195                 :            :                     {
     196                 :          0 :                     case 'A':   aNumFmt.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER); break;
     197                 :          0 :                     case 'a':   aNumFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); break;
     198                 :          0 :                     case 'I':   aNumFmt.SetNumberingType(SVX_NUM_ROMAN_UPPER);        break;
     199                 :          0 :                     case 'i':   aNumFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER);        break;
     200                 :          0 :                     default:    bChangeNumFmt = sal_False;
     201                 :            :                     }
     202                 :          0 :                     break;
     203                 :            : 
     204                 :            :                 case HTML_UNORDERLIST_ON:
     205                 :            :                     aNumFmt.SetBulletChar( (sal_Unicode)rOption.GetEnum(
     206         [ #  # ]:          0 :                                     aHTMLULTypeTable,aNumFmt.GetBulletChar() ) );
     207                 :          0 :                     bChangeNumFmt = sal_True;
     208                 :          0 :                     break;
     209                 :            :                 }
     210                 :            :             }
     211                 :          0 :             break;
     212                 :            :         case HTML_O_START:
     213                 :            :             {
     214         [ #  # ]:          0 :                 sal_uInt16 nStart = (sal_uInt16)rOption.GetNumber();
     215         [ #  # ]:          0 :                 if( bNewNumFmt )
     216                 :            :                 {
     217                 :          0 :                     aNumFmt.SetStart( nStart );
     218                 :          0 :                     bChangeNumFmt = sal_True;
     219                 :            :                 }
     220                 :            :                 else
     221                 :            :                 {
     222                 :          0 :                     rInfo.SetNodeStartValue( nLevel, nStart );
     223                 :            :                 }
     224                 :            :             }
     225                 :          0 :             break;
     226                 :            :         case HTML_O_STYLE:
     227         [ #  # ]:          0 :             aStyle = rOption.GetString();
     228                 :          0 :             break;
     229                 :            :         case HTML_O_CLASS:
     230         [ #  # ]:          0 :             aClass = rOption.GetString();
     231                 :          0 :             break;
     232                 :            :         case HTML_O_LANG:
     233         [ #  # ]:          0 :             aLang = rOption.GetString();
     234                 :          0 :             break;
     235                 :            :         case HTML_O_DIR:
     236         [ #  # ]:          0 :             aDir = rOption.GetString();
     237                 :          0 :             break;
     238                 :            :         case HTML_O_SRC:
     239         [ #  # ]:          0 :             if( bNewNumFmt )
     240                 :            :             {
     241         [ #  # ]:          0 :                 aBulletSrc = rOption.GetString();
     242 [ #  # ][ #  # ]:          0 :                 if( !InternalImgToPrivateURL(aBulletSrc) )
     243 [ #  # ][ #  # ]:          0 :                     aBulletSrc = URIHelper::SmartRel2Abs( INetURLObject( sBaseURL ), aBulletSrc, Link(), false );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     244                 :            :             }
     245                 :          0 :             break;
     246                 :            :         case HTML_O_WIDTH:
     247         [ #  # ]:          0 :             nWidth = (sal_uInt16)rOption.GetNumber();
     248                 :          0 :             break;
     249                 :            :         case HTML_O_HEIGHT:
     250         [ #  # ]:          0 :             nHeight = (sal_uInt16)rOption.GetNumber();
     251                 :          0 :             break;
     252                 :            :         case HTML_O_ALIGN:
     253                 :            :             eVertOri =
     254                 :            :                 (sal_Int16)rOption.GetEnum( aHTMLImgVAlignTable,
     255         [ #  # ]:          0 :                                                 static_cast< sal_uInt16 >(eVertOri) );
     256                 :          0 :             break;
     257                 :            :         }
     258                 :            :     }
     259                 :            : 
     260         [ #  # ]:          0 :     if( aBulletSrc.Len() )
     261                 :            :     {
     262                 :            :         // Eine Bullet-Liste mit Grafiken
     263                 :          0 :         aNumFmt.SetNumberingType(SVX_NUM_BITMAP);
     264                 :            : 
     265                 :            :         // Die Grafik als Brush anlegen
     266         [ #  # ]:          0 :         SvxBrushItem aBrushItem( RES_BACKGROUND );
     267         [ #  # ]:          0 :         aBrushItem.SetGraphicLink( aBulletSrc );
     268         [ #  # ]:          0 :         aBrushItem.SetGraphicPos( GPOS_AREA );
     269                 :            : 
     270                 :            :         // Die Groesse nur beachten, wenn Breite und Hoehe vorhanden sind
     271                 :          0 :         Size aTwipSz( nWidth, nHeight), *pTwipSz=0;
     272 [ #  # ][ #  # ]:          0 :         if( nWidth!=USHRT_MAX && nHeight!=USHRT_MAX )
     273                 :            :         {
     274                 :            :             aTwipSz =
     275                 :            :                 Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
     276 [ #  # ][ #  # ]:          0 :                                                     MapMode(MAP_TWIP) );
         [ #  # ][ #  # ]
     277                 :          0 :             pTwipSz = &aTwipSz;
     278                 :            :         }
     279                 :            : 
     280                 :            :         // Die Ausrichtung auch nur beachten, wenn eine Ausrichtung
     281                 :            :         // angegeben wurde
     282                 :            :         aNumFmt.SetGraphicBrush( &aBrushItem, pTwipSz,
     283 [ #  # ][ #  # ]:          0 :                             text::VertOrientation::NONE!=eVertOri ? &eVertOri : 0);
     284                 :            : 
     285                 :            :         // Und noch die Grafik merken, um sie in den Absaetzen nicht
     286                 :            :         // einzufuegen
     287         [ #  # ]:          0 :         aBulletGrfs[nLevel] = aBulletSrc;
     288         [ #  # ]:          0 :         bChangeNumFmt = sal_True;
     289                 :            :     }
     290                 :            :     else
     291         [ #  # ]:          0 :         aBulletGrfs[nLevel].Erase();
     292                 :            : 
     293                 :            :     // den aktuellen Absatz erst einmal nicht numerieren
     294                 :            :     {
     295                 :          0 :         sal_uInt8 nLvl = nLevel;
     296         [ #  # ]:          0 :         SetNodeNum( nLvl, false );
     297                 :            :     }
     298                 :            : 
     299                 :            :     // einen neuen Kontext anlegen
     300 [ #  # ][ #  # ]:          0 :     _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
     301                 :            : 
     302                 :            :     // Styles parsen
     303         [ #  # ]:          0 :     if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
     304                 :            :     {
     305 [ #  # ][ #  # ]:          0 :         SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     306         [ #  # ]:          0 :         SvxCSS1PropertyInfo aPropInfo;
     307                 :            : 
     308 [ #  # ][ #  # ]:          0 :         if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
     309                 :            :         {
     310         [ #  # ]:          0 :             if( bNewNumFmt )
     311                 :            :             {
     312         [ #  # ]:          0 :                 if( aPropInfo.bLeftMargin )
     313                 :            :                 {
     314                 :            :                     // Der Der Default-Einzug wurde schon eingefuegt.
     315                 :            :                     sal_uInt16 nAbsLSpace =
     316         [ #  # ]:          0 :                         aNumFmt.GetAbsLSpace() - HTML_NUMBUL_MARGINLEFT;
     317 [ #  # ][ #  # ]:          0 :                     if( aPropInfo.nLeftMargin < 0 &&
     318                 :            :                         nAbsLSpace < -aPropInfo.nLeftMargin )
     319                 :          0 :                         nAbsLSpace = 0U;
     320 [ #  # ][ #  # ]:          0 :                     else if( aPropInfo.nLeftMargin > USHRT_MAX ||
     321                 :            :                              (long)nAbsLSpace +
     322                 :            :                                             aPropInfo.nLeftMargin > USHRT_MAX )
     323                 :          0 :                         nAbsLSpace = USHRT_MAX;
     324                 :            :                     else
     325                 :          0 :                         nAbsLSpace = nAbsLSpace + (sal_uInt16)aPropInfo.nLeftMargin;
     326                 :            : 
     327                 :          0 :                     aNumFmt.SetAbsLSpace( nAbsLSpace );
     328                 :          0 :                     bChangeNumFmt = sal_True;
     329                 :            :                 }
     330         [ #  # ]:          0 :                 if( aPropInfo.bTextIndent )
     331                 :            :                 {
     332                 :            :                     short nTextIndent =
     333         [ #  # ]:          0 :                         ((const SvxLRSpaceItem &)aItemSet.Get( RES_LR_SPACE ))
     334                 :          0 :                                                         .GetTxtFirstLineOfst();
     335                 :          0 :                     aNumFmt.SetFirstLineOffset( nTextIndent );
     336                 :          0 :                     bChangeNumFmt = sal_True;
     337                 :            :                 }
     338                 :            :             }
     339                 :          0 :             aPropInfo.bLeftMargin = aPropInfo.bTextIndent = sal_False;
     340         [ #  # ]:          0 :             if( !aPropInfo.bRightMargin )
     341         [ #  # ]:          0 :                 aItemSet.ClearItem( RES_LR_SPACE );
     342                 :            : 
     343                 :            :             // #i89812# - Perform change to list style before calling <DoPositioning(..)>,
     344                 :            :             // because <DoPositioning(..)> may open a new context and thus may
     345                 :            :             // clear the <SwHTMLNumRuleInfo> instance hold by local variable <rInfo>.
     346         [ #  # ]:          0 :             if( bChangeNumFmt )
     347                 :            :             {
     348         [ #  # ]:          0 :                 rInfo.GetNumRule()->Set( nLevel, aNumFmt );
     349         [ #  # ]:          0 :                 pDoc->ChgNumRuleFmts( *rInfo.GetNumRule() );
     350                 :          0 :                 bChangeNumFmt = sal_False;
     351                 :            :             }
     352                 :            : 
     353         [ #  # ]:          0 :             DoPositioning( aItemSet, aPropInfo, pCntxt );
     354                 :            : 
     355         [ #  # ]:          0 :             InsertAttrs( aItemSet, aPropInfo, pCntxt );
     356 [ #  # ][ #  # ]:          0 :         }
     357                 :            :     }
     358                 :            : 
     359         [ #  # ]:          0 :     if( bChangeNumFmt )
     360                 :            :     {
     361         [ #  # ]:          0 :         rInfo.GetNumRule()->Set( nLevel, aNumFmt );
     362         [ #  # ]:          0 :         pDoc->ChgNumRuleFmts( *rInfo.GetNumRule() );
     363                 :            :     }
     364                 :            : 
     365         [ #  # ]:          0 :     PushContext( pCntxt );
     366                 :            : 
     367                 :            :     // die Attribute der neuen Vorlage setzen
     368 [ #  # ][ #  # ]:          0 :     SetTxtCollAttrs( pCntxt );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     369                 :          0 : }
     370                 :            : 
     371                 :          0 : void SwHTMLParser::EndNumBulList( int nToken )
     372                 :            : {
     373                 :          0 :     SwHTMLNumRuleInfo& rInfo = GetNumInfo();
     374                 :            : 
     375                 :            :     // Ein neuer Absatz muss aufgemacht werden, wenn
     376                 :            :     // - der aktuelle nicht leer ist, also Text oder absatzgebundene Objekte
     377                 :            :     //   enthaelt.
     378                 :            :     // - der aktuelle Absatz numeriert ist.
     379                 :          0 :     sal_Bool bAppend = pPam->GetPoint()->nContent.GetIndex() > 0;
     380         [ #  # ]:          0 :     if( !bAppend )
     381                 :            :     {
     382                 :          0 :         SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
     383                 :            : 
     384                 :          0 :         bAppend = (pTxtNode && ! pTxtNode->IsOutline() && pTxtNode->IsCountedInList()) ||
     385                 :            : 
     386 [ #  # ][ #  #  :          0 :             HasCurrentParaFlys();
             #  #  #  # ]
     387                 :            :     }
     388                 :            : 
     389                 :          0 :     sal_Bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 1;
     390         [ #  # ]:          0 :     if( bAppend )
     391         [ #  # ]:          0 :         AppendTxtNode( bSpace ? AM_SPACE : AM_NOSPACE, sal_False );
     392         [ #  # ]:          0 :     else if( bSpace )
     393                 :          0 :         AddParSpace();
     394                 :            : 
     395                 :            :     // den aktuellen Kontext vom Stack holen
     396         [ #  # ]:          0 :     _HTMLAttrContext *pCntxt = nToken!=0 ? PopContext( static_cast< sal_uInt16 >(nToken & ~1) ) : 0;
     397                 :            : 
     398                 :            :     // Keine Liste aufgrund eines Tokens beenden, wenn der Kontext
     399                 :            :     // nie angelgt wurde oder nicht beendet werden darf.
     400 [ #  # ][ #  # ]:          0 :     if( rInfo.GetDepth()>0 && (!nToken || pCntxt) )
         [ #  # ][ #  # ]
     401                 :            :     {
     402                 :          0 :         rInfo.DecDepth();
     403         [ #  # ]:          0 :         if( !rInfo.GetDepth() )     // wars der letze Level ?
     404                 :            :         {
     405                 :            :             // Die noch nicht angepassten Formate werden jetzt noch
     406                 :            :             // angepasst, damit es sich besser Editieren laesst.
     407                 :          0 :             const SwNumFmt *pRefNumFmt = 0;
     408                 :          0 :             sal_Bool bChanged = sal_False;
     409         [ #  # ]:          0 :             for( sal_uInt16 i=0; i<MAXLEVEL; i++ )
     410                 :            :             {
     411                 :          0 :                 const SwNumFmt *pNumFmt = rInfo.GetNumRule()->GetNumFmt(i);
     412         [ #  # ]:          0 :                 if( pNumFmt )
     413                 :            :                 {
     414                 :          0 :                     pRefNumFmt = pNumFmt;
     415                 :            :                 }
     416         [ #  # ]:          0 :                 else if( pRefNumFmt )
     417                 :            :                 {
     418 [ #  # ][ #  # ]:          0 :                     SwNumFmt aNumFmt( rInfo.GetNumRule()->Get(i) );
     419                 :          0 :                     aNumFmt.SetNumberingType(pRefNumFmt->GetNumberingType() != SVX_NUM_BITMAP
     420         [ #  # ]:          0 :                                         ? pRefNumFmt->GetNumberingType() : style::NumberingType::CHAR_SPECIAL);
     421         [ #  # ]:          0 :                     if( SVX_NUM_CHAR_SPECIAL == aNumFmt.GetNumberingType() )
     422                 :            :                     {
     423                 :            :                         // #i63395# - Only apply user defined default bullet font
     424 [ #  # ][ #  # ]:          0 :                         if ( numfunc::IsDefBulletFontUserDefined() )
     425                 :            :                         {
     426 [ #  # ][ #  # ]:          0 :                             aNumFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
     427                 :            :                         }
     428                 :          0 :                         aNumFmt.SetBulletChar( cBulletChar );
     429                 :            :                     }
     430                 :          0 :                     aNumFmt.SetAbsLSpace( (i+1) * HTML_NUMBUL_MARGINLEFT );
     431                 :          0 :                     aNumFmt.SetFirstLineOffset( HTML_NUMBUL_INDENT );
     432         [ #  # ]:          0 :                     aNumFmt.SetCharFmt( pRefNumFmt->GetCharFmt() );
     433         [ #  # ]:          0 :                     rInfo.GetNumRule()->Set( i, aNumFmt );
     434         [ #  # ]:          0 :                     bChanged = sal_True;
     435                 :            :                 }
     436                 :            :             }
     437         [ #  # ]:          0 :             if( bChanged )
     438                 :          0 :                 pDoc->ChgNumRuleFmts( *rInfo.GetNumRule() );
     439                 :            : 
     440                 :            :             // Beim letzen Append wurde das NumRule-Item und das
     441                 :            :             // NodeNum-Objekt mit kopiert. Beides muessen wir noch
     442                 :            :             // loeschen. Das ResetAttr loescht das NodeNum-Objekt mit!
     443                 :          0 :             pPam->GetNode()->GetTxtNode()->ResetAttr( RES_PARATR_NUMRULE );
     444                 :            : 
     445                 :          0 :             rInfo.Clear();
     446                 :            :         }
     447                 :            :         else
     448                 :            :         {
     449                 :            :             // the next paragraph not numbered first
     450                 :          0 :             SetNodeNum( rInfo.GetLevel(), false );
     451                 :            :         }
     452                 :            :     }
     453                 :            : 
     454                 :            :     // und noch Attribute beenden
     455                 :          0 :     sal_Bool bSetAttrs = sal_False;
     456         [ #  # ]:          0 :     if( pCntxt )
     457                 :            :     {
     458                 :          0 :         EndContext( pCntxt );
     459         [ #  # ]:          0 :         delete pCntxt;
     460                 :          0 :         bSetAttrs = sal_True;
     461                 :            :     }
     462                 :            : 
     463         [ #  # ]:          0 :     if( nToken )
     464                 :          0 :         SetTxtCollAttrs();
     465                 :            : 
     466         [ #  # ]:          0 :     if( bSetAttrs )
     467                 :          0 :         SetAttr();  // Absatz-Atts wegen JavaScript moeglichst schnell setzen
     468                 :            : 
     469                 :          0 : }
     470                 :            : 
     471                 :            : 
     472                 :          0 : void SwHTMLParser::NewNumBulListItem( int nToken )
     473                 :            : {
     474                 :          0 :     sal_uInt8 nLevel = GetNumInfo().GetLevel();
     475 [ #  # ][ #  # ]:          0 :     String aId, aStyle, aClass, aLang, aDir;
         [ #  # ][ #  # ]
                 [ #  # ]
     476                 :            :     sal_uInt16 nStart = HTML_LISTHEADER_ON != nToken
     477                 :          0 :                         ? GetNumInfo().GetNodeStartValue( nLevel )
     478         [ #  # ]:          0 :                         : USHRT_MAX;
     479         [ #  # ]:          0 :     if( USHRT_MAX != nStart )
     480                 :          0 :         GetNumInfo().SetNodeStartValue( nLevel );
     481                 :            : 
     482         [ #  # ]:          0 :     const HTMLOptions& rHTMLOptions = GetOptions();
     483         [ #  # ]:          0 :     for (size_t i = rHTMLOptions.size(); i; )
     484                 :            :     {
     485         [ #  # ]:          0 :         const HTMLOption& rOption = rHTMLOptions[--i];
     486   [ #  #  #  #  :          0 :         switch( rOption.GetToken() )
                #  #  # ]
     487                 :            :         {
     488                 :            :             case HTML_O_VALUE:
     489         [ #  # ]:          0 :                 nStart = (sal_uInt16)rOption.GetNumber();
     490                 :          0 :                 break;
     491                 :            :             case HTML_O_ID:
     492         [ #  # ]:          0 :                 aId = rOption.GetString();
     493                 :          0 :                 break;
     494                 :            :             case HTML_O_STYLE:
     495         [ #  # ]:          0 :                 aStyle = rOption.GetString();
     496                 :          0 :                 break;
     497                 :            :             case HTML_O_CLASS:
     498         [ #  # ]:          0 :                 aClass = rOption.GetString();
     499                 :          0 :                 break;
     500                 :            :             case HTML_O_LANG:
     501         [ #  # ]:          0 :                 aLang = rOption.GetString();
     502                 :          0 :                 break;
     503                 :            :             case HTML_O_DIR:
     504         [ #  # ]:          0 :                 aDir = rOption.GetString();
     505                 :          0 :                 break;
     506                 :            :         }
     507                 :            :     }
     508                 :            : 
     509                 :            :     // einen neuen Absatz aufmachen
     510         [ #  # ]:          0 :     if( pPam->GetPoint()->nContent.GetIndex() )
     511         [ #  # ]:          0 :         AppendTxtNode( AM_NOSPACE, sal_False );
     512                 :          0 :     bNoParSpace = sal_False;    // In <LI> wird kein Abstand eingefuegt!
     513                 :            : 
     514                 :          0 :     const bool bCountedInList( HTML_LISTHEADER_ON==nToken ? false : true );
     515                 :            : 
     516 [ #  # ][ #  # ]:          0 :     _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
     517                 :            : 
     518         [ #  # ]:          0 :     String aNumRuleName;
     519         [ #  # ]:          0 :     if( GetNumInfo().GetNumRule() )
     520                 :            :     {
     521         [ #  # ]:          0 :         aNumRuleName = GetNumInfo().GetNumRule()->GetName();
     522                 :            :     }
     523                 :            :     else
     524                 :            :     {
     525 [ #  # ][ #  # ]:          0 :         aNumRuleName = pDoc->GetUniqueNumRuleName();
                 [ #  # ]
     526                 :            :         SwNumRule aNumRule( aNumRuleName,
     527         [ #  # ]:          0 :                             SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
     528 [ #  # ][ #  # ]:          0 :         SwNumFmt aNumFmt( aNumRule.Get( 0 ) );
     529                 :            :         // #i63395# - Only apply user defined default bullet font
     530 [ #  # ][ #  # ]:          0 :         if ( numfunc::IsDefBulletFontUserDefined() )
     531                 :            :         {
     532 [ #  # ][ #  # ]:          0 :             aNumFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
     533                 :            :         }
     534                 :          0 :         aNumFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
     535                 :          0 :         aNumFmt.SetBulletChar( cBulletChar );   // das Bulletzeichen !!
     536 [ #  # ][ #  # ]:          0 :         aNumFmt.SetCharFmt( pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_BUL_LEVEL) );
     537                 :          0 :         aNumFmt.SetLSpace( (sal_uInt16)(-HTML_NUMBUL_INDENT) );
     538                 :          0 :         aNumFmt.SetFirstLineOffset( HTML_NUMBUL_INDENT );
     539         [ #  # ]:          0 :         aNumRule.Set( 0, aNumFmt );
     540                 :            : 
     541         [ #  # ]:          0 :         pDoc->MakeNumRule( aNumRuleName, &aNumRule );
     542                 :            : 
     543                 :            :         OSL_ENSURE( !nOpenParaToken,
     544                 :            :                 "Jetzt geht ein offenes Absatz-Element verloren" );
     545                 :            :         // Wir tun so, als ob wir in einem Absatz sind. Dann wird
     546                 :            :         // beim naechsten Absatz wenigstens die Numerierung
     547                 :            :         // weggeschmissen, die nach dem naechsten AppendTxtNode uebernommen
     548                 :            :         // wird.
     549 [ #  # ][ #  # ]:          0 :         nOpenParaToken = static_cast< sal_uInt16 >(nToken);
     550                 :            :     }
     551                 :            : 
     552                 :          0 :     SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
     553 [ #  # ][ #  # ]:          0 :     ((SwCntntNode *)pTxtNode)->SetAttr( SwNumRuleItem(aNumRuleName) );
                 [ #  # ]
     554         [ #  # ]:          0 :     pTxtNode->SetAttrListLevel(nLevel);
     555                 :            :     // #i57656# - <IsCounted()> state of text node has to be adjusted accordingly.
     556         [ #  # ]:          0 :     if ( nLevel < MAXLEVEL )
     557                 :            :     {
     558         [ #  # ]:          0 :         pTxtNode->SetCountedInList( bCountedInList );
     559                 :            :     }
     560                 :            :     // #i57919#
     561                 :            :     // correction of refactoring done by cws swnumtree
     562                 :            :     // - <nStart> contains the start value, if the numbering has to be restarted
     563                 :            :     //   at this text node. Value <USHRT_MAX> indicates, that numbering isn't
     564                 :            :     //   restarted at this text node
     565         [ #  # ]:          0 :     if ( nStart != USHRT_MAX )
     566                 :            :     {
     567         [ #  # ]:          0 :         pTxtNode->SetListRestart( true );
     568         [ #  # ]:          0 :         pTxtNode->SetAttrListRestartValue( nStart );
     569                 :            :     }
     570                 :            : 
     571         [ #  # ]:          0 :     if( GetNumInfo().GetNumRule() )
     572         [ #  # ]:          0 :         GetNumInfo().GetNumRule()->SetInvalidRule( sal_True );
     573                 :            : 
     574                 :            :     // Styles parsen
     575         [ #  # ]:          0 :     if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
     576                 :            :     {
     577 [ #  # ][ #  # ]:          0 :         SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
     578         [ #  # ]:          0 :         SvxCSS1PropertyInfo aPropInfo;
     579                 :            : 
     580 [ #  # ][ #  # ]:          0 :         if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
     581                 :            :         {
     582         [ #  # ]:          0 :             DoPositioning( aItemSet, aPropInfo, pCntxt );
     583         [ #  # ]:          0 :             InsertAttrs( aItemSet, aPropInfo, pCntxt );
     584 [ #  # ][ #  # ]:          0 :         }
     585                 :            :     }
     586                 :            : 
     587         [ #  # ]:          0 :     PushContext( pCntxt );
     588                 :            : 
     589                 :            :     // die neue Vorlage setzen
     590         [ #  # ]:          0 :     SetTxtCollAttrs( pCntxt );
     591                 :            : 
     592                 :            :     // Laufbalkenanzeige aktualisieren
     593 [ #  # ][ #  # ]:          0 :     ShowStatline();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     594                 :          0 : }
     595                 :            : 
     596                 :          0 : void SwHTMLParser::EndNumBulListItem( int nToken, sal_Bool bSetColl,
     597                 :            :                                       sal_Bool /*bLastPara*/ )
     598                 :            : {
     599                 :            :     // einen neuen Absatz aufmachen
     600 [ #  # ][ #  # ]:          0 :     if( !nToken && pPam->GetPoint()->nContent.GetIndex() )
                 [ #  # ]
     601                 :          0 :         AppendTxtNode( AM_NOSPACE );
     602                 :            : 
     603                 :            :     // Kontext zu dem Token suchen und vom Stack holen
     604                 :          0 :     _HTMLAttrContext *pCntxt = 0;
     605                 :          0 :     sal_uInt16 nPos = aContexts.size();
     606                 :          0 :     nToken &= ~1;
     607 [ #  # ][ #  # ]:          0 :     while( !pCntxt && nPos>nContextStMin )
                 [ #  # ]
     608                 :            :     {
     609                 :          0 :         sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
     610      [ #  #  # ]:          0 :         switch( nCntxtToken )
     611                 :            :         {
     612                 :            :         case HTML_LI_ON:
     613                 :            :         case HTML_LISTHEADER_ON:
     614 [ #  # ][ #  # ]:          0 :             if( !nToken || nToken == nCntxtToken  )
     615                 :            :             {
     616                 :          0 :                 pCntxt = aContexts[nPos];
     617 [ #  # ][ #  # ]:          0 :                 aContexts.erase( aContexts.begin() + nPos );
     618                 :            :             }
     619                 :          0 :             break;
     620                 :            :         case HTML_ORDERLIST_ON:
     621                 :            :         case HTML_UNORDERLIST_ON:
     622                 :            :         case HTML_MENULIST_ON:
     623                 :            :         case HTML_DIRLIST_ON:
     624                 :            :             // keine LI/LH ausserhalb der aktuellen Liste betrachten
     625                 :          0 :             nPos = nContextStMin;
     626                 :          0 :             break;
     627                 :            :         }
     628                 :            :     }
     629                 :            : 
     630                 :            :     // und noch Attribute beenden
     631         [ #  # ]:          0 :     if( pCntxt )
     632                 :            :     {
     633                 :          0 :         EndContext( pCntxt );
     634                 :          0 :         SetAttr();  // Absatz-Atts wegen JavaScript moeglichst schnell setzen
     635         [ #  # ]:          0 :         delete pCntxt;
     636                 :            :     }
     637                 :            : 
     638                 :            :     // und die bisherige Vorlage setzen
     639         [ #  # ]:          0 :     if( bSetColl )
     640                 :          0 :         SetTxtCollAttrs();
     641                 :          0 : }
     642                 :            : 
     643                 :            : 
     644                 :          0 : void SwHTMLParser::SetNodeNum( sal_uInt8 nLevel, bool bCountedInList )
     645                 :            : {
     646                 :          0 :     SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
     647                 :            :     OSL_ENSURE( pTxtNode, "Kein Text-Node an PaM-Position" );
     648                 :            : 
     649                 :            :     OSL_ENSURE( GetNumInfo().GetNumRule(), "Kein Numerierungs-Regel" );
     650                 :          0 :     const String& rName = GetNumInfo().GetNumRule()->GetName();
     651         [ #  # ]:          0 :     ((SwCntntNode *)pTxtNode)->SetAttr( SwNumRuleItem(rName) );
     652                 :            : 
     653                 :          0 :     pTxtNode->SetAttrListLevel( nLevel );
     654                 :          0 :     pTxtNode->SetCountedInList( bCountedInList );
     655                 :            : 
     656                 :            :     // NumRule invalidieren, weil sie durch ein EndAction bereits
     657                 :            :     // auf valid geschaltet worden sein kann.
     658                 :          0 :     GetNumInfo().GetNumRule()->SetInvalidRule( sal_False );
     659                 :          0 : }
     660                 :            : 
     661                 :            : 
     662                 :            : 
     663                 :          0 : void SwHTMLWriter::FillNextNumInfo()
     664                 :            : {
     665                 :          0 :     pNextNumRuleInfo = 0;
     666                 :            : 
     667                 :          0 :     sal_uLong nPos = pCurPam->GetPoint()->nNode.GetIndex() + 1;
     668                 :            : 
     669                 :          0 :     sal_Bool bTable = sal_False;
     670         [ #  # ]:          0 :     do
     671                 :            :     {
     672                 :          0 :         const SwNode* pNd = pDoc->GetNodes()[nPos];
     673         [ #  # ]:          0 :         if( pNd->IsTxtNode() )
     674                 :            :         {
     675                 :            :             // Der naechste wird als naechstes ausgegeben.
     676         [ #  # ]:          0 :             pNextNumRuleInfo = new SwHTMLNumRuleInfo( *pNd->GetTxtNode() );
     677                 :            : 
     678                 :            :             // Vor einer Tabelle behalten wir erst einmal die alte Ebene bei,
     679                 :            :             // wenn die gleiche Numerierung hinter der Tabelle
     680                 :            :             // fortgesetzt wird und dort nicht von vorne numeriert
     681                 :            :             // wird. Die Tabelle wird ann beim Import so weit eingeruckt,
     682                 :            :             // wie es der Num-Ebene entspricht.
     683   [ #  #  #  #  :          0 :             if( bTable &&
           #  # ][ #  # ]
     684                 :          0 :                 pNextNumRuleInfo->GetNumRule()==GetNumInfo().GetNumRule() &&
     685                 :          0 :                 !pNextNumRuleInfo->IsRestart() )
     686                 :            :             {
     687                 :          0 :                 pNextNumRuleInfo->SetDepth( GetNumInfo().GetDepth() );
     688                 :            :             }
     689                 :            :         }
     690         [ #  # ]:          0 :         else if( pNd->IsTableNode() )
     691                 :            :         {
     692                 :            :             // Eine Tabelle wird uebersprungen, also den Node
     693                 :            :             // hinter der Tabelle betrachten.
     694                 :          0 :             nPos = pNd->EndOfSectionIndex() + 1;
     695                 :          0 :             bTable = sal_True;
     696                 :            :         }
     697                 :            :         else
     698                 :            :         {
     699                 :            :             // In allen anderen Faellen ist die Numerierung erstmal
     700                 :            :             // zu Ende.
     701                 :          0 :             pNextNumRuleInfo = new SwHTMLNumRuleInfo;
     702                 :            :         }
     703                 :            :     }
     704                 :          0 :     while( !pNextNumRuleInfo );
     705                 :          0 : }
     706                 :            : 
     707                 :          2 : void SwHTMLWriter::ClearNextNumInfo()
     708                 :            : {
     709                 :          2 :     delete pNextNumRuleInfo;
     710                 :          2 :     pNextNumRuleInfo = 0;
     711                 :          2 : }
     712                 :            : 
     713                 :          0 : Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
     714                 :            :                                  const SwHTMLNumRuleInfo& rInfo )
     715                 :            : {
     716                 :          0 :     SwHTMLNumRuleInfo& rPrevInfo = rWrt.GetNumInfo();
     717                 :          0 :     sal_Bool bSameRule = rPrevInfo.GetNumRule() == rInfo.GetNumRule();
     718   [ #  #  #  # ]:          0 :     if( bSameRule && rPrevInfo.GetDepth() >= rInfo.GetDepth() &&
         [ #  # ][ #  # ]
     719                 :          0 :         !rInfo.IsRestart() )
     720                 :            :     {
     721                 :          0 :         return rWrt;
     722                 :            :     }
     723                 :            : 
     724                 :          0 :     sal_Bool bStartValue = sal_False;
     725 [ #  # ][ #  # ]:          0 :     if( !bSameRule && rInfo.GetDepth() )
                 [ #  # ]
     726                 :            :     {
     727         [ #  # ]:          0 :         String aName( rInfo.GetNumRule()->GetName() );
     728 [ #  # ][ #  # ]:          0 :         if( 0 != rWrt.aNumRuleNames.count( aName ) )
     729                 :            :         {
     730                 :            :             // The rule has been applied before
     731                 :            :             sal_Int16 eType = rInfo.GetNumRule()
     732         [ #  # ]:          0 :                 ->Get( rInfo.GetDepth()-1 ).GetNumberingType();
     733 [ #  # ][ #  # ]:          0 :             if( SVX_NUM_CHAR_SPECIAL != eType && SVX_NUM_BITMAP != eType )
     734                 :            :             {
     735                 :            :                 // If its a numbering rule, the current number should be
     736                 :            :                 // exported as start value, but only if there are no nodes
     737                 :            :                 // within the numbering that have a lower level
     738                 :          0 :                 bStartValue = sal_True;
     739         [ #  # ]:          0 :                 if( rInfo.GetDepth() > 1 )
     740                 :            :                 {
     741                 :            :                     sal_uLong nPos =
     742                 :          0 :                         rWrt.pCurPam->GetPoint()->nNode.GetIndex() + 1;
     743                 :          0 :                     do
     744                 :            :                     {
     745 [ #  # ][ #  # ]:          0 :                         const SwNode* pNd = rWrt.pDoc->GetNodes()[nPos];
     746         [ #  # ]:          0 :                         if( pNd->IsTxtNode() )
     747                 :            :                         {
     748                 :          0 :                             const SwTxtNode *pTxtNd = pNd->GetTxtNode();
     749 [ #  # ][ #  # ]:          0 :                             if( !pTxtNd->GetNumRule() )
     750                 :            :                             {
     751                 :            :                                 // node isn't numbered => check completed
     752                 :          0 :                                 break;
     753                 :            :                             }
     754                 :            : 
     755                 :            :                             OSL_ENSURE(! pTxtNd->IsOutline(),
     756                 :            :                                    "outline not expected");
     757                 :            : 
     758   [ #  #  #  # ]:          0 :                             if( pTxtNd->GetActualListLevel() + 1 <
     759                 :          0 :                                 rInfo.GetDepth() )
     760                 :            :                             {
     761                 :            :                                 // node is numbered, but level is lower
     762                 :            :                                 // => check completed
     763                 :          0 :                                 bStartValue = sal_False;
     764                 :          0 :                                 break;
     765                 :            :                             }
     766                 :          0 :                             nPos++;
     767                 :            :                         }
     768         [ #  # ]:          0 :                         else if( pNd->IsTableNode() )
     769                 :            :                         {
     770                 :            :                             // skip table
     771                 :          0 :                             nPos = pNd->EndOfSectionIndex() + 1;
     772                 :            :                         }
     773                 :            :                         else
     774                 :            :                         {
     775                 :            :                             // end node or sections start node -> check
     776                 :            :                             // completed
     777                 :          0 :                             break;
     778                 :            :                         }
     779                 :            :                     }
     780                 :            :                     while( sal_True );
     781                 :            :                 }
     782                 :            :             }
     783                 :            :         }
     784                 :            :         else
     785                 :            :         {
     786         [ #  # ]:          0 :             rWrt.aNumRuleNames.insert( aName );
     787         [ #  # ]:          0 :         }
     788                 :            :     }
     789                 :            : 
     790                 :            : 
     791                 :            :     OSL_ENSURE( rWrt.nLastParaToken == 0,
     792                 :            :                 "<PRE> wurde nicht vor <OL> beendet." );
     793                 :            :     sal_uInt16 nPrevDepth =
     794 [ #  # ][ #  # ]:          0 :         (bSameRule && !rInfo.IsRestart()) ? rPrevInfo.GetDepth() : 0;
     795                 :            : 
     796         [ #  # ]:          0 :     for( sal_uInt16 i=nPrevDepth; i<rInfo.GetDepth(); i++ )
     797                 :            :     {
     798         [ #  # ]:          0 :         rWrt.OutNewLine(); // <OL>/<UL> in eine neue Zeile
     799                 :            : 
     800         [ #  # ]:          0 :         rWrt.aBulletGrfs[i].Erase();
     801                 :          0 :         rtl::OStringBuffer sOut;
     802         [ #  # ]:          0 :         sOut.append('<');
     803         [ #  # ]:          0 :         const SwNumFmt& rNumFmt = rInfo.GetNumRule()->Get( i );
     804                 :          0 :         sal_Int16 eType = rNumFmt.GetNumberingType();
     805         [ #  # ]:          0 :         if( SVX_NUM_CHAR_SPECIAL == eType )
     806                 :            :         {
     807                 :            :             // Aufzaehlungs-Liste: <OL>
     808         [ #  # ]:          0 :             sOut.append(OOO_STRING_SVTOOLS_HTML_unorderlist);
     809                 :            : 
     810                 :            :             // den Typ ueber das Bullet-Zeichen bestimmen
     811                 :          0 :             const sal_Char *pStr = 0;
     812   [ #  #  #  # ]:          0 :             switch( rNumFmt.GetBulletChar() )
     813                 :            :             {
     814                 :            :             case HTML_BULLETCHAR_DISC:
     815                 :          0 :                 pStr = OOO_STRING_SVTOOLS_HTML_ULTYPE_disc;
     816                 :          0 :                 break;
     817                 :            :             case HTML_BULLETCHAR_CIRCLE:
     818                 :          0 :                 pStr = OOO_STRING_SVTOOLS_HTML_ULTYPE_circle;
     819                 :          0 :                 break;
     820                 :            :             case HTML_BULLETCHAR_SQUARE:
     821                 :          0 :                 pStr = OOO_STRING_SVTOOLS_HTML_ULTYPE_square;
     822                 :          0 :                 break;
     823                 :            :             }
     824                 :            : 
     825         [ #  # ]:          0 :             if( pStr )
     826                 :            :             {
     827 [ #  # ][ #  # ]:          0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type).
     828 [ #  # ][ #  # ]:          0 :                     append('=').append(pStr);
     829                 :            :             }
     830                 :            :         }
     831         [ #  # ]:          0 :         else if( SVX_NUM_BITMAP == eType )
     832                 :            :         {
     833                 :            :             // Aufzaehlungs-Liste: <OL>
     834         [ #  # ]:          0 :             sOut.append(OOO_STRING_SVTOOLS_HTML_unorderlist);
     835 [ #  # ][ #  # ]:          0 :             rWrt.Strm() << sOut.makeStringAndClear().getStr();
     836                 :            : 
     837                 :            :             OutHTML_BulletImage( rWrt,
     838                 :            :                                     0,
     839                 :            :                                     rNumFmt.GetBrush(),
     840                 :          0 :                                     rWrt.aBulletGrfs[i],
     841                 :          0 :                                     rNumFmt.GetGraphicSize(),
     842   [ #  #  #  # ]:          0 :                                     rNumFmt.GetGraphicOrientation() );
     843                 :            :         }
     844                 :            :         else
     845                 :            :         {
     846                 :            :             // Numerierungs-Liste: <UL>
     847         [ #  # ]:          0 :             sOut.append(OOO_STRING_SVTOOLS_HTML_orderlist);
     848                 :            : 
     849                 :            :             // den Typ ueber das Format bestimmen
     850                 :          0 :             sal_Char cType = 0;
     851   [ #  #  #  #  :          0 :             switch( eType )
                      # ]
     852                 :            :             {
     853                 :          0 :             case SVX_NUM_CHARS_UPPER_LETTER:    cType = 'A'; break;
     854                 :          0 :             case SVX_NUM_CHARS_LOWER_LETTER:    cType = 'a'; break;
     855                 :          0 :             case SVX_NUM_ROMAN_UPPER:           cType = 'I'; break;
     856                 :          0 :             case SVX_NUM_ROMAN_LOWER:           cType = 'i'; break;
     857                 :            :             }
     858         [ #  # ]:          0 :             if( cType )
     859                 :            :             {
     860 [ #  # ][ #  # ]:          0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type).
     861 [ #  # ][ #  # ]:          0 :                     append('=').append(cType);
     862                 :            :             }
     863                 :            : 
     864                 :          0 :             sal_uInt16 nStartVal = rNumFmt.GetStart();
     865 [ #  # ][ #  # ]:          0 :             if( bStartValue && 1 == nStartVal && i == rInfo.GetDepth()-1 )
         [ #  # ][ #  # ]
     866                 :            :             {
     867                 :            :                 // #i51089 - TUNING#
     868         [ #  # ]:          0 :                 if ( rWrt.pCurPam->GetNode()->GetTxtNode()->GetNum() )
     869                 :            :                 {
     870                 :            :                     nStartVal = static_cast< sal_uInt16 >( rWrt.pCurPam->GetNode()
     871 [ #  # ][ #  # ]:          0 :                                 ->GetTxtNode()->GetNumberVector()[i] );
     872                 :            :                 }
     873                 :            :                 else
     874                 :            :                 {
     875                 :            :                     OSL_FAIL( "<OutHTML_NumBulListStart(..) - text node has no number." );
     876                 :            :                 }
     877                 :            :             }
     878         [ #  # ]:          0 :             if( nStartVal != 1 )
     879                 :            :             {
     880 [ #  # ][ #  # ]:          0 :                 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_start).
     881 [ #  # ][ #  # ]:          0 :                     append('=').append(static_cast<sal_Int32>(nStartVal));
     882                 :            :             }
     883                 :            :         }
     884                 :            : 
     885         [ #  # ]:          0 :         if (sOut.getLength())
     886 [ #  # ][ #  # ]:          0 :             rWrt.Strm() << sOut.makeStringAndClear().getStr();
     887                 :            : 
     888         [ #  # ]:          0 :         if( rWrt.bCfgOutStyles )
     889         [ #  # ]:          0 :             OutCSS1_NumBulListStyleOpt( rWrt, *rInfo.GetNumRule(), (sal_uInt8)i );
     890                 :            : 
     891 [ #  # ][ #  # ]:          0 :         rWrt.Strm() << '>';
     892                 :            : 
     893                 :          0 :         rWrt.IncIndentLevel(); // Inhalt von <OL> einruecken
     894                 :          0 :     }
     895                 :            : 
     896                 :          0 :     return rWrt;
     897                 :            : }
     898                 :            : 
     899                 :          0 : Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
     900                 :            :                                const SwHTMLNumRuleInfo& rNextInfo )
     901                 :            : {
     902                 :          0 :     SwHTMLNumRuleInfo& rInfo = rWrt.GetNumInfo();
     903                 :          0 :     sal_Bool bSameRule = rNextInfo.GetNumRule() == rInfo.GetNumRule();
     904   [ #  #  #  # ]:          0 :     if( bSameRule && rNextInfo.GetDepth() >= rInfo.GetDepth() &&
         [ #  # ][ #  # ]
     905                 :          0 :         !rNextInfo.IsRestart() )
     906                 :            :     {
     907                 :          0 :         return rWrt;
     908                 :            :     }
     909                 :            : 
     910                 :            :     OSL_ENSURE( rWrt.nLastParaToken == 0,
     911                 :            :                 "<PRE> wurde nicht vor </OL> beendet." );
     912                 :            :     sal_uInt16 nNextDepth =
     913 [ #  # ][ #  # ]:          0 :         (bSameRule && !rNextInfo.IsRestart()) ? rNextInfo.GetDepth() : 0;
     914                 :            : 
     915                 :            :     // MIB 23.7.97: Die Schleife muss doch rueckwaerts durchlaufen
     916                 :            :     // werden, weil die Reihenfolge von </OL>/</UL> stimmen muss
     917         [ #  # ]:          0 :     for( sal_uInt16 i=rInfo.GetDepth(); i>nNextDepth; i-- )
     918                 :            :     {
     919                 :          0 :         rWrt.DecIndentLevel(); // Inhalt von <OL> einruecken
     920         [ #  # ]:          0 :         if( rWrt.bLFPossible )
     921                 :          0 :             rWrt.OutNewLine(); // </OL>/</UL> in eine neue Zeile
     922                 :            : 
     923                 :            :         // es wird also eine Liste angefangen oder beendet:
     924                 :          0 :         sal_Int16 eType = rInfo.GetNumRule()->Get( i-1 ).GetNumberingType();
     925                 :            :         const sal_Char *pStr;
     926 [ #  # ][ #  # ]:          0 :         if( SVX_NUM_CHAR_SPECIAL == eType || SVX_NUM_BITMAP == eType)
     927                 :          0 :             pStr = OOO_STRING_SVTOOLS_HTML_unorderlist;
     928                 :            :         else
     929                 :          0 :             pStr = OOO_STRING_SVTOOLS_HTML_orderlist;
     930                 :          0 :         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), pStr, sal_False );
     931                 :          0 :         rWrt.bLFPossible = sal_True;
     932                 :            :     }
     933                 :            : 
     934                 :          0 :     return rWrt;
     935                 :            : }
     936                 :            : 
     937                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10