LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/html - htmlcss1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 1183 0.4 %
Date: 2012-12-27 Functions: 3 49 6.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "hintids.hxx"
      21             : #include <svl/itemiter.hxx>
      22             : #include <svl/whiter.hxx>
      23             : #include <svl/urihelper.hxx>
      24             : #include <i18npool/languagetag.hxx>
      25             : #include <sfx2/docfile.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <editeng/fhgtitem.hxx>
      28             : #include <editeng/brshitem.hxx>
      29             : #include <editeng/lrspitem.hxx>
      30             : #include <editeng/ulspitem.hxx>
      31             : #include <editeng/boxitem.hxx>
      32             : #include <editeng/flstitem.hxx>
      33             : #include <editeng/brkitem.hxx>
      34             : #include <editeng/keepitem.hxx>
      35             : #include <editeng/fontitem.hxx>
      36             : #include <editeng/langitem.hxx>
      37             : #include <editeng/frmdiritem.hxx>
      38             : #include <svtools/htmltokn.h>
      39             : #include <svtools/htmlkywd.hxx>
      40             : #include <fmtpdsc.hxx>
      41             : #include <fmtanchr.hxx>
      42             : #include <fmtornt.hxx>
      43             : #include <fmtsrnd.hxx>
      44             : #include <fmtfsize.hxx>
      45             : #include "frmatr.hxx"
      46             : #include <charfmt.hxx>
      47             : #include <docary.hxx>
      48             : #include <svx/svxids.hrc>
      49             : 
      50             : #include "doc.hxx"
      51             : #include "pam.hxx"
      52             : #include "ndtxt.hxx"
      53             : #include "poolfmt.hxx"
      54             : #include "docsh.hxx"
      55             : #include "paratr.hxx"
      56             : #include "pagedesc.hxx"
      57             : #include "css1kywd.hxx"
      58             : #include "swcss1.hxx"
      59             : #include "htmlnum.hxx"
      60             : #include "swhtml.hxx"
      61             : #include <numrule.hxx>
      62             : 
      63             : using namespace ::com::sun::star;
      64             : 
      65             : 
      66             : // Wie viele Zeilen/Zeichen sind fuer DropCaps erlaubt?
      67             : // (Gibt es vielleicht woanders entsprechende Werte?)
      68             : #define MAX_DROPCAP_LINES 9
      69             : #define MAX_DROPCAP_CHARS 9
      70             : 
      71             : static void lcl_swcss1_setEncoding( SwFmt& rFmt, rtl_TextEncoding eEnc );
      72             : 
      73             : 
      74             : // Implementierung des SwCSS1Parsers (eigentlich swcss1.cxx)
      75             : static struct SwCSS1ItemIds
      76             : {
      77             :     sal_uInt16 nFmtBreak;
      78             :     sal_uInt16 nFmtPageDesc;
      79             :     sal_uInt16 nFmtKeep;
      80             : 
      81          10 :     SwCSS1ItemIds() :
      82             :         nFmtBreak( RES_BREAK ),
      83             :         nFmtPageDesc( RES_PAGEDESC ),
      84          10 :         nFmtKeep( RES_KEEP )
      85          10 :     {}
      86             : 
      87          10 : } aItemIds;
      88             : 
      89           0 : void SwCSS1Parser::ChgPageDesc( const SwPageDesc *pPageDesc,
      90             :                                 const SwPageDesc& rNewPageDesc )
      91             : {
      92           0 :     sal_uInt16 nPageDescs = pDoc->GetPageDescCnt();
      93             :     sal_uInt16 i;
      94           0 :     for( i=0; i<nPageDescs; i++ )
      95           0 :         if( pPageDesc == &pDoc->GetPageDesc(i) )
      96             :         {
      97           0 :             pDoc->ChgPageDesc( i, rNewPageDesc );
      98           0 :             return;
      99             :         }
     100             : 
     101             :     OSL_ENSURE( i<nPageDescs, "Seitenvorlage nicht gefunden" );
     102             : }
     103             : 
     104           0 : SwCSS1Parser::SwCSS1Parser( SwDoc *pD, sal_uInt32 aFHeights[7], const String& rBaseURL, sal_Bool bNewDoc ) :
     105           0 :     SvxCSS1Parser( pD->GetAttrPool(), rBaseURL, MM50/2,
     106             :                    (sal_uInt16*)&aItemIds, sizeof(aItemIds) / sizeof(sal_uInt16) ),
     107             :     pDoc( pD ),
     108             :     nDropCapCnt( 0 ),
     109             :     bIsNewDoc( bNewDoc ),
     110             :     bBodyBGColorSet( sal_False ),
     111             :     bBodyBackgroundSet( sal_False ),
     112             :     bBodyTextSet( sal_False ),
     113             :     bBodyLinkSet( sal_False ),
     114             :     bBodyVLinkSet( sal_False ),
     115             :     bSetFirstPageDesc( sal_False ),
     116             :     bSetRightPageDesc( sal_False ),
     117             :     bTableHeaderTxtCollSet( sal_False ),
     118             :     bTableTxtCollSet( sal_False ),
     119           0 :     bLinkCharFmtsSet( sal_False )
     120             : {
     121           0 :     aFontHeights[0] = aFHeights[0];
     122           0 :     aFontHeights[1] = aFHeights[1];
     123           0 :     aFontHeights[2] = aFHeights[2];
     124           0 :     aFontHeights[3] = aFHeights[3];
     125           0 :     aFontHeights[4] = aFHeights[4];
     126           0 :     aFontHeights[5] = aFHeights[5];
     127           0 :     aFontHeights[6] = aFHeights[6];
     128           0 : }
     129             : 
     130           0 : SwCSS1Parser::~SwCSS1Parser()
     131             : {
     132           0 : }
     133             : 
     134             : 
     135             : 
     136             : // Feature: PrintExt
     137           0 : sal_Bool SwCSS1Parser::SetFmtBreak( SfxItemSet& rItemSet,
     138             :                                 const SvxCSS1PropertyInfo& rPropInfo )
     139             : {
     140           0 :     SvxBreak eBreak = SVX_BREAK_NONE;
     141           0 :     sal_Bool bKeep = sal_False;
     142           0 :     sal_Bool bSetKeep = sal_False, bSetBreak = sal_False, bSetPageDesc = sal_False;
     143           0 :     const SwPageDesc *pPageDesc = 0;
     144           0 :     switch( rPropInfo.ePageBreakBefore )
     145             :     {
     146             :     case SVX_CSS1_PBREAK_ALWAYS:
     147           0 :         eBreak = SVX_BREAK_PAGE_BEFORE;
     148           0 :         bSetBreak = sal_True;
     149           0 :         break;
     150             :     case SVX_CSS1_PBREAK_LEFT:
     151           0 :         pPageDesc = GetLeftPageDesc( sal_True );
     152           0 :         bSetPageDesc = sal_True;
     153           0 :         break;
     154             :     case SVX_CSS1_PBREAK_RIGHT:
     155           0 :         pPageDesc = GetRightPageDesc( sal_True );
     156           0 :         bSetPageDesc = sal_True;
     157           0 :         break;
     158             :     case SVX_CSS1_PBREAK_AUTO:
     159           0 :         bSetBreak = bSetPageDesc = sal_True;
     160           0 :         break;
     161             :     default:
     162             :         ;
     163             :     }
     164           0 :     switch( rPropInfo.ePageBreakAfter )
     165             :     {
     166             :     case SVX_CSS1_PBREAK_ALWAYS:
     167             :     case SVX_CSS1_PBREAK_LEFT:
     168             :     case SVX_CSS1_PBREAK_RIGHT:
     169             :         // LEFT/RIGHT koennte man auch am Absatz davor setzen
     170           0 :         eBreak = SVX_BREAK_PAGE_AFTER;
     171           0 :         bSetBreak = sal_True;
     172           0 :         break;
     173             :     case SVX_CSS1_PBREAK_AUTO:
     174           0 :         bSetBreak = bSetKeep = bSetPageDesc = sal_True;
     175           0 :         break;
     176             :     case SVX_CSS1_PBREAK_AVOID:
     177           0 :         bKeep = bSetKeep = sal_True;
     178           0 :         break;
     179             :     default:
     180             :         ;
     181             :     }
     182             : 
     183           0 :     if( bSetBreak )
     184           0 :         rItemSet.Put( SvxFmtBreakItem( eBreak, RES_BREAK ) );
     185           0 :     if( bSetPageDesc )
     186           0 :         rItemSet.Put( SwFmtPageDesc( pPageDesc ) );
     187           0 :     if( bSetKeep )
     188           0 :         rItemSet.Put( SvxFmtKeepItem( bKeep, RES_KEEP ) );
     189             : 
     190           0 :     return bSetBreak;
     191             : }
     192             : // /Feature: PrintExt
     193             : 
     194           0 : static void SetCharFmtAttrs( SwCharFmt *pCharFmt, SfxItemSet& rItemSet )
     195             : {
     196             :     const SfxPoolItem *pItem;
     197             :     static sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
     198             :                                    RES_CHRATR_CTL_FONTSIZE };
     199           0 :        for( sal_uInt16 i=0; i<3; i++ )
     200             :     {
     201           0 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aWhichIds[i], sal_False,
     202           0 :                                                    &pItem ) &&
     203           0 :             ((const SvxFontHeightItem *)pItem)->GetProp() != 100)
     204             :         {
     205             :             // %-Angaben beim FontHeight-Item werden nicht unterstuetzt
     206           0 :             rItemSet.ClearItem( aWhichIds[i] );
     207             :         }
     208             :     }
     209             : 
     210           0 :     pCharFmt->SetFmtAttr( rItemSet );
     211             : 
     212           0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
     213             :     {
     214             :         // Ein Brush-Item mit RES_BACKGROUND muss noch in eines mit
     215             :         // RES_CHRATR_BACKGROUND gewandelt werden
     216             : 
     217           0 :         SvxBrushItem aBrushItem( *(const SvxBrushItem *)pItem );
     218           0 :         aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
     219           0 :         pCharFmt->SetFmtAttr( aBrushItem );
     220             :     }
     221           0 : }
     222             : 
     223           0 : void SwCSS1Parser::SetLinkCharFmts()
     224             : {
     225             :     OSL_ENSURE( !bLinkCharFmtsSet, "Aufruf von SetLinkCharFmts unnoetig" );
     226             : 
     227             :     SvxCSS1MapEntry *pStyleEntry =
     228           0 :         GetTag( rtl::OUString(OOO_STRING_SVTOOLS_HTML_anchor) );
     229           0 :     SwCharFmt *pUnvisited = 0, *pVisited = 0;
     230           0 :     if( pStyleEntry )
     231             :     {
     232           0 :         SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
     233             :         sal_Bool bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
     234           0 :                                                               sal_False));
     235           0 :         pUnvisited = GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL );
     236           0 :         SetCharFmtAttrs( pUnvisited, rItemSet );
     237           0 :         bBodyLinkSet |= bColorSet;
     238             : 
     239           0 :         pVisited = GetCharFmtFromPool( RES_POOLCHR_INET_VISIT );
     240           0 :         SetCharFmtAttrs( pVisited, rItemSet );
     241           0 :         bBodyVLinkSet |= bColorSet;
     242             :     }
     243             : 
     244           0 :     String sTmp( rtl::OUString(OOO_STRING_SVTOOLS_HTML_anchor) );
     245           0 :     sTmp.Append( ':' );
     246           0 :     sTmp.AppendAscii( sCSS1_link );
     247           0 :     pStyleEntry = GetTag( sTmp );
     248           0 :     if( pStyleEntry )
     249             :     {
     250           0 :         SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
     251             :         sal_Bool bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
     252           0 :                                                               sal_False));
     253           0 :         if( !pUnvisited )
     254           0 :             pUnvisited = GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL );
     255           0 :         SetCharFmtAttrs( pUnvisited, rItemSet );
     256           0 :         bBodyLinkSet |= bColorSet;
     257             :     }
     258             : 
     259           0 :     sTmp.AssignAscii( OOO_STRING_SVTOOLS_HTML_anchor );
     260           0 :     sTmp.Assign( ':' );
     261           0 :     sTmp.AppendAscii( sCSS1_visited );
     262           0 :     pStyleEntry = GetTag( sTmp );
     263           0 :     if( pStyleEntry )
     264             :     {
     265           0 :         SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
     266             :         sal_Bool bColorSet = (SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
     267           0 :                                                               sal_False));
     268           0 :         if( !pVisited )
     269           0 :             pVisited = GetCharFmtFromPool( RES_POOLCHR_INET_VISIT );
     270           0 :         SetCharFmtAttrs( pVisited, rItemSet );
     271           0 :         bBodyVLinkSet |= bColorSet;
     272             :     }
     273             : 
     274           0 :     bLinkCharFmtsSet = sal_True;
     275           0 : }
     276             : 
     277           0 : static void SetTxtCollAttrs( SwTxtFmtColl *pColl, SfxItemSet& rItemSet,
     278             :                              SvxCSS1PropertyInfo& rPropInfo,
     279             :                              SwCSS1Parser *pCSS1Parser )
     280             : {
     281           0 :     const SfxItemSet& rCollItemSet = pColl->GetAttrSet();
     282             :     const SfxPoolItem *pCollItem, *pItem;
     283             : 
     284             :     // linker, rechter Rand und Erstzeilen-Einzug
     285           0 :     if( (rPropInfo.bLeftMargin || rPropInfo.bRightMargin ||
     286             :          rPropInfo.bTextIndent) &&
     287           0 :         (!rPropInfo.bLeftMargin || !rPropInfo.bRightMargin ||
     288           0 :          !rPropInfo.bTextIndent) &&
     289           0 :         SFX_ITEM_SET == rCollItemSet.GetItemState(RES_LR_SPACE,sal_True,&pCollItem) &&
     290           0 :         SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,sal_False,&pItem) )
     291             :     {
     292           0 :         const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
     293             : 
     294           0 :         SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem *)pCollItem) );
     295           0 :         if( rPropInfo.bLeftMargin )
     296           0 :             aLRItem.SetTxtLeft( pLRItem->GetTxtLeft() );
     297           0 :         if( rPropInfo.bRightMargin )
     298           0 :             aLRItem.SetRight( pLRItem->GetRight() );
     299           0 :         if( rPropInfo.bTextIndent )
     300           0 :             aLRItem.SetTxtFirstLineOfst( pLRItem->GetTxtFirstLineOfst() );
     301             : 
     302           0 :         rItemSet.Put( aLRItem );
     303             :     }
     304             : 
     305             :     // oberer und unterer Rand
     306           0 :     if( (rPropInfo.bTopMargin || rPropInfo.bBottomMargin) &&
     307           0 :         (!rPropInfo.bTopMargin || !rPropInfo.bBottomMargin) &&
     308             :         SFX_ITEM_SET == rCollItemSet.GetItemState(RES_UL_SPACE,sal_True,
     309           0 :                                                   &pCollItem) &&
     310           0 :         SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,sal_False,&pItem) )
     311             :     {
     312           0 :         const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
     313             : 
     314           0 :         SvxULSpaceItem aULItem( *((const SvxULSpaceItem *)pCollItem) );
     315           0 :         if( rPropInfo.bTopMargin )
     316           0 :             aULItem.SetUpper( pULItem->GetUpper() );
     317           0 :         if( rPropInfo.bBottomMargin )
     318           0 :             aULItem.SetLower( pULItem->GetLower() );
     319             : 
     320           0 :         rItemSet.Put( aULItem );
     321             :     }
     322             : 
     323             :     static sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
     324             :                                    RES_CHRATR_CTL_FONTSIZE };
     325           0 :        for( sal_uInt16 i=0; i<3; i++ )
     326             :     {
     327           0 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aWhichIds[i], sal_False,
     328           0 :                                                    &pItem ) &&
     329           0 :             ((const SvxFontHeightItem *)pItem)->GetProp() != 100)
     330             :         {
     331             :             // %-Angaben beim FontHeight-Item werden nicht unterstuetzt
     332           0 :             rItemSet.ClearItem( aWhichIds[i] );
     333             :         }
     334             :     }
     335             : 
     336             : // Feature: PrintExt
     337           0 :     pCSS1Parser->SetFmtBreak( rItemSet, rPropInfo );
     338             : // /Feature: PrintExt
     339             : 
     340           0 :     pColl->SetFmtAttr( rItemSet );
     341           0 : }
     342             : 
     343           0 : void SwCSS1Parser::SetTableTxtColl( sal_Bool bHeader )
     344             : {
     345             :     OSL_ENSURE( !(bHeader ? bTableHeaderTxtCollSet : bTableTxtCollSet),
     346             :             "Aufruf von SetTableTxtColl unnoetig" );
     347             : 
     348             :     sal_uInt16 nPoolId;
     349           0 :     String sTag;
     350           0 :     if( bHeader )
     351             :     {
     352           0 :         nPoolId = RES_POOLCOLL_TABLE_HDLN;
     353           0 :         sTag.AssignAscii( OOO_STRING_SVTOOLS_HTML_tableheader );
     354             :     }
     355             :     else
     356             :     {
     357           0 :         nPoolId = RES_POOLCOLL_TABLE;
     358           0 :         sTag.AssignAscii( OOO_STRING_SVTOOLS_HTML_tabledata );
     359             :     }
     360             : 
     361           0 :     SwTxtFmtColl *pColl = 0;
     362             : 
     363             :     // The following entries will never be used again and may be changed.
     364           0 :     SvxCSS1MapEntry *pStyleEntry = GetTag( sTag );
     365           0 :     if( pStyleEntry )
     366             :     {
     367           0 :         pColl = GetTxtFmtColl( nPoolId, aEmptyStr );
     368           0 :         SetTxtCollAttrs( pColl, pStyleEntry->GetItemSet(),
     369           0 :                          pStyleEntry->GetPropertyInfo(), this );
     370             :     }
     371             : 
     372           0 :     String sTmp( sTag );
     373           0 :     sTmp.Append( ' ' );
     374           0 :     sTmp.AppendAscii( OOO_STRING_SVTOOLS_HTML_parabreak );
     375           0 :     pStyleEntry = GetTag( sTmp );
     376           0 :     if( pStyleEntry )
     377             :     {
     378           0 :         if( !pColl )
     379           0 :             pColl = GetTxtFmtColl( nPoolId, aEmptyStr );
     380           0 :         SetTxtCollAttrs( pColl, pStyleEntry->GetItemSet(),
     381           0 :                          pStyleEntry->GetPropertyInfo(), this );
     382             :     }
     383             : 
     384           0 :     if( bHeader )
     385           0 :         bTableHeaderTxtCollSet = sal_True;
     386             :     else
     387           0 :         bTableTxtCollSet = sal_True;
     388           0 : }
     389             : 
     390           0 : void SwCSS1Parser::SetPageDescAttrs( const SvxBrushItem *pBrush,
     391             :                                      SfxItemSet *pItemSet2 )
     392             : {
     393           0 :     SvxBrushItem aBrushItem( RES_BACKGROUND );
     394           0 :     SvxBoxItem aBoxItem( RES_BOX );
     395           0 :     SvxFrameDirectionItem aFrmDirItem(FRMDIR_ENVIRONMENT, RES_FRAMEDIR);
     396           0 :     sal_Bool bSetBrush = pBrush!=0, bSetBox = sal_False, bSetFrmDir = sal_False;
     397           0 :     if( pBrush )
     398           0 :         aBrushItem = *pBrush;
     399             : 
     400           0 :     if( pItemSet2 )
     401             :     {
     402           0 :         const SfxPoolItem *pItem = 0;
     403           0 :         if( SFX_ITEM_SET == pItemSet2->GetItemState( RES_BACKGROUND, sal_False,
     404           0 :                                                    &pItem ) )
     405             :         {
     406             :             // ein Hintergrund wird gesetzt
     407           0 :             aBrushItem = *((const SvxBrushItem *)pItem);
     408           0 :             pItemSet2->ClearItem( RES_BACKGROUND );
     409           0 :             bSetBrush = sal_True;
     410             :         }
     411             : 
     412           0 :         if( SFX_ITEM_SET == pItemSet2->GetItemState( RES_BOX, sal_False, &pItem ) )
     413             :         {
     414             :             // eine Umrandung wird gesetzt
     415           0 :             aBoxItem = *((const SvxBoxItem *)pItem);
     416           0 :             pItemSet2->ClearItem( RES_BOX );
     417           0 :             bSetBox = sal_True;
     418             :         }
     419             : 
     420           0 :         if( SFX_ITEM_SET == pItemSet2->GetItemState( RES_BOX, sal_False, &pItem ) )
     421             :         {
     422             :             // eine Umrandung wird gesetzt
     423           0 :             aBoxItem = *((const SvxBoxItem *)pItem);
     424           0 :             pItemSet2->ClearItem( RES_BOX );
     425           0 :             bSetBox = sal_True;
     426             :         }
     427             : 
     428           0 :         if( SFX_ITEM_SET == pItemSet2->GetItemState( RES_FRAMEDIR, sal_False, &pItem ) )
     429             :         {
     430             :             // eine Umrandung wird gesetzt
     431           0 :             aFrmDirItem = *static_cast< const SvxFrameDirectionItem *>( pItem );
     432           0 :             pItemSet2->ClearItem( RES_FRAMEDIR );
     433           0 :             bSetFrmDir = sal_True;
     434             :         }
     435             :     }
     436             : 
     437           0 :     if( bSetBrush || bSetBox || bSetFrmDir )
     438             :     {
     439             :         static sal_uInt16 aPoolIds[] = { RES_POOLPAGE_HTML, RES_POOLPAGE_FIRST,
     440             :                                      RES_POOLPAGE_LEFT, RES_POOLPAGE_RIGHT };
     441           0 :         for( sal_uInt16 i=0; i<4; i++ )
     442             :         {
     443           0 :             const SwPageDesc *pPageDesc = GetPageDesc( aPoolIds[i], sal_False );
     444           0 :             if( pPageDesc )
     445             :             {
     446           0 :                 SwPageDesc aNewPageDesc( *pPageDesc );
     447           0 :                 SwFrmFmt &rMaster = aNewPageDesc.GetMaster();
     448           0 :                 if( bSetBrush )
     449           0 :                     rMaster.SetFmtAttr( aBrushItem );
     450           0 :                 if( bSetBox )
     451           0 :                     rMaster.SetFmtAttr( aBoxItem );
     452           0 :                 if( bSetFrmDir )
     453           0 :                     rMaster.SetFmtAttr( aFrmDirItem );
     454             : 
     455           0 :                 ChgPageDesc( pPageDesc, aNewPageDesc );
     456             :             }
     457             :         }
     458           0 :     }
     459           0 : }
     460             : 
     461             : // Feature: PrintExt
     462           0 : void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc,
     463             :                                      SfxItemSet& rItemSet,
     464             :                                      const SvxCSS1PropertyInfo& rPropInfo )
     465             : {
     466           0 :     if( !pPageDesc )
     467           0 :         return;
     468             : 
     469           0 :     SwPageDesc aNewPageDesc( *pPageDesc );
     470           0 :     SwFrmFmt &rMaster = aNewPageDesc.GetMaster();
     471           0 :     const SfxItemSet& rPageItemSet = rMaster.GetAttrSet();
     472             :     const SfxPoolItem *pPageItem, *pItem;
     473           0 :     sal_Bool bChanged = sal_False;
     474             : 
     475             :     // linker, rechter Rand und Erstzeilen-Einzug
     476           0 :     if( (rPropInfo.bLeftMargin || rPropInfo.bRightMargin) &&
     477           0 :         SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,sal_False,&pItem) )
     478             :     {
     479           0 :         if( (!rPropInfo.bLeftMargin || !rPropInfo.bRightMargin) &&
     480             :             SFX_ITEM_SET == rPageItemSet.GetItemState(RES_LR_SPACE,
     481           0 :                                                       sal_True,&pPageItem) )
     482             :         {
     483           0 :             const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
     484             : 
     485           0 :             SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem *)pPageItem) );
     486           0 :             if( rPropInfo.bLeftMargin )
     487           0 :                 aLRItem.SetLeft( pLRItem->GetLeft() );
     488           0 :             if( rPropInfo.bRightMargin )
     489           0 :                 aLRItem.SetRight( pLRItem->GetRight() );
     490             : 
     491           0 :             rMaster.SetFmtAttr( aLRItem );
     492             :         }
     493             :         else
     494             :         {
     495           0 :             rMaster.SetFmtAttr( *pItem );
     496             :         }
     497           0 :         bChanged = sal_True;
     498             :     }
     499             : 
     500             :     // oberer und unterer Rand
     501           0 :     if( (rPropInfo.bTopMargin || rPropInfo.bBottomMargin) &&
     502           0 :         SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,sal_False,&pItem) )
     503             :     {
     504           0 :         if( (!rPropInfo.bTopMargin || !rPropInfo.bBottomMargin) &&
     505             :             SFX_ITEM_SET == rPageItemSet.GetItemState(RES_UL_SPACE,
     506           0 :                                                       sal_True,&pPageItem) )
     507             :         {
     508           0 :             const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
     509             : 
     510           0 :             SvxULSpaceItem aULItem( *((const SvxULSpaceItem *)pPageItem) );
     511           0 :             if( rPropInfo.bTopMargin )
     512           0 :                 aULItem.SetUpper( pULItem->GetUpper() );
     513           0 :             if( rPropInfo.bBottomMargin )
     514           0 :                 aULItem.SetLower( pULItem->GetLower() );
     515             : 
     516           0 :             rMaster.SetFmtAttr( aULItem );
     517             :         }
     518             :         else
     519             :         {
     520           0 :             rMaster.SetFmtAttr( *pItem );
     521             :         }
     522           0 :         bChanged = sal_True;
     523             :     }
     524             : 
     525             :     // die Groesse
     526           0 :     if( rPropInfo.eSizeType != SVX_CSS1_STYPE_NONE )
     527             :     {
     528           0 :         if( rPropInfo.eSizeType == SVX_CSS1_STYPE_TWIP )
     529             :         {
     530             :             rMaster.SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE, rPropInfo.nWidth,
     531           0 :                                            rPropInfo.nHeight ) );
     532           0 :             bChanged = sal_True;
     533             :         }
     534             :         else
     535             :         {
     536             :             // Bei "size: auto|portrait|landscape" bleibt die bisherige
     537             :             // Groesse der Vorlage erhalten. Bei "landscape" und "portrait"
     538             :             // wird das Landscape-Flag gesetzt und evtl. die Breite/Hoehe
     539             :             // vertauscht.
     540           0 :             SwFmtFrmSize aFrmSz( rMaster.GetFrmSize() );
     541           0 :             sal_Bool bLandscape = aNewPageDesc.GetLandscape();
     542           0 :             if( ( bLandscape &&
     543             :                   rPropInfo.eSizeType == SVX_CSS1_STYPE_PORTRAIT ) ||
     544             :                 ( !bLandscape &&
     545             :                   rPropInfo.eSizeType == SVX_CSS1_STYPE_LANDSCAPE ) )
     546             :             {
     547           0 :                 SwTwips nTmp = aFrmSz.GetHeight();
     548           0 :                 aFrmSz.SetHeight( aFrmSz.GetWidth() );
     549           0 :                 aFrmSz.SetWidth( nTmp );
     550           0 :                 rMaster.SetFmtAttr( aFrmSz );
     551           0 :                 aNewPageDesc.SetLandscape( !bLandscape );
     552           0 :                 bChanged = sal_True;
     553           0 :             }
     554             :         }
     555             :     }
     556             : 
     557             :     // Geht das wirklich?
     558           0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False, &pItem ) )
     559             :     {
     560             :         // eine Umrandung wird gesetzt
     561           0 :         rMaster.SetFmtAttr( *pItem );
     562           0 :         rItemSet.ClearItem( RES_BACKGROUND );
     563           0 :         bChanged = sal_True;
     564             :     }
     565             : 
     566           0 :     if( bChanged )
     567           0 :         ChgPageDesc( pPageDesc, aNewPageDesc );
     568             : }
     569             : // /Feature: PrintExt
     570             : 
     571           0 : const SvxBrushItem& SwCSS1Parser::GetPageDescBackground() const
     572             : {
     573           0 :     return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false )
     574           0 :         ->GetMaster().GetBackground();
     575             : }
     576             : 
     577           0 : sal_uInt16 SwCSS1Parser::GetScriptFromClass( String& rClass,
     578             :                                       sal_Bool bSubClassOnly )
     579             : {
     580           0 :     sal_uInt16 nScriptFlags = CSS1_SCRIPT_ALL;
     581           0 :     xub_StrLen nLen = rClass.Len();
     582           0 :     xub_StrLen nPos = nLen > 4 ? rClass.SearchBackward( '-' ) : STRING_NOTFOUND;
     583             : 
     584           0 :     if( STRING_NOTFOUND == nPos )
     585             :     {
     586           0 :         if( bSubClassOnly )
     587           0 :             return nScriptFlags;
     588           0 :         nPos = 0;
     589             :     }
     590             :     else
     591             :     {
     592           0 :         nPos++;
     593           0 :         nLen = nLen - nPos;
     594             :     }
     595             : 
     596           0 :     switch( nLen )
     597             :     {
     598             :     case 3:
     599           0 :         if( rClass.EqualsIgnoreCaseAscii( "cjk", nPos, 3 ) )
     600             :         {
     601           0 :             nScriptFlags = CSS1_SCRIPT_CJK;
     602             :         }
     603           0 :         else if( rClass.EqualsIgnoreCaseAscii( "ctl", nPos, 3 ) )
     604             :         {
     605           0 :             nScriptFlags = CSS1_SCRIPT_CTL;
     606             :         }
     607           0 :         break;
     608             :     case 7:
     609           0 :         if( rClass.EqualsIgnoreCaseAscii( "western", nPos, 7 ) )
     610             :         {
     611           0 :             nScriptFlags = CSS1_SCRIPT_WESTERN;
     612             :         }
     613           0 :         break;
     614             :     }
     615           0 :     if( CSS1_SCRIPT_ALL != nScriptFlags )
     616             :     {
     617           0 :         if( nPos )
     618             :         {
     619           0 :             rClass.Erase( nPos-1 );
     620             :         }
     621             :         else
     622             :         {
     623           0 :             rClass.Erase();
     624             :         }
     625             :     }
     626             : 
     627           0 :     return nScriptFlags;
     628             : }
     629             : 
     630           0 : static CSS1SelectorType GetTokenAndClass( const CSS1Selector *pSelector,
     631             :                               String& rToken, String& rClass,
     632             :                               sal_uInt16& rScriptFlags )
     633             : {
     634           0 :     rToken = pSelector->GetString();
     635           0 :     rClass.Erase();
     636           0 :     rScriptFlags = CSS1_SCRIPT_ALL;
     637             : 
     638           0 :     CSS1SelectorType eType = pSelector->GetType();
     639           0 :     if( CSS1_SELTYPE_ELEM_CLASS==eType  )
     640             :     {
     641           0 :         xub_StrLen nPos = rToken.Search( '.' );
     642             :         OSL_ENSURE( nPos != STRING_NOTFOUND, "kein Punkt in Class-Selektor???" );
     643           0 :         if( nPos != STRING_NOTFOUND )
     644             :         {
     645           0 :             rClass = rToken.Copy( nPos+1 );
     646           0 :             rToken.Erase( nPos );
     647             : 
     648           0 :             rScriptFlags = SwCSS1Parser::GetScriptFromClass( rClass, sal_False );
     649           0 :             if( !rClass.Len() )
     650           0 :                 eType = CSS1_SELTYPE_ELEMENT;
     651             :         }
     652             :     }
     653             : 
     654           0 :     rToken.ToUpperAscii();
     655           0 :     return eType;
     656             : }
     657             : 
     658             : extern bool swhtml_css1atr_equalFontItems( const SfxPoolItem& r1, const SfxPoolItem& r2 );
     659             : 
     660           0 : static void RemoveScriptItems( SfxItemSet& rItemSet, sal_uInt16 nScript,
     661             :                                const SfxItemSet *pParentItemSet = 0 )
     662             : {
     663             :     static sal_uInt16 aWhichIds[3][5] =
     664             :     {
     665             :         { RES_CHRATR_FONT, RES_CHRATR_FONTSIZE, RES_CHRATR_LANGUAGE,
     666             :             RES_CHRATR_POSTURE, RES_CHRATR_WEIGHT },
     667             :         { RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_LANGUAGE,
     668             :             RES_CHRATR_CJK_POSTURE, RES_CHRATR_CJK_WEIGHT },
     669             :         { RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_LANGUAGE,
     670             :             RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT }
     671             :     };
     672             : 
     673           0 :     sal_uInt16 aClearItems[3] = { sal_False, sal_False, sal_False };
     674           0 :     switch( nScript )
     675             :     {
     676             :     case CSS1_SCRIPT_WESTERN:
     677           0 :         aClearItems[1] = aClearItems[2] =  sal_True;
     678           0 :         break;
     679             :     case CSS1_SCRIPT_CJK:
     680           0 :         aClearItems[0] = aClearItems[2] =  sal_True;
     681           0 :         break;
     682             :     case CSS1_SCRIPT_CTL:
     683           0 :         aClearItems[0] = aClearItems[1] =  sal_True;
     684           0 :         break;
     685             :     case CSS1_SCRIPT_ALL:
     686           0 :         break;
     687             :     default:
     688             :         OSL_ENSURE( aClearItems[0], "unknown script type" );
     689           0 :         break;
     690             :        }
     691             : 
     692           0 :     for( sal_uInt16 j=0; j < 3; j++ )
     693             :     {
     694           0 :         for( sal_uInt16 i=0; i < 5; i++ )
     695             :         {
     696           0 :             sal_uInt16 nWhich = aWhichIds[j][i];
     697             :             const SfxPoolItem *pItem;
     698           0 :             if( aClearItems[j] ||
     699             :                 (pParentItemSet &&
     700           0 :                  SFX_ITEM_SET == rItemSet.GetItemState( nWhich, sal_False, &pItem ) &&
     701           0 :                  (0==i ? swhtml_css1atr_equalFontItems( *pItem, pParentItemSet->Get(nWhich, sal_True ) )
     702           0 :                         : *pItem == pParentItemSet->Get(nWhich, sal_True ) ) ) )
     703             :             {
     704           0 :                 rItemSet.ClearItem( nWhich );
     705             :             }
     706             :         }
     707             :     }
     708           0 : }
     709             : 
     710           0 : sal_Bool SwCSS1Parser::StyleParsed( const CSS1Selector *pSelector,
     711             :                                 SfxItemSet& rItemSet,
     712             :                                 SvxCSS1PropertyInfo& rPropInfo )
     713             : {
     714           0 :     if( !bIsNewDoc )
     715           0 :         return sal_True;
     716             : 
     717           0 :     CSS1SelectorType eSelType = pSelector->GetType();
     718           0 :     const CSS1Selector *pNext = pSelector->GetNext();
     719             : 
     720           0 :     if( CSS1_SELTYPE_ID==eSelType && !pNext )
     721             :     {
     722           0 :         InsertId( pSelector->GetString(), rItemSet, rPropInfo );
     723             :     }
     724           0 :     else if( CSS1_SELTYPE_CLASS==eSelType && !pNext )
     725             :     {
     726           0 :         String aClass( pSelector->GetString() );
     727           0 :         sal_uInt16 nScript = GetScriptFromClass( aClass );
     728           0 :         if( CSS1_SCRIPT_ALL != nScript )
     729             :         {
     730           0 :             SfxItemSet aScriptItemSet( rItemSet );
     731           0 :             RemoveScriptItems( aScriptItemSet, nScript );
     732           0 :             InsertClass( aClass, aScriptItemSet, rPropInfo );
     733             :         }
     734             :         else
     735             :         {
     736           0 :             InsertClass( aClass, rItemSet, rPropInfo );
     737           0 :         }
     738             :     }
     739           0 :     else if( CSS1_SELTYPE_PAGE==eSelType )
     740             :     {
     741           0 :         if( !pNext ||
     742           0 :             (CSS1_SELTYPE_PSEUDO == pNext->GetType() &&
     743           0 :             (pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_left) ||
     744           0 :              pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_right) ||
     745           0 :              pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_first)) ) )
     746             :         {
     747           0 :             String aName;
     748           0 :             if( pNext )
     749           0 :                 aName = pNext->GetString();
     750             :             InsertPage( aName,
     751             :                         pNext != 0,
     752           0 :                         rItemSet, rPropInfo );
     753             :         }
     754             :     }
     755             : 
     756           0 :     if( CSS1_SELTYPE_ELEMENT != eSelType &&
     757             :         CSS1_SELTYPE_ELEM_CLASS != eSelType)
     758           0 :         return sal_True;
     759             : 
     760             :     // Token und Class zu dem Selektor holen
     761           0 :     String aToken2, aClass;
     762             :     sal_uInt16 nScript;
     763           0 :     eSelType = GetTokenAndClass( pSelector, aToken2, aClass, nScript );
     764           0 :     int nToken2 = GetHTMLToken( aToken2 );
     765             : 
     766             :     // und noch ein ganz par Infos zum naechsten Element
     767             :     CSS1SelectorType eNextType = pNext ? pNext->GetType()
     768           0 :                                        : CSS1_SELTYPE_ELEMENT;
     769             : 
     770             :     // Erstmal ein par Spezialfaelle
     771           0 :     if( CSS1_SELTYPE_ELEMENT==eSelType )
     772             :     {
     773           0 :         switch( nToken2 )
     774             :         {
     775             :         case HTML_ANCHOR_ON:
     776           0 :             if( !pNext )
     777             :             {
     778           0 :                 InsertTag( aToken2, rItemSet, rPropInfo );
     779           0 :                 return sal_False;
     780             :             }
     781           0 :             else if( pNext && CSS1_SELTYPE_PSEUDO == eNextType )
     782             :             {
     783             :                 // vielleicht A:visited oder A:link
     784             : 
     785           0 :                 String aPseudo( pNext->GetString() );
     786           0 :                 aPseudo.ToLowerAscii();
     787             : 
     788           0 :                 sal_Bool bInsert = sal_False;
     789           0 :                 switch( aPseudo.GetChar( 0 ))
     790             :                 {
     791             :                     case 'l':
     792           0 :                         if( aPseudo.EqualsAscii(sCSS1_link) )
     793             :                         {
     794           0 :                             bInsert = sal_True;
     795             :                         }
     796           0 :                         break;
     797             :                     case 'v':
     798           0 :                         if( aPseudo.EqualsAscii(sCSS1_visited) )
     799             :                         {
     800           0 :                             bInsert = sal_True;
     801             :                         }
     802           0 :                         break;
     803             :                 }
     804           0 :                 if( bInsert )
     805             :                 {
     806           0 :                     String sTmp( aToken2 );
     807           0 :                     (sTmp += ':') += aPseudo;
     808           0 :                     if( CSS1_SCRIPT_ALL != nScript )
     809             :                     {
     810           0 :                         SfxItemSet aScriptItemSet( rItemSet );
     811           0 :                         RemoveScriptItems( aScriptItemSet, nScript );
     812           0 :                         InsertTag( sTmp, aScriptItemSet, rPropInfo );
     813             :                     }
     814             :                     else
     815             :                     {
     816           0 :                         InsertTag( sTmp, rItemSet, rPropInfo );
     817             :                     }
     818           0 :                     return sal_False;
     819           0 :                 }
     820             :             }
     821           0 :             break;
     822             :         case HTML_BODY_ON:
     823           0 :             if( !pNext )
     824             :             {
     825             :                 // BODY
     826             : 
     827             :                 // Den Hintergrund muessen wir vor dem Setzen abfragen,
     828             :                 // denn in SetPageDescAttrs wird er geloescht.
     829             :                 const SfxPoolItem *pItem;
     830           0 :                 if( SFX_ITEM_SET==rItemSet.GetItemState(RES_BACKGROUND,sal_False,&pItem) )
     831             :                 {
     832             :                     const SvxBrushItem *pBrushItem =
     833           0 :                         (const SvxBrushItem *)pItem;
     834             : 
     835             :                     /// Body has a background color, if it is not "no fill"/"auto fill"
     836           0 :                     if( pBrushItem->GetColor() != COL_TRANSPARENT )
     837           0 :                         bBodyBGColorSet = sal_True;
     838           0 :                     if( GPOS_NONE != pBrushItem->GetGraphicPos() )
     839           0 :                         bBodyBackgroundSet = sal_True;
     840             :                 }
     841             : 
     842             :                 // Border and Padding
     843           0 :                 rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
     844             : 
     845             :                 // Ein par Attribute muessen an der Seitenvorlage gesetzt werden,
     846             :                 // und zwar die, die nicht vererbt werden
     847           0 :                 SetPageDescAttrs( 0, &rItemSet );
     848             : 
     849             :                 // alle noch uebrigen Optionen koennen an der Standard-Vorlage
     850             :                 // gesetzt werden und gelten dann automatisch als defaults
     851           0 :                 if( SFX_ITEM_SET==rItemSet.GetItemState(RES_CHRATR_COLOR,sal_False) )
     852           0 :                     bBodyTextSet = sal_True;
     853             :                 SetTxtCollAttrs(
     854             :                     GetTxtCollFromPool( RES_POOLCOLL_STANDARD ),
     855           0 :                     rItemSet, rPropInfo, this );
     856             : 
     857           0 :                 return sal_False;
     858             :             }
     859           0 :             break;
     860             :         }
     861             :     }
     862           0 :     else if( CSS1_SELTYPE_ELEM_CLASS==eSelType &&  HTML_ANCHOR_ON==nToken2 &&
     863           0 :              !pNext && aClass.Len() >= 9 &&
     864           0 :              ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0)) )
     865             :     {
     866           0 :         sal_uInt16 nPoolFmtId = 0;
     867           0 :         if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdendnote_sym) )
     868           0 :             nPoolFmtId = RES_POOLCHR_ENDNOTE;
     869           0 :         else if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdfootnote_sym) )
     870           0 :             nPoolFmtId = RES_POOLCHR_FOOTNOTE;
     871           0 :         if( nPoolFmtId )
     872             :         {
     873           0 :             if( CSS1_SCRIPT_ALL == nScript )
     874             :             {
     875           0 :                 SetCharFmtAttrs( GetCharFmtFromPool(nPoolFmtId), rItemSet );
     876             :             }
     877             :             else
     878             :             {
     879           0 :                 SfxItemSet aScriptItemSet( rItemSet );
     880           0 :                 RemoveScriptItems( aScriptItemSet, nScript );
     881             :                 SetCharFmtAttrs( GetCharFmtFromPool(nPoolFmtId),
     882           0 :                                  aScriptItemSet);
     883             :             }
     884           0 :             return sal_False;
     885             :         }
     886             :     }
     887             : 
     888             :     // Jetzt werden die Selektoren verarbeitet, die zu einer Absatz-Vorlage
     889             :     // gehoehren
     890           0 :     sal_uInt16 nPoolCollId = 0;
     891           0 :     switch( nToken2 )
     892             :     {
     893             :     case HTML_HEAD1_ON:
     894           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE1;
     895           0 :         break;
     896             :     case HTML_HEAD2_ON:
     897           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE2;
     898           0 :         break;
     899             :     case HTML_HEAD3_ON:
     900           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE3;
     901           0 :         break;
     902             :     case HTML_HEAD4_ON:
     903           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE4;
     904           0 :         break;
     905             :     case HTML_HEAD5_ON:
     906           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE5;
     907           0 :         break;
     908             :     case HTML_HEAD6_ON:
     909           0 :         nPoolCollId = RES_POOLCOLL_HEADLINE6;
     910           0 :         break;
     911             :     case HTML_PARABREAK_ON:
     912           0 :         if( aClass.Len() >= 9 &&
     913           0 :             ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0)) )
     914             :         {
     915           0 :             if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdendnote) )
     916           0 :                 nPoolCollId = RES_POOLCOLL_ENDNOTE;
     917           0 :             else if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
     918           0 :                 nPoolCollId = RES_POOLCOLL_FOOTNOTE;
     919             : 
     920           0 :             if( nPoolCollId )
     921           0 :                 aClass = aEmptyStr;
     922             :             else
     923           0 :                 nPoolCollId = RES_POOLCOLL_TEXT;
     924             :         }
     925             :         else
     926             :         {
     927           0 :             nPoolCollId = RES_POOLCOLL_TEXT;
     928             :         }
     929           0 :         break;
     930             :     case HTML_ADDRESS_ON:
     931           0 :         nPoolCollId = RES_POOLCOLL_SENDADRESS;
     932           0 :         break;
     933             :     case HTML_BLOCKQUOTE_ON:
     934           0 :         nPoolCollId = RES_POOLCOLL_HTML_BLOCKQUOTE;
     935           0 :         break;
     936             :     case HTML_DT_ON:
     937           0 :         nPoolCollId = RES_POOLCOLL_HTML_DT;
     938           0 :         break;
     939             :     case HTML_DD_ON:
     940           0 :         nPoolCollId = RES_POOLCOLL_HTML_DD;
     941           0 :         break;
     942             :     case HTML_PREFORMTXT_ON:
     943           0 :         nPoolCollId = RES_POOLCOLL_HTML_PRE;
     944           0 :         break;
     945             :     case HTML_TABLEHEADER_ON:
     946             :     case HTML_TABLEDATA_ON:
     947           0 :         if( CSS1_SELTYPE_ELEMENT==eSelType && !pNext )
     948             :         {
     949           0 :             InsertTag( aToken2, rItemSet, rPropInfo );
     950           0 :             return sal_False;
     951             :         }
     952           0 :         else if( CSS1_SELTYPE_ELEMENT==eSelType && pNext &&
     953             :                  (CSS1_SELTYPE_ELEMENT==eNextType ||
     954             :                   CSS1_SELTYPE_ELEM_CLASS==eNextType) )
     955             :         {
     956             :             // nicht TH und TD, aber TH P und TD P
     957           0 :             String aSubToken, aSubClass;
     958           0 :             GetTokenAndClass( pNext, aSubToken, aSubClass, nScript );
     959           0 :             if( HTML_PARABREAK_ON == GetHTMLToken( aSubToken ) )
     960             :             {
     961           0 :                 aClass = aSubClass;
     962           0 :                 pNext = pNext->GetNext();
     963           0 :                 eNextType = pNext ? pNext->GetType() : CSS1_SELTYPE_ELEMENT;
     964             : 
     965           0 :                 if( aClass.Len() || pNext )
     966             :                 {
     967             :                     nPoolCollId = static_cast< sal_uInt16 >(
     968             :                         HTML_TABLEHEADER_ON == nToken2 ? RES_POOLCOLL_TABLE_HDLN
     969           0 :                                                       : RES_POOLCOLL_TABLE );
     970             :                 }
     971             :                 else
     972             :                 {
     973           0 :                     String sTmp( aToken2 );
     974           0 :                     sTmp += ' ';
     975           0 :                     sTmp.AppendAscii( OOO_STRING_SVTOOLS_HTML_parabreak );
     976             : 
     977           0 :                     if( CSS1_SCRIPT_ALL == nScript )
     978             :                     {
     979           0 :                         InsertTag( sTmp, rItemSet, rPropInfo );
     980             :                     }
     981             :                     else
     982             :                     {
     983           0 :                         SfxItemSet aScriptItemSet( rItemSet );
     984           0 :                         RemoveScriptItems( aScriptItemSet, nScript );
     985           0 :                         InsertTag( sTmp, aScriptItemSet, rPropInfo );
     986             :                     }
     987             : 
     988           0 :                     return sal_False;
     989             :                 }
     990           0 :             }
     991             :         }
     992           0 :         break;
     993             : 
     994             :         default:
     995             :             ;
     996             :     }
     997             : 
     998           0 :     if( nPoolCollId )
     999             :     {
    1000           0 :         if( !pNext ||
    1001             :             (CSS1_SELTYPE_PSEUDO==eNextType &&
    1002           0 :              pNext->GetString().EqualsIgnoreCaseAscii(sCSS1_first_letter) &&
    1003             :              SVX_ADJUST_LEFT == rPropInfo.eFloat) )
    1004             :         {
    1005             :             // Entweder kein zusammengesetzter Selektor oder
    1006             :             // ein X:first-line { float: left; ... }
    1007             : 
    1008             :             // Die Vorlage Suchen bzw. Anlegen
    1009           0 :             SwTxtFmtColl *pColl = GetTxtFmtColl( nPoolCollId, aEmptyStr );
    1010           0 :             SwTxtFmtColl* pParentColl = 0;
    1011           0 :             if( aClass.Len() )
    1012             :             {
    1013           0 :                 String aName( pColl->GetName() );
    1014           0 :                 AddClassName( aName, aClass );
    1015             : 
    1016           0 :                 pParentColl = pColl;
    1017           0 :                 pColl = pDoc->FindTxtFmtCollByName( aName );
    1018           0 :                 if( !pColl )
    1019           0 :                     pColl = pDoc->MakeTxtFmtColl( aName, pParentColl );
    1020             :             }
    1021           0 :             if( !pNext )
    1022             :             {
    1023             :                 // nur die Attribute an der Vorlage setzen
    1024             :                 const SfxPoolItem *pItem;
    1025           0 :                 const SvxBoxItem *pBoxItem = 0;
    1026           0 :                 if( SFX_ITEM_SET ==
    1027           0 :                         pColl->GetAttrSet().GetItemState(RES_BOX,sal_True,&pItem) )
    1028           0 :                     pBoxItem = (const SvxBoxItem *)pItem;
    1029           0 :                 rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST, pBoxItem );
    1030           0 :                 if( CSS1_SCRIPT_ALL == nScript && !pParentColl )
    1031             :                 {
    1032           0 :                     SetTxtCollAttrs( pColl, rItemSet, rPropInfo, this );
    1033             :                 }
    1034             :                 else
    1035             :                 {
    1036           0 :                     SfxItemSet aScriptItemSet( rItemSet );
    1037             :                     RemoveScriptItems( aScriptItemSet, nScript,
    1038           0 :                                        pParentColl ? &pParentColl->GetAttrSet() : 0 );
    1039           0 :                     SetTxtCollAttrs( pColl, aScriptItemSet, rPropInfo, this );
    1040             :                 }
    1041             :             }
    1042             :             else
    1043             :             {
    1044             :                 // ein Drop-Cap-Attribut basteln
    1045           0 :                 SwFmtDrop aDrop( pColl->GetDrop() );
    1046           0 :                 aDrop.GetChars() = 1;
    1047             : 
    1048             :                 // die Attribute in das DropCap-Attribut einfuegen
    1049           0 :                 if( CSS1_SCRIPT_ALL == nScript )
    1050             :                 {
    1051           0 :                     FillDropCap( aDrop, rItemSet, &pColl->GetName() );
    1052             :                 }
    1053             :                 else
    1054             :                 {
    1055           0 :                     SfxItemSet aScriptItemSet( rItemSet );
    1056           0 :                     if( CSS1_SCRIPT_WESTERN != nScript )
    1057             :                     {
    1058           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_FONT );
    1059           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_LANGUAGE );
    1060           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_POSTURE );
    1061           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_WEIGHT );
    1062             :                     }
    1063           0 :                     if( CSS1_SCRIPT_CJK != nScript )
    1064             :                     {
    1065           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CJK_FONT );
    1066           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CJK_LANGUAGE );
    1067           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CJK_POSTURE );
    1068           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CJK_WEIGHT );
    1069             :                     }
    1070           0 :                     if( CSS1_SCRIPT_CTL != nScript )
    1071             :                     {
    1072           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CTL_FONT );
    1073           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CTL_LANGUAGE );
    1074           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CTL_POSTURE );
    1075           0 :                         aScriptItemSet.ClearItem( RES_CHRATR_CTL_WEIGHT );
    1076             :                     }
    1077           0 :                     FillDropCap( aDrop, aScriptItemSet, &pColl->GetName() );
    1078             :                 }
    1079             : 
    1080             :                 // Das Attribut nur setzen, wenn float: left angegeben wurde
    1081             :                 // und das Initial ueber mehrere Zeilen geht. Sonst wird die
    1082             :                 // ggf. angelegte Zeichen-Vorlage spaeter ueber den Namen
    1083             :                 // gesucht und gesetzt.
    1084           0 :                 if( aDrop.GetLines() > 1 &&
    1085             :                     (SVX_ADJUST_LEFT == rPropInfo.eFloat  ||
    1086             :                      CSS1_SCRIPT_ALL == nScript) )
    1087             :                 {
    1088           0 :                     pColl->SetFmtAttr( aDrop );
    1089           0 :                 }
    1090             :             }
    1091             : 
    1092           0 :             return sal_False;
    1093             :         }
    1094             : 
    1095           0 :         return sal_True;
    1096             :     }
    1097             : 
    1098             :     // Jetzt werden die Selektoten verarbeitet, die zu einer Zechenvorlage
    1099             :     // gehoehren. Zusammengesetzte gibt es hier allerdings nich nicht.
    1100           0 :     if( pNext )
    1101           0 :         return sal_True;
    1102             : 
    1103           0 :     SwCharFmt *pCFmt = GetChrFmt( static_cast< sal_uInt16 >(nToken2), aEmptyStr );
    1104           0 :     if( pCFmt )
    1105             :     {
    1106           0 :         SwCharFmt *pParentCFmt = 0;
    1107           0 :         if( aClass.Len() )
    1108             :         {
    1109           0 :             String aName( pCFmt->GetName() );
    1110           0 :             AddClassName( aName, aClass );
    1111           0 :             pParentCFmt = pCFmt;
    1112             : 
    1113           0 :             pCFmt = pDoc->FindCharFmtByName( aName );
    1114           0 :             if( !pCFmt )
    1115             :             {
    1116           0 :                 pCFmt = pDoc->MakeCharFmt( aName, pParentCFmt );
    1117           0 :                 pCFmt->SetAuto( false );
    1118           0 :             }
    1119             :         }
    1120             : 
    1121           0 :         if( CSS1_SCRIPT_ALL == nScript && !pParentCFmt )
    1122             :         {
    1123           0 :             SetCharFmtAttrs( pCFmt, rItemSet );
    1124             :         }
    1125             :         else
    1126             :         {
    1127           0 :             SfxItemSet aScriptItemSet( rItemSet );
    1128             :             RemoveScriptItems( aScriptItemSet, nScript,
    1129           0 :                                pParentCFmt ? &pParentCFmt->GetAttrSet() : 0 );
    1130           0 :             SetCharFmtAttrs( pCFmt, aScriptItemSet );
    1131             :         }
    1132           0 :         return sal_False;
    1133             :     }
    1134             : 
    1135           0 :     return sal_True;
    1136             : }
    1137             : 
    1138           0 : sal_uInt32 SwCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
    1139             : {
    1140           0 :     return aFontHeights[ nSize>6 ? 6 : nSize ];
    1141             : }
    1142             : 
    1143           0 : const FontList *SwCSS1Parser::GetFontList() const
    1144             : {
    1145           0 :     const FontList *pFList = 0;
    1146           0 :     SwDocShell *pDocSh = pDoc->GetDocShell();
    1147           0 :     if( pDocSh )
    1148             :     {
    1149             :         const SvxFontListItem *pFListItem =
    1150           0 :             (const SvxFontListItem *)pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
    1151           0 :         if( pFListItem )
    1152           0 :             pFList = pFListItem->GetFontList();
    1153             :     }
    1154             : 
    1155           0 :     return pFList;
    1156             : }
    1157             : 
    1158             : 
    1159           0 : SwCharFmt* SwCSS1Parser::GetChrFmt( sal_uInt16 nToken2, const String& rClass ) const
    1160             : {
    1161             :     // die entsprechende Vorlage suchen
    1162           0 :     sal_uInt16 nPoolId = 0;
    1163           0 :     const sal_Char* sName = 0;
    1164           0 :     switch( nToken2 )
    1165             :     {
    1166           0 :     case HTML_EMPHASIS_ON:      nPoolId = RES_POOLCHR_HTML_EMPHASIS;    break;
    1167           0 :     case HTML_CITIATION_ON:     nPoolId = RES_POOLCHR_HTML_CITIATION;   break;
    1168           0 :     case HTML_STRONG_ON:        nPoolId = RES_POOLCHR_HTML_STRONG;      break;
    1169           0 :     case HTML_CODE_ON:          nPoolId = RES_POOLCHR_HTML_CODE;        break;
    1170           0 :     case HTML_SAMPLE_ON:        nPoolId = RES_POOLCHR_HTML_SAMPLE;      break;
    1171           0 :     case HTML_KEYBOARD_ON:      nPoolId = RES_POOLCHR_HTML_KEYBOARD;    break;
    1172           0 :     case HTML_VARIABLE_ON:      nPoolId = RES_POOLCHR_HTML_VARIABLE;    break;
    1173           0 :     case HTML_DEFINSTANCE_ON:   nPoolId = RES_POOLCHR_HTML_DEFINSTANCE; break;
    1174           0 :     case HTML_TELETYPE_ON:      nPoolId = RES_POOLCHR_HTML_TELETYPE;    break;
    1175             : 
    1176           0 :     case HTML_SHORTQUOTE_ON:    sName = OOO_STRING_SVTOOLS_HTML_shortquote;     break;
    1177           0 :     case HTML_LANGUAGE_ON:      sName = OOO_STRING_SVTOOLS_HTML_language;   break;
    1178           0 :     case HTML_AUTHOR_ON:        sName = OOO_STRING_SVTOOLS_HTML_author;         break;
    1179           0 :     case HTML_PERSON_ON:        sName = OOO_STRING_SVTOOLS_HTML_person;         break;
    1180           0 :     case HTML_ACRONYM_ON:       sName = OOO_STRING_SVTOOLS_HTML_acronym;        break;
    1181           0 :     case HTML_ABBREVIATION_ON:  sName = OOO_STRING_SVTOOLS_HTML_abbreviation;   break;
    1182           0 :     case HTML_INSERTEDTEXT_ON:  sName = OOO_STRING_SVTOOLS_HTML_insertedtext;   break;
    1183           0 :     case HTML_DELETEDTEXT_ON:   sName = OOO_STRING_SVTOOLS_HTML_deletedtext;    break;
    1184             :     }
    1185             : 
    1186             :     // die Vorlage suchen oder anlegen (geht nur mit Namen)
    1187           0 :     if( !nPoolId && !sName )
    1188           0 :         return 0;
    1189             : 
    1190             :     // Die Vorlage (ohne Class) suchen oder anlegen
    1191           0 :     SwCharFmt *pCFmt = 0;
    1192           0 :     if( nPoolId )
    1193             :     {
    1194           0 :         pCFmt = GetCharFmtFromPool( nPoolId );
    1195             :     }
    1196             :     else
    1197             :     {
    1198           0 :         String sCName( rtl::OUString::createFromAscii(sName) );
    1199           0 :         pCFmt = pDoc->FindCharFmtByName( sCName );
    1200           0 :         if( !pCFmt )
    1201             :         {
    1202           0 :             pCFmt = pDoc->MakeCharFmt( sCName, pDoc->GetDfltCharFmt() );
    1203           0 :             pCFmt->SetAuto( false );
    1204           0 :         }
    1205             :     }
    1206             : 
    1207             :     OSL_ENSURE( pCFmt, "Keine Zeichen-Vorlage???" );
    1208             : 
    1209             :     // Wenn es eine Klasse gibt, die Klassen-Vorlage suchen aber nicht
    1210             :     // neu anlegen.
    1211           0 :     String aClass( rClass );
    1212           0 :     GetScriptFromClass( aClass, sal_False );
    1213           0 :     if( aClass.Len() )
    1214             :     {
    1215           0 :         String aTmp( pCFmt->GetName() );
    1216           0 :         AddClassName( aTmp, aClass );
    1217           0 :         SwCharFmt *pClassCFmt = pDoc->FindCharFmtByName( aTmp );
    1218           0 :         if( pClassCFmt )
    1219             :         {
    1220           0 :             pCFmt = pClassCFmt;
    1221             :         }
    1222             :         else
    1223             :         {
    1224           0 :             const SvxCSS1MapEntry *pClass = GetClass( aClass );
    1225           0 :             if( pClass )
    1226             :             {
    1227           0 :                 pCFmt = pDoc->MakeCharFmt( aTmp, pCFmt );
    1228           0 :                 pCFmt->SetAuto( false );
    1229           0 :                 SfxItemSet aItemSet( pClass->GetItemSet() );
    1230           0 :                 SetCharFmtAttrs( pCFmt, aItemSet );
    1231             :             }
    1232           0 :         }
    1233             :     }
    1234             : 
    1235           0 :     return pCFmt;
    1236             : }
    1237             : 
    1238             : 
    1239             : 
    1240           0 : SwTxtFmtColl *SwCSS1Parser::GetTxtCollFromPool( sal_uInt16 nPoolId ) const
    1241             : {
    1242           0 :     sal_uInt16 nOldArrLen = pDoc->GetTxtFmtColls()->size();
    1243             : 
    1244           0 :     SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool( nPoolId, false );
    1245             : 
    1246           0 :     if( bIsNewDoc )
    1247             :     {
    1248           0 :         sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->size();
    1249           0 :         for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ )
    1250           0 :             lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i],
    1251           0 :                                     GetDfltEncoding() );
    1252             :     }
    1253             : 
    1254           0 :     return pColl;
    1255             : }
    1256             : 
    1257           0 : SwCharFmt *SwCSS1Parser::GetCharFmtFromPool( sal_uInt16 nPoolId ) const
    1258             : {
    1259           0 :     sal_uInt16 nOldArrLen = pDoc->GetCharFmts()->size();
    1260             : 
    1261           0 :     SwCharFmt *pCharFmt = pDoc->GetCharFmtFromPool( nPoolId );
    1262             : 
    1263           0 :     if( bIsNewDoc )
    1264             :     {
    1265           0 :         sal_uInt16 nArrLen = pDoc->GetCharFmts()->size();
    1266             : 
    1267           0 :         for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ )
    1268           0 :             lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i],
    1269           0 :                                     GetDfltEncoding() );
    1270             :     }
    1271             : 
    1272           0 :     return pCharFmt;
    1273             : }
    1274             : 
    1275           0 : SwTxtFmtColl *SwCSS1Parser::GetTxtFmtColl( sal_uInt16 nTxtColl,
    1276             :                                            const String& rClass )
    1277             : {
    1278           0 :     SwTxtFmtColl* pColl = 0;
    1279             : 
    1280           0 :     String aClass( rClass );
    1281           0 :     GetScriptFromClass( aClass, sal_False );
    1282           0 :     if( RES_POOLCOLL_TEXT == nTxtColl && aClass.Len() >= 9 &&
    1283           0 :         ('s' == aClass.GetChar(0) || 'S' == aClass.GetChar(0) ) )
    1284             :     {
    1285           0 :         if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdendnote) )
    1286             :         {
    1287           0 :             nTxtColl = RES_POOLCOLL_ENDNOTE;
    1288           0 :             aClass = aEmptyStr;
    1289             :         }
    1290           0 :         else if( aClass.EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
    1291             :         {
    1292           0 :             nTxtColl = RES_POOLCOLL_FOOTNOTE;
    1293           0 :             aClass = aEmptyStr;
    1294             :         }
    1295             :     }
    1296             : 
    1297           0 :     if( USER_FMT & nTxtColl )       // eine vom Reader angelegte
    1298             :     {
    1299             :         OSL_ENSURE( !this, "Wo kommt die Benutzer-Vorlage her?" );
    1300           0 :         pColl = GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
    1301             :     }
    1302             :     else
    1303             :     {
    1304           0 :         pColl = GetTxtCollFromPool( nTxtColl );
    1305             :     }
    1306             : 
    1307             :     OSL_ENSURE( pColl, "Keine Absatz-Vorlage???" );
    1308           0 :     if( aClass.Len() )
    1309             :     {
    1310           0 :         String aTmp( pColl->GetName() );
    1311           0 :         AddClassName( aTmp, aClass );
    1312           0 :         SwTxtFmtColl* pClassColl = pDoc->FindTxtFmtCollByName( aTmp );
    1313             : 
    1314           0 :         if( !pClassColl &&
    1315             :             (nTxtColl==RES_POOLCOLL_TABLE ||
    1316             :              nTxtColl==RES_POOLCOLL_TABLE_HDLN) )
    1317             :         {
    1318             :             // Wenn dieser Fall eintritt, dann wurde ein <TD><P CLASS=foo>
    1319             :             // gelesen, aber die TD.foo Vorlage nicht gefunden. Dann muessen
    1320             :             // wir P.foo nehmen, wenn es sie gibt.
    1321             :             SwTxtFmtColl* pCollText =
    1322           0 :                 GetTxtCollFromPool( RES_POOLCOLL_TEXT );
    1323           0 :             aTmp = pCollText->GetName();
    1324           0 :             AddClassName( aTmp, aClass );
    1325           0 :             pClassColl = pDoc->FindTxtFmtCollByName( aTmp );
    1326             :         }
    1327             : 
    1328           0 :         if( pClassColl )
    1329             :         {
    1330           0 :             pColl = pClassColl;
    1331             :         }
    1332             :         else
    1333             :         {
    1334           0 :             const SvxCSS1MapEntry *pClass = GetClass( aClass );
    1335           0 :             if( pClass )
    1336             :             {
    1337           0 :                 pColl = pDoc->MakeTxtFmtColl( aTmp, pColl );
    1338           0 :                 SfxItemSet aItemSet( pClass->GetItemSet() );
    1339           0 :                 SvxCSS1PropertyInfo aPropInfo( pClass->GetPropertyInfo() );
    1340           0 :                 aPropInfo.SetBoxItem( aItemSet, MIN_BORDER_DIST );
    1341           0 :                 sal_Bool bPositioned = MayBePositioned( pClass->GetPropertyInfo() );
    1342           0 :                 if( bPositioned )
    1343           0 :                     aItemSet.ClearItem( RES_BACKGROUND );
    1344             :                 SetTxtCollAttrs( pColl, aItemSet, aPropInfo,
    1345           0 :                                  this );
    1346             :             }
    1347           0 :         }
    1348             : 
    1349             :     }
    1350             : 
    1351           0 :     if( pColl )
    1352           0 :         lcl_swcss1_setEncoding( *pColl, GetDfltEncoding() );
    1353             : 
    1354           0 :     return pColl;
    1355             : }
    1356             : 
    1357           0 : SwPageDesc *SwCSS1Parser::GetMasterPageDesc()
    1358             : {
    1359           0 :     return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false );
    1360             : }
    1361             : 
    1362           0 : static SwPageDesc *FindPageDesc( SwDoc *pDoc, sal_uInt16 nPoolId, sal_uInt16& rPage )
    1363             : {
    1364           0 :     sal_uInt16 nPageDescs = pDoc->GetPageDescCnt();
    1365           0 :     for( rPage=0; rPage < nPageDescs &&
    1366           0 :          pDoc->GetPageDesc(rPage).GetPoolFmtId() != nPoolId; rPage++ )
    1367             :          ;
    1368             : 
    1369           0 :     return rPage < nPageDescs ? &pDoc->GetPageDesc( rPage ) : 0;
    1370             : }
    1371             : 
    1372           0 : const SwPageDesc *SwCSS1Parser::GetPageDesc( sal_uInt16 nPoolId, sal_Bool bCreate )
    1373             : {
    1374           0 :     if( RES_POOLPAGE_HTML == nPoolId )
    1375           0 :         return pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false );
    1376             : 
    1377             :     sal_uInt16 nPage;
    1378           0 :     const SwPageDesc *pPageDesc = FindPageDesc( pDoc, nPoolId, nPage );
    1379           0 :     if( !pPageDesc && bCreate )
    1380             :     {
    1381             :         // Die erste Seite wird aus der rechten Seite erzeugt, wenn es die
    1382             :         // gibt.
    1383           0 :         SwPageDesc *pMasterPageDesc = 0;
    1384           0 :         if( RES_POOLPAGE_FIRST == nPoolId )
    1385           0 :             pMasterPageDesc = FindPageDesc( pDoc, RES_POOLPAGE_RIGHT, nPage );
    1386           0 :         if( !pMasterPageDesc )
    1387           0 :             pMasterPageDesc = pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false );
    1388             : 
    1389             :         // Die neue Seitenvorlage entsteht aus dem Master durch kopieren.
    1390             :         SwPageDesc *pNewPageDesc = pDoc->
    1391           0 :             GetPageDescFromPool( nPoolId, false );
    1392             : 
    1393             :         // dazu brauchen wir auch die Nummer der neuen Vorlage
    1394           0 :         pPageDesc = FindPageDesc( pDoc, nPoolId, nPage );
    1395             :         OSL_ENSURE( pPageDesc==pNewPageDesc, "Seitenvorlage nicht gefunden" );
    1396             : 
    1397           0 :         pDoc->CopyPageDesc( *pMasterPageDesc, *pNewPageDesc, false );
    1398             : 
    1399             :         // Die Vorlagen an ihren neuen Zweck anpassen.
    1400           0 :         const SwPageDesc *pFollow = 0;
    1401           0 :         sal_Bool bSetFollowFollow = sal_False;
    1402           0 :         switch( nPoolId )
    1403             :         {
    1404             :         case RES_POOLPAGE_FIRST:
    1405             :             // Wenn es schon eine linke Seite gibt, dann ist das die
    1406             :             // Folge-Vorlage, sonst ist es die HTML-Vorlage.
    1407           0 :             pFollow = GetLeftPageDesc();
    1408           0 :             if( !pFollow )
    1409           0 :                 pFollow = pMasterPageDesc;
    1410           0 :             break;
    1411             : 
    1412             :         case RES_POOLPAGE_RIGHT:
    1413             :             // Wenn die linke Vorlage schon angelegt ist, passiert hier gar
    1414             :             // nichts. Sonst wird die linke Vorlage angelegt und sorgt auch
    1415             :             // fuer die richtige Verkettung mit der rechten Voralge.
    1416           0 :             GetLeftPageDesc( sal_True );
    1417           0 :             break;
    1418             : 
    1419             :         case RES_POOLPAGE_LEFT:
    1420             :             // Die rechte Vorlage wird angelegt, wenn sie noch nicht existiert.
    1421             :             // Es findet aber keine Verkettung statt.
    1422             :             // Wenn schon eine erste Seitenvorlage existiert, wird die linke
    1423             :             // Vorlage die Folge-Vorlage der ersten Seite.
    1424           0 :             pFollow = GetRightPageDesc( sal_True );
    1425           0 :             bSetFollowFollow = sal_True;
    1426             :             {
    1427           0 :                 const SwPageDesc *pFirstPageDesc = GetFirstPageDesc();
    1428           0 :                 if( pFirstPageDesc )
    1429             :                 {
    1430           0 :                     SwPageDesc aNewFirstPageDesc( *pFirstPageDesc );
    1431           0 :                     aNewFirstPageDesc.SetFollow( pNewPageDesc );
    1432           0 :                     ChgPageDesc( pFirstPageDesc, aNewFirstPageDesc );
    1433             :                 }
    1434             :             }
    1435           0 :             break;
    1436             :         }
    1437             : 
    1438           0 :         if( pFollow )
    1439             :         {
    1440           0 :             SwPageDesc aNewPageDesc( *pNewPageDesc );
    1441           0 :             aNewPageDesc.SetFollow( pFollow );
    1442           0 :             ChgPageDesc( pNewPageDesc, aNewPageDesc );
    1443             : 
    1444           0 :             if( bSetFollowFollow )
    1445             :             {
    1446           0 :                 SwPageDesc aNewFollowPageDesc( *pFollow );
    1447           0 :                 aNewFollowPageDesc.SetFollow( pNewPageDesc );
    1448           0 :                 ChgPageDesc( pFollow, aNewFollowPageDesc );
    1449           0 :             }
    1450             :         }
    1451           0 :         pPageDesc = pNewPageDesc;
    1452             :     }
    1453             : 
    1454           0 :     return pPageDesc;
    1455             : }
    1456             : 
    1457             : 
    1458           0 : sal_Bool SwCSS1Parser::MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
    1459             :                                     sal_Bool bAutoWidth )
    1460             : {
    1461             :     // abs-pos
    1462             :     // left/top none    auto    twip    perc
    1463             :     //
    1464             :     // none     Z       Z       -       -
    1465             :     // auto     Z       Z       -       -
    1466             :     // twip     Z       Z       S/R     -
    1467             :     // perc     -       -       -       -
    1468             :     //
    1469             :     // - das Tag wird absolut positioniert und left/top sind beide
    1470             :     //   gegeben und enthalten auch keine %-Angabe, oder
    1471             :     // - das Tag soll fliessen, und
    1472             :     // - es wurde eine Breite angegeben (in beiden Faellen noetig)
    1473             :     return ( ( SVX_CSS1_POS_ABSOLUTE     == rPropInfo.ePosition &&
    1474             :                SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.eLeftType &&
    1475             :                SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.eTopType &&
    1476             :               (SVX_CSS1_LTYPE_TWIP       == rPropInfo.eLeftType ||
    1477             :                SVX_CSS1_LTYPE_TWIP       != rPropInfo.eTopType) ) ||
    1478             :              ( SVX_ADJUST_END            != rPropInfo.eFloat  ) ) &&
    1479             :            ( bAutoWidth ||
    1480             :              SVX_CSS1_LTYPE_TWIP         == rPropInfo.eWidthType ||
    1481           0 :              SVX_CSS1_LTYPE_PERCENTAGE   == rPropInfo.eWidthType );
    1482             : }
    1483             : 
    1484             : 
    1485             : 
    1486           0 : void SwCSS1Parser::AddClassName( String& rFmtName, const String& rClass )
    1487             : {
    1488             :     OSL_ENSURE( rClass.Len(), "Style-Klasse ohne Laenge?" );
    1489             : 
    1490           0 :     (rFmtName += '.') += rClass;
    1491           0 : }
    1492             : 
    1493             : 
    1494           0 : void SwCSS1Parser::FillDropCap( SwFmtDrop& rDrop,
    1495             :                                 SfxItemSet& rItemSet,
    1496             :                                 const String *pName )
    1497             : {
    1498             :     // die Anzahl der Zeilen entspricht in etwa einer %-Angabe
    1499             :     // fuer die Hoehe (was passiert mit absoluten Hoehen???)
    1500           0 :     sal_uInt8 nLines = rDrop.GetLines();
    1501             :     const SfxPoolItem *pItem;
    1502           0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, sal_False, &pItem ) )
    1503             :     {
    1504           0 :         sal_uInt16 nProp = ((const SvxFontHeightItem *)pItem)->GetProp();
    1505           0 :         nLines = (sal_uInt8)((nProp + 50) / 100);
    1506           0 :         if( nLines < 1 )
    1507           0 :             nLines = 1;
    1508           0 :         else if( nLines > MAX_DROPCAP_LINES )
    1509           0 :             nLines = MAX_DROPCAP_LINES;
    1510             : 
    1511             :         // Nur wenn nLines>1 ist, wird das Attribut auch gesetzt. Dann
    1512             :         // brauchen wir die Font-Hoehe aber auch nicht in der Zeichen-Vorlage.
    1513           0 :         if( nLines > 1 )
    1514             :         {
    1515           0 :             rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
    1516           0 :             rItemSet.ClearItem( RES_CHRATR_CJK_FONTSIZE );
    1517           0 :             rItemSet.ClearItem( RES_CHRATR_CTL_FONTSIZE );
    1518             :         }
    1519             :     }
    1520             : 
    1521             :     // Bei harter Attributierung (pName==0) koennen wir aufhoehren, wenn
    1522             :     // das Initial nur ueber eine Zeile geht.
    1523           0 :     if( nLines<=1 )
    1524           0 :         return;
    1525             : 
    1526           0 :     rDrop.GetLines() = nLines;
    1527             : 
    1528             :     // ein rechter Rand wird der Abstand zum Text!
    1529           0 :     if( SFX_ITEM_SET == rItemSet.GetItemState( RES_LR_SPACE, sal_False, &pItem ) )
    1530             :     {
    1531           0 :         rDrop.GetDistance() = static_cast< sal_uInt16 >(
    1532           0 :             ((const SvxLRSpaceItem *)pItem)->GetRight() );
    1533           0 :         rItemSet.ClearItem( RES_LR_SPACE );
    1534             :     }
    1535             : 
    1536             :     // Fuer alle anderen Attribute eine Zeichen-Vorlage anlegen
    1537           0 :     if( rItemSet.Count() )
    1538             :     {
    1539           0 :         SwCharFmt *pCFmt = 0;
    1540           0 :         String aName;
    1541           0 :         if( pName )
    1542             :         {
    1543           0 :             aName = *pName;
    1544           0 :             AddFirstLetterExt( aName );
    1545           0 :             pCFmt = pDoc->FindCharFmtByName( aName );
    1546             :         }
    1547             :         else
    1548             :         {
    1549           0 :             do
    1550             :             {
    1551           0 :                 aName.AssignAscii( sCSS1_first_letter );
    1552           0 :                 aName.Append( ' ' );
    1553             :                 aName.Append(
    1554           0 :                     String::CreateFromInt32( (sal_Int32)(++nDropCapCnt) ) );
    1555             :             }
    1556           0 :             while( pDoc->FindCharFmtByName(aName) );
    1557             :         }
    1558             : 
    1559           0 :         if( !pCFmt )
    1560             :         {
    1561           0 :             pCFmt = pDoc->MakeCharFmt( aName, pDoc->GetDfltCharFmt() );
    1562           0 :             pCFmt->SetAuto( false );
    1563             :         }
    1564           0 :         SetCharFmtAttrs( pCFmt, rItemSet );
    1565             : 
    1566             :         // Die Zeichenvorlage braucht nur im Attribut gesetzt werden, wenn
    1567             :         // auch das Attribut gesetzt wird.
    1568           0 :         if( nLines > 1 )
    1569           0 :             rDrop.SetCharFmt( pCFmt );
    1570             :     }
    1571             : }
    1572             : 
    1573             : 
    1574             : // CSS1-sezifisches des SwHTMLParsers
    1575             : 
    1576           0 : _HTMLAttr **SwHTMLParser::GetAttrTabEntry( sal_uInt16 nWhich )
    1577             : {
    1578             :     // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ...
    1579           0 :     _HTMLAttr **ppAttr = 0;
    1580           0 :     switch( nWhich )
    1581             :     {
    1582             :     case RES_CHRATR_BLINK:
    1583           0 :         ppAttr = &aAttrTab.pBlink;
    1584           0 :         break;
    1585             :     case RES_CHRATR_CASEMAP:
    1586           0 :         ppAttr = &aAttrTab.pCaseMap;
    1587           0 :         break;
    1588             :     case RES_CHRATR_COLOR:
    1589           0 :         ppAttr = &aAttrTab.pFontColor;
    1590           0 :         break;
    1591             :     case RES_CHRATR_CROSSEDOUT:
    1592           0 :         ppAttr = &aAttrTab.pStrike;
    1593           0 :         break;
    1594             :     case RES_CHRATR_ESCAPEMENT:
    1595           0 :         ppAttr = &aAttrTab.pEscapement;
    1596           0 :         break;
    1597             :     case RES_CHRATR_FONT:
    1598           0 :         ppAttr = &aAttrTab.pFont;
    1599           0 :         break;
    1600             :     case RES_CHRATR_CJK_FONT:
    1601           0 :         ppAttr = &aAttrTab.pFontCJK;
    1602           0 :         break;
    1603             :     case RES_CHRATR_CTL_FONT:
    1604           0 :         ppAttr = &aAttrTab.pFontCTL;
    1605           0 :         break;
    1606             :     case RES_CHRATR_FONTSIZE:
    1607           0 :         ppAttr = &aAttrTab.pFontHeight;
    1608           0 :         break;
    1609             :     case RES_CHRATR_CJK_FONTSIZE:
    1610           0 :         ppAttr = &aAttrTab.pFontHeightCJK;
    1611           0 :         break;
    1612             :     case RES_CHRATR_CTL_FONTSIZE:
    1613           0 :         ppAttr = &aAttrTab.pFontHeightCTL;
    1614           0 :         break;
    1615             :     case RES_CHRATR_KERNING:
    1616           0 :         ppAttr = &aAttrTab.pKerning;
    1617           0 :         break;
    1618             :     case RES_CHRATR_POSTURE:
    1619           0 :         ppAttr = &aAttrTab.pItalic;
    1620           0 :         break;
    1621             :     case RES_CHRATR_CJK_POSTURE:
    1622           0 :         ppAttr = &aAttrTab.pItalicCJK;
    1623           0 :         break;
    1624             :     case RES_CHRATR_CTL_POSTURE:
    1625           0 :         ppAttr = &aAttrTab.pItalicCTL;
    1626           0 :         break;
    1627             :     case RES_CHRATR_UNDERLINE:
    1628           0 :         ppAttr = &aAttrTab.pUnderline;
    1629           0 :         break;
    1630             :     case RES_CHRATR_WEIGHT:
    1631           0 :         ppAttr = &aAttrTab.pBold;
    1632           0 :         break;
    1633             :     case RES_CHRATR_CJK_WEIGHT:
    1634           0 :         ppAttr = &aAttrTab.pBoldCJK;
    1635           0 :         break;
    1636             :     case RES_CHRATR_CTL_WEIGHT:
    1637           0 :         ppAttr = &aAttrTab.pBoldCTL;
    1638           0 :         break;
    1639             :     case RES_CHRATR_BACKGROUND:
    1640           0 :         ppAttr = &aAttrTab.pCharBrush;
    1641           0 :         break;
    1642             : 
    1643             :     case RES_PARATR_LINESPACING:
    1644           0 :         ppAttr = &aAttrTab.pLineSpacing;
    1645           0 :         break;
    1646             :     case RES_PARATR_ADJUST:
    1647           0 :         ppAttr = &aAttrTab.pAdjust;
    1648           0 :         break;
    1649             : 
    1650             :     case RES_LR_SPACE:
    1651           0 :         ppAttr = &aAttrTab.pLRSpace;
    1652           0 :         break;
    1653             :     case RES_UL_SPACE:
    1654           0 :         ppAttr = &aAttrTab.pULSpace;
    1655           0 :         break;
    1656             :     case RES_BOX:
    1657           0 :         ppAttr = &aAttrTab.pBox;
    1658           0 :         break;
    1659             :     case RES_BACKGROUND:
    1660           0 :         ppAttr = &aAttrTab.pBrush;
    1661           0 :         break;
    1662             :     case RES_BREAK:
    1663           0 :         ppAttr = &aAttrTab.pBreak;
    1664           0 :         break;
    1665             :     case RES_PAGEDESC:
    1666           0 :         ppAttr = &aAttrTab.pPageDesc;
    1667           0 :         break;
    1668             :     case RES_PARATR_SPLIT:
    1669           0 :         ppAttr = &aAttrTab.pSplit;
    1670           0 :         break;
    1671             :     case RES_PARATR_WIDOWS:
    1672           0 :         ppAttr = &aAttrTab.pWidows;
    1673           0 :         break;
    1674             :     case RES_PARATR_ORPHANS:
    1675           0 :         ppAttr = &aAttrTab.pOrphans;
    1676           0 :         break;
    1677             :     case RES_KEEP:
    1678           0 :         ppAttr = &aAttrTab.pKeep;
    1679           0 :         break;
    1680             : 
    1681             :     case RES_CHRATR_LANGUAGE:
    1682           0 :         ppAttr = &aAttrTab.pLanguage;
    1683           0 :         break;
    1684             :     case RES_CHRATR_CJK_LANGUAGE:
    1685           0 :         ppAttr = &aAttrTab.pLanguageCJK;
    1686           0 :         break;
    1687             :     case RES_CHRATR_CTL_LANGUAGE:
    1688           0 :         ppAttr = &aAttrTab.pLanguageCTL;
    1689           0 :         break;
    1690             : 
    1691             :     case RES_FRAMEDIR:
    1692           0 :         ppAttr = &aAttrTab.pDirection;
    1693           0 :         break;
    1694             :     }
    1695             : 
    1696           0 :     return ppAttr;
    1697             : }
    1698             : 
    1699           0 : void SwHTMLParser::NewStyle()
    1700             : {
    1701           0 :     String sType;
    1702             : 
    1703           0 :     const HTMLOptions& rOptions2 = GetOptions();
    1704           0 :     for (size_t i = rOptions2.size(); i; )
    1705             :     {
    1706           0 :         const HTMLOption& rOption = rOptions2[--i];
    1707           0 :         if( HTML_O_TYPE == rOption.GetToken() )
    1708           0 :             sType = rOption.GetString();
    1709             :     }
    1710             : 
    1711           0 :     bIgnoreRawData = sType.Len() &&
    1712           0 :                      !sType.GetToken(0,';').EqualsAscii(sCSS_mimetype);
    1713           0 : }
    1714             : 
    1715           0 : void SwHTMLParser::EndStyle()
    1716             : {
    1717           0 :     bIgnoreRawData = sal_False;
    1718             : 
    1719           0 :     if( aStyleSource.Len() )
    1720             :     {
    1721           0 :         pCSS1Parser->ParseStyleSheet( aStyleSource );
    1722           0 :         aStyleSource.Erase();
    1723             :     }
    1724           0 : }
    1725             : 
    1726           0 : sal_Bool SwHTMLParser::FileDownload( const String& rURL,
    1727             :                                  String& rStr )
    1728             : {
    1729             :     // View wegschmeissen (wegen Reschedule)
    1730           0 :     ViewShell *pOldVSh = CallEndAction();
    1731             : 
    1732             :     // Ein Medium anlegen
    1733           0 :     SfxMedium aDLMedium( rURL, STREAM_READ | STREAM_SHARE_DENYWRITE );
    1734             : 
    1735           0 :     SvStream* pStream = aDLMedium.GetInStream();
    1736           0 :     if( pStream )
    1737             :     {
    1738           0 :         SvMemoryStream aStream;
    1739           0 :         aStream << *pStream;
    1740             : 
    1741           0 :         aStream.Seek( STREAM_SEEK_TO_END );
    1742             :         OSL_ENSURE( aStream.Tell() < STRING_MAXLEN,
    1743             :                     "File zu lang fuer einen String, Ende abgeschnitten" );
    1744           0 :         xub_StrLen nLen = aStream.Tell() < STRING_MAXLEN
    1745           0 :                         ? (xub_StrLen)aStream.Tell()
    1746           0 :                         : STRING_MAXLEN;
    1747             : 
    1748           0 :         rStr = String( (const sal_Char *)aStream.GetData(), nLen,
    1749           0 :                        GetSrcEncoding() );
    1750             :     }
    1751             : 
    1752             : 
    1753             :     // wurde abgebrochen?
    1754           0 :     if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
    1755           0 :         || 1 == pDoc->getReferenceCount() )
    1756             :     {
    1757             :         // wurde der Import vom SFX abgebrochen?
    1758           0 :         eState = SVPAR_ERROR;
    1759           0 :         pStream = 0;
    1760             :     }
    1761             : 
    1762             :     // recreate View
    1763           0 :     ViewShell *const pVSh = CallStartAction( pOldVSh );
    1764             :     OSL_ENSURE( pOldVSh == pVSh, "FileDownload: ViewShell changed on us" );
    1765             :     (void) pVSh;
    1766             : 
    1767           0 :     return pStream!=0;
    1768             : }
    1769             : 
    1770           0 : void SwHTMLParser::InsertLink()
    1771             : {
    1772           0 :     sal_Bool bFinishDownload = sal_False;
    1773           0 :     if( pPendStack )
    1774             :     {
    1775             :         OSL_ENSURE( ShouldFinishFileDownload(),
    1776             :                 "Pending-Stack ohne File-Download?" );
    1777             : 
    1778           0 :         SwPendingStack* pTmp = pPendStack->pNext;
    1779           0 :         delete pPendStack;
    1780           0 :         pPendStack = pTmp;
    1781             :         OSL_ENSURE( !pPendStack, "Wo kommt der Pending-Stack her?" );
    1782             : 
    1783           0 :         bFinishDownload = sal_True;
    1784             :     }
    1785             :     else
    1786             :     {
    1787           0 :         String sRel, sHRef, sType;
    1788             : 
    1789           0 :         const HTMLOptions& rOptions2 = GetOptions();
    1790           0 :         for (size_t i = rOptions2.size(); i; )
    1791             :         {
    1792           0 :             const HTMLOption& rOption = rOptions2[--i];
    1793           0 :             switch( rOption.GetToken() )
    1794             :             {
    1795             :                 case HTML_O_REL:
    1796           0 :                     sRel = rOption.GetString();
    1797           0 :                     break;
    1798             :                 case HTML_O_HREF:
    1799           0 :                     sHRef = URIHelper::SmartRel2Abs( INetURLObject( sBaseURL ), rOption.GetString(), Link(), false );
    1800           0 :                     break;
    1801             :                 case HTML_O_TYPE:
    1802           0 :                     sType = rOption.GetString();
    1803           0 :                     break;
    1804             :             }
    1805             :         }
    1806             : 
    1807           0 :         if( sHRef.Len() && sRel.EqualsIgnoreCaseAscii( "STYLESHEET" ) &&
    1808           0 :             ( !sType.Len() ||
    1809           0 :               sType.GetToken(0,';').EqualsAscii(sCSS_mimetype) ) )
    1810             :         {
    1811           0 :             if( GetMedium() )
    1812             :             {
    1813             :                 // Download des Style-Source starten
    1814           0 :                 StartFileDownload(sHRef);
    1815           0 :                 if( IsParserWorking() )
    1816             :                 {
    1817             :                     // Der Style wurde synchron geladen und wir koennen
    1818             :                     // es direkt aufrufen.
    1819           0 :                     bFinishDownload = sal_True;
    1820             :                 }
    1821             :                 else
    1822             :                 {
    1823             :                     // Der Style wird asynchron geladen und ist erst beim
    1824             :                     // naechsten Continue-Aufruf da. Wir muessen deshalb einen
    1825             :                     // Pending-Stack anlegen, damit wir hierher zurueckkehren
    1826           0 :                     pPendStack = new SwPendingStack( HTML_LINK, pPendStack );
    1827             :                 }
    1828             :             }
    1829             :             else
    1830             :             {
    1831             :                 // File synchron holen
    1832           0 :                 String sSource;
    1833           0 :                 if( FileDownload( sHRef, sSource ) )
    1834           0 :                     pCSS1Parser->ParseStyleSheet( sSource );
    1835             :             }
    1836           0 :         }
    1837             :     }
    1838             : 
    1839           0 :     if( bFinishDownload )
    1840             :     {
    1841           0 :         String sSource;
    1842           0 :         if( FinishFileDownload(sSource) && sSource.Len() )
    1843           0 :             pCSS1Parser->ParseStyleSheet( sSource );
    1844             :     }
    1845           0 : }
    1846             : 
    1847           0 : sal_Bool SwCSS1Parser::ParseStyleSheet( const String& rIn )
    1848             : {
    1849           0 :     if( !SvxCSS1Parser::ParseStyleSheet( rIn ) )
    1850           0 :         return sal_False;
    1851             : 
    1852             :     SwPageDesc *pMasterPageDesc =
    1853           0 :         pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false );
    1854             : 
    1855           0 :     SvxCSS1MapEntry *pPageEntry = GetPage( aEmptyStr, false );
    1856           0 :     if( pPageEntry )
    1857             :     {
    1858             :         // @page (wirkt auf alle Seiten, die es schon gibt
    1859             : 
    1860           0 :         SetPageDescAttrs( pMasterPageDesc, pPageEntry->GetItemSet(),
    1861           0 :                           pPageEntry->GetPropertyInfo() );
    1862             : 
    1863             :         // Fuer alle anderen Seiten-Vorlagen, die es schon gibt,
    1864             :         // muessen die Attribute auch noch gesetzt werden
    1865             : 
    1866           0 :         SetPageDescAttrs( GetFirstPageDesc(), pPageEntry->GetItemSet(),
    1867           0 :                           pPageEntry->GetPropertyInfo() );
    1868           0 :         SetPageDescAttrs( GetLeftPageDesc(), pPageEntry->GetItemSet(),
    1869           0 :                           pPageEntry->GetPropertyInfo() );
    1870           0 :         SetPageDescAttrs( GetRightPageDesc(), pPageEntry->GetItemSet(),
    1871           0 :                           pPageEntry->GetPropertyInfo() );
    1872             : 
    1873             :     }
    1874             : 
    1875           0 :     pPageEntry = GetPage( rtl::OUString::createFromAscii(sCSS1_first), sal_True );
    1876           0 :     if( pPageEntry )
    1877             :     {
    1878           0 :         SetPageDescAttrs( GetFirstPageDesc(sal_True), pPageEntry->GetItemSet(),
    1879           0 :                           pPageEntry->GetPropertyInfo() );
    1880           0 :         bSetFirstPageDesc = sal_True;
    1881             :     }
    1882             : 
    1883           0 :     pPageEntry = GetPage( rtl::OUString::createFromAscii(sCSS1_right), sal_True );
    1884           0 :     if( pPageEntry )
    1885             :     {
    1886           0 :         SetPageDescAttrs( GetRightPageDesc(sal_True), pPageEntry->GetItemSet(),
    1887           0 :                           pPageEntry->GetPropertyInfo() );
    1888           0 :         bSetRightPageDesc = sal_True;
    1889             :     }
    1890             : 
    1891           0 :     pPageEntry = GetPage( rtl::OUString::createFromAscii(sCSS1_left), sal_True );
    1892           0 :     if( pPageEntry )
    1893           0 :         SetPageDescAttrs( GetLeftPageDesc(sal_True), pPageEntry->GetItemSet(),
    1894           0 :                           pPageEntry->GetPropertyInfo() );
    1895             : 
    1896           0 :     return sal_True;
    1897             : }
    1898             : 
    1899           0 : sal_Bool SwHTMLParser::ParseStyleOptions( const String &rStyle,
    1900             :                                       const String &rId,
    1901             :                                       const String &rClass,
    1902             :                                       SfxItemSet &rItemSet,
    1903             :                                       SvxCSS1PropertyInfo &rPropInfo,
    1904             :                                          const String *pLang,
    1905             :                                          const String *pDir )
    1906             : {
    1907           0 :     sal_Bool bRet = sal_False;
    1908             : 
    1909           0 :     if( rClass.Len() )
    1910             :     {
    1911           0 :         String aClass( rClass );
    1912           0 :         SwCSS1Parser::GetScriptFromClass( aClass );
    1913           0 :         const SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( aClass );
    1914           0 :         if( pClass )
    1915             :         {
    1916           0 :             pCSS1Parser->MergeStyles( pClass->GetItemSet(),
    1917           0 :                                       pClass->GetPropertyInfo(),
    1918           0 :                                       rItemSet, rPropInfo, sal_False );
    1919           0 :             bRet = sal_True;
    1920           0 :         }
    1921             :     }
    1922             : 
    1923           0 :     if( rId.Len() )
    1924             :     {
    1925           0 :         const SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
    1926           0 :         if( pId )
    1927           0 :             pCSS1Parser->MergeStyles( pId->GetItemSet(),
    1928           0 :                                       pId->GetPropertyInfo(),
    1929           0 :                                       rItemSet, rPropInfo, rClass.Len()!=0 );
    1930           0 :         rPropInfo.aId = rId;
    1931           0 :         bRet = sal_True;
    1932             :     }
    1933             : 
    1934           0 :     if( rStyle.Len() )
    1935             :     {
    1936           0 :         pCSS1Parser->ParseStyleOption( rStyle, rItemSet, rPropInfo );
    1937           0 :         bRet = sal_True;
    1938             :     }
    1939             : 
    1940           0 :     if( bRet )
    1941           0 :         rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
    1942             : 
    1943           0 :     if( pLang && pLang->Len() )
    1944             :     {
    1945           0 :         LanguageType eLang = LanguageTag( *pLang ).getLanguageType();
    1946           0 :         if( LANGUAGE_DONTKNOW != eLang )
    1947             :         {
    1948           0 :             SvxLanguageItem aLang( eLang, RES_CHRATR_LANGUAGE );
    1949           0 :             rItemSet.Put( aLang );
    1950           0 :             aLang.SetWhich( RES_CHRATR_CJK_LANGUAGE );
    1951           0 :             rItemSet.Put( aLang );
    1952           0 :             aLang.SetWhich( RES_CHRATR_CTL_LANGUAGE );
    1953           0 :             rItemSet.Put( aLang );
    1954             : 
    1955           0 :             bRet = sal_True;
    1956             :         }
    1957             :     }
    1958           0 :     if( pDir && pDir->Len() )
    1959             :     {
    1960           0 :         String aValue( *pDir );
    1961           0 :         aValue.ToUpperAscii();
    1962           0 :         SvxFrameDirection eDir = FRMDIR_ENVIRONMENT;
    1963           0 :         if( aValue.EqualsAscii( "LTR" ) )
    1964           0 :             eDir = FRMDIR_HORI_LEFT_TOP;
    1965           0 :         else if( aValue.EqualsAscii( "RTL" ) )
    1966           0 :             eDir = FRMDIR_HORI_RIGHT_TOP;
    1967             : 
    1968           0 :         if( FRMDIR_ENVIRONMENT != eDir )
    1969             :         {
    1970           0 :             SvxFrameDirectionItem aDir( eDir, RES_FRAMEDIR );
    1971           0 :             rItemSet.Put( aDir );
    1972             : 
    1973           0 :             bRet = sal_True;
    1974           0 :         }
    1975             :     }
    1976             : 
    1977           0 :     return bRet;
    1978             : }
    1979             : 
    1980           0 : void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/,
    1981             :                                            const SvxCSS1PropertyInfo &rPropInfo,
    1982             :                                            SfxItemSet &rFrmItemSet )
    1983             : {
    1984           0 :     SwFmtAnchor aAnchor;
    1985             : 
    1986           0 :     sal_Int16 eHoriOri = text::HoriOrientation::NONE;
    1987           0 :     sal_Int16 eVertOri = text::VertOrientation::NONE;
    1988           0 :     sal_Int16 eHoriRel = text::RelOrientation::FRAME;
    1989           0 :     sal_Int16 eVertRel = text::RelOrientation::FRAME;
    1990           0 :     SwTwips nHoriPos = 0, nVertPos = 0;
    1991           0 :     SwSurround eSurround = SURROUND_THROUGHT;
    1992           0 :     if( SVX_CSS1_POS_ABSOLUTE == rPropInfo.ePosition )
    1993             :     {
    1994           0 :         if( SVX_CSS1_LTYPE_TWIP == rPropInfo.eLeftType &&
    1995             :             SVX_CSS1_LTYPE_TWIP == rPropInfo.eTopType )
    1996             :         {
    1997             :             // Absolut positionierte Objekte sind seitengebunden, wenn
    1998             :             // sie nicht schon in einem Rahmen stehen und sonst
    1999             :             // Rahmengebunden.
    2000             :             const SwStartNode *pFlySttNd =
    2001           0 :                 pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
    2002           0 :             if( pFlySttNd )
    2003             :             {
    2004           0 :                 aAnchor.SetType( FLY_AT_FLY );
    2005           0 :                 SwPosition aPos( *pFlySttNd );
    2006           0 :                 aAnchor.SetAnchor( &aPos );
    2007             :             }
    2008             :             else
    2009             :             {
    2010           0 :                 aAnchor.SetType( FLY_AT_PAGE );
    2011           0 :                 aAnchor.SetPageNum( 1 );
    2012             :             }
    2013           0 :             nHoriPos = rPropInfo.nLeft;
    2014           0 :             nVertPos = rPropInfo.nTop;
    2015             :         }
    2016             :         else
    2017             :         {
    2018           0 :             aAnchor.SetType( FLY_AT_PARA );
    2019           0 :             aAnchor.SetAnchor( pPam->GetPoint() );
    2020           0 :             eVertOri = text::VertOrientation::TOP;
    2021           0 :             eVertRel = text::RelOrientation::CHAR;
    2022           0 :             if( SVX_CSS1_LTYPE_TWIP == rPropInfo.eLeftType )
    2023             :             {
    2024           0 :                 eHoriOri = text::HoriOrientation::NONE;
    2025           0 :                 eHoriRel = text::RelOrientation::PAGE_FRAME;
    2026           0 :                 nHoriPos = rPropInfo.nLeft;
    2027             :             }
    2028             :             else
    2029             :             {
    2030           0 :                 eHoriOri = text::HoriOrientation::LEFT;
    2031           0 :                 eHoriRel = text::RelOrientation::FRAME;   // wird noch umgeschossen
    2032             :             }
    2033             :         }
    2034             :     }
    2035             :     else
    2036             :     {
    2037             :         // fliessende Objekte werden Absatzgebunden eingefuegt, wenn
    2038             :         // der Absatz noch leer ist und sonst auto-gebunden.
    2039             :         // Auto-gebundene Rahmen werden zunaechst an der Position davor
    2040             :         // eingefuegt und erst spaeter verschoben.
    2041           0 :         xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex();
    2042           0 :         if( nCntnt )
    2043             :         {
    2044           0 :             aAnchor.SetType( FLY_AT_CHAR );
    2045           0 :             pPam->Move( fnMoveBackward );
    2046           0 :             eVertOri = text::VertOrientation::CHAR_BOTTOM;
    2047           0 :             eVertRel = text::RelOrientation::CHAR;
    2048             :         }
    2049             :         else
    2050             :         {
    2051           0 :             aAnchor.SetType( FLY_AT_PARA );
    2052           0 :             eVertOri = text::VertOrientation::TOP;
    2053           0 :             eVertRel = text::RelOrientation::PRINT_AREA;
    2054             :         }
    2055             : 
    2056           0 :         aAnchor.SetAnchor( pPam->GetPoint() );
    2057             : 
    2058           0 :         if( nCntnt )
    2059           0 :             pPam->Move( fnMoveForward );
    2060             : 
    2061           0 :         sal_uInt16 nLeftSpace = 0, nRightSpace = 0;
    2062           0 :         short nIndent = 0;
    2063           0 :         GetMarginsFromContextWithNumBul( nLeftSpace, nRightSpace, nIndent );
    2064             : 
    2065           0 :         if( SVX_ADJUST_RIGHT==rPropInfo.eFloat )
    2066             :         {
    2067           0 :             eHoriOri = text::HoriOrientation::RIGHT;
    2068           0 :             eHoriRel = nRightSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
    2069           0 :             eSurround = SURROUND_LEFT;
    2070             :         }
    2071             :         else
    2072             :         {
    2073           0 :             eHoriOri = text::HoriOrientation::LEFT;
    2074           0 :             eHoriRel = nLeftSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
    2075           0 :             eSurround = SURROUND_RIGHT;
    2076             :         }
    2077             :     }
    2078           0 :     rFrmItemSet.Put( aAnchor );
    2079             : 
    2080             :     // Absolut Positioniert mit Durchlauf
    2081           0 :     rFrmItemSet.Put( SwFmtHoriOrient( nHoriPos, eHoriOri, eHoriRel ) );
    2082           0 :     rFrmItemSet.Put( SwFmtVertOrient( nVertPos, eVertOri, eVertRel ) );
    2083           0 :     rFrmItemSet.Put( SwFmtSurround( eSurround ) );
    2084           0 : }
    2085             : 
    2086           0 : void SwHTMLParser::SetVarSize( SfxItemSet & /*rItemSet*/,
    2087             :                                SvxCSS1PropertyInfo &rPropInfo,
    2088             :                                SfxItemSet &rFrmItemSet,
    2089             :                                SwTwips nDfltWidth, sal_uInt8 nDfltPrcWidth )
    2090             : {
    2091           0 :     SwFrmSize eSize = ATT_MIN_SIZE;
    2092           0 :     SwTwips nWidth = nDfltWidth, nHeight = MINFLY;
    2093           0 :     sal_uInt8 nPrcWidth = nDfltPrcWidth, nPrcHeight = 0;
    2094           0 :     switch( rPropInfo.eWidthType )
    2095             :     {
    2096             :     case SVX_CSS1_LTYPE_PERCENTAGE:
    2097           0 :         nPrcWidth = rPropInfo.nWidth > 0 ? (sal_uInt8)rPropInfo.nWidth : 1;
    2098           0 :         nWidth = MINFLY;
    2099           0 :         break;
    2100             :     case SVX_CSS1_LTYPE_TWIP:
    2101           0 :         nWidth = rPropInfo.nWidth > MINFLY ? rPropInfo.nWidth : MINFLY;
    2102           0 :         nPrcWidth = 0;
    2103           0 :         break;
    2104             :     default:
    2105             :         ;
    2106             :     }
    2107           0 :     switch( rPropInfo.eHeightType )
    2108             :     {
    2109             :     case SVX_CSS1_LTYPE_PERCENTAGE:
    2110           0 :         nPrcHeight = rPropInfo.nHeight > 0 ? (sal_uInt8)rPropInfo.nHeight : 1;
    2111           0 :         break;
    2112             :     case SVX_CSS1_LTYPE_TWIP:
    2113             :         // Netscape und MS-IE interpretieren die Hoehe regelwiedrig
    2114             :         // als Mindest-Hoehe, also machwn wir das auch so.
    2115           0 :         nHeight = rPropInfo.nHeight > MINFLY ? rPropInfo.nHeight : MINFLY;
    2116           0 :         break;
    2117             :     default:
    2118             :         ;
    2119             :     }
    2120             : 
    2121           0 :     SwFmtFrmSize aFrmSize( eSize, nWidth, nHeight );
    2122           0 :     aFrmSize.SetWidthPercent( nPrcWidth );
    2123           0 :     aFrmSize.SetHeightPercent( nPrcHeight );
    2124           0 :     rFrmItemSet.Put( aFrmSize );
    2125           0 : }
    2126             : 
    2127           0 : void SwHTMLParser::SetFrmFmtAttrs( SfxItemSet &rItemSet,
    2128             :                                    SvxCSS1PropertyInfo & /*rPropInfo*/,
    2129             :                                    sal_uInt16 nFlags,
    2130             :                                    SfxItemSet &rFrmItemSet )
    2131             : {
    2132             :     const SfxPoolItem *pItem;
    2133           0 :     if( (nFlags & HTML_FF_BOX) != 0 &&
    2134           0 :         SFX_ITEM_SET==rItemSet.GetItemState( RES_BOX, sal_True, &pItem ) )
    2135             :     {
    2136           0 :         if( (nFlags & HTML_FF_PADDING) == 0 )
    2137             :         {
    2138           0 :             SvxBoxItem aBoxItem( *(const SvxBoxItem *)pItem );
    2139             :             // Alle 4 Seiten gleichzeitig auf 0 setzen
    2140           0 :             aBoxItem.SetDistance( 0 );
    2141           0 :             rFrmItemSet.Put( aBoxItem );
    2142             :         }
    2143             :         else
    2144             :         {
    2145           0 :             rFrmItemSet.Put( *pItem );
    2146             :         }
    2147           0 :         rItemSet.ClearItem( RES_BOX );
    2148             :     }
    2149             : 
    2150           0 :     if( (nFlags & HTML_FF_BACKGROUND) != 0 &&
    2151           0 :         SFX_ITEM_SET==rItemSet.GetItemState( RES_BACKGROUND, sal_True, &pItem ) )
    2152             :     {
    2153           0 :         rFrmItemSet.Put( *pItem );
    2154           0 :         rItemSet.ClearItem( RES_BACKGROUND );
    2155             :     }
    2156             : 
    2157           0 :     if( (nFlags & HTML_FF_DIRECTION) != 0 &&
    2158           0 :         SFX_ITEM_SET==rItemSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem ) )
    2159             :     {
    2160           0 :         rFrmItemSet.Put( *pItem );
    2161           0 :         rItemSet.ClearItem( RES_FRAMEDIR );
    2162             :     }
    2163           0 : }
    2164             : 
    2165             : 
    2166             : 
    2167           0 : _HTMLAttrContext *SwHTMLParser::PopContext( sal_uInt16 nToken, sal_uInt16 nLimit,
    2168             :                                             sal_Bool bRemove )
    2169             : {
    2170           0 :     sal_uInt16 nPos = aContexts.size();
    2171           0 :     if( nPos <= nContextStMin )
    2172           0 :         return 0;
    2173             : 
    2174           0 :     sal_Bool bFound = 0==nToken;
    2175           0 :     if( nToken )
    2176             :     {
    2177             :         // Stack-Eintrag zu dem Token suchen
    2178           0 :         while( nPos > nContextStMin )
    2179             :         {
    2180           0 :             sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
    2181           0 :             if( nCntxtToken == nToken )
    2182             :             {
    2183           0 :                 bFound = sal_True;
    2184           0 :                 break;
    2185             :             }
    2186           0 :             else if( nCntxtToken == nLimit ) // 0 als Token kommt nicht vor
    2187             :             {
    2188           0 :                 break;
    2189             :             }
    2190             :         }
    2191             :     }
    2192             :     else
    2193             :     {
    2194           0 :         nPos--;
    2195             :     }
    2196             : 
    2197           0 :     _HTMLAttrContext *pCntxt = 0;
    2198           0 :     if( bFound )
    2199             :     {
    2200           0 :         pCntxt = aContexts[nPos];
    2201           0 :         if( bRemove )
    2202           0 :             aContexts.erase( aContexts.begin() + nPos );
    2203             :     }
    2204             : 
    2205           0 :     return pCntxt;
    2206             : }
    2207             : 
    2208           0 : sal_Bool SwHTMLParser::GetMarginsFromContext( sal_uInt16& nLeft,
    2209             :                                           sal_uInt16& nRight,
    2210             :                                           short& nIndent,
    2211             :                                           sal_Bool bIgnoreTopContext ) const
    2212             : {
    2213           0 :     sal_uInt16 nPos = aContexts.size();
    2214           0 :     if( bIgnoreTopContext )
    2215             :     {
    2216           0 :         if( !nPos )
    2217           0 :             return sal_False;
    2218             :         else
    2219           0 :             nPos--;
    2220             :     }
    2221             : 
    2222           0 :     while( nPos > nContextStAttrMin )
    2223             :     {
    2224           0 :         const _HTMLAttrContext *pCntxt = aContexts[--nPos];
    2225           0 :         if( pCntxt->IsLRSpaceChanged() )
    2226             :         {
    2227           0 :             pCntxt->GetMargins( nLeft, nRight, nIndent );
    2228           0 :             return sal_True;
    2229             :         }
    2230             :     }
    2231             : 
    2232           0 :     return sal_False;
    2233             : }
    2234             : 
    2235           0 : sal_Bool SwHTMLParser::GetMarginsFromContextWithNumBul( sal_uInt16& nLeft,
    2236             :                                                     sal_uInt16& nRight,
    2237             :                                                     short& nIndent ) const
    2238             : {
    2239           0 :     sal_Bool bRet = GetMarginsFromContext( nLeft, nRight, nIndent );
    2240           0 :     const SwHTMLNumRuleInfo& rInfo = ((SwHTMLParser*)this)->GetNumInfo();
    2241           0 :     if( rInfo.GetDepth() )
    2242             :     {
    2243           0 :         sal_uInt8 nLevel = (sal_uInt8)( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
    2244           0 :                                                             : MAXLEVEL) - 1 );
    2245           0 :         const SwNumFmt& rNumFmt = rInfo.GetNumRule()->Get(nLevel);
    2246           0 :         nLeft = nLeft + rNumFmt.GetAbsLSpace();
    2247           0 :         nIndent = rNumFmt.GetFirstLineOffset();
    2248             :     }
    2249             : 
    2250           0 :     return bRet;
    2251             : }
    2252             : 
    2253           0 : void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
    2254             :                                           sal_uInt16& nLower ) const
    2255             : {
    2256           0 :     sal_uInt16 nDfltColl = 0;
    2257           0 :     String aDfltClass;
    2258             : 
    2259           0 :     sal_uInt16 nPos = aContexts.size();
    2260           0 :     while( nPos > nContextStAttrMin )
    2261             :     {
    2262           0 :         const _HTMLAttrContext *pCntxt = aContexts[--nPos];
    2263           0 :         if( pCntxt->IsULSpaceChanged() )
    2264             :         {
    2265           0 :             pCntxt->GetULSpace( nUpper, nLower );
    2266           0 :             return;
    2267             :         }
    2268           0 :         else if( !nDfltColl )
    2269             :         {
    2270           0 :             nDfltColl = pCntxt->GetDfltTxtFmtColl();
    2271           0 :             if( nDfltColl )
    2272           0 :                 aDfltClass = pCntxt->GetClass();
    2273             :         }
    2274             :     }
    2275             : 
    2276           0 :     if( !nDfltColl )
    2277           0 :         nDfltColl = RES_POOLCOLL_TEXT;
    2278             : 
    2279             :     const SwTxtFmtColl *pColl =
    2280           0 :         pCSS1Parser->GetTxtFmtColl( nDfltColl, aDfltClass );
    2281           0 :     const SvxULSpaceItem& rULSpace = pColl->GetULSpace();
    2282           0 :     nUpper = rULSpace.GetUpper();
    2283           0 :     nLower = rULSpace.GetLower();
    2284             : }
    2285             : 
    2286           0 : void SwHTMLParser::EndContextAttrs( _HTMLAttrContext *pContext, sal_Bool bRemove )
    2287             : {
    2288           0 :     _HTMLAttrs &rAttrs = pContext->GetAttrs();
    2289           0 :     for( sal_uInt16 i=0; i<rAttrs.size(); i++ )
    2290             :     {
    2291           0 :         _HTMLAttr *pAttr = rAttrs[i];
    2292             : 
    2293           0 :         if( RES_PARATR_DROP==pAttr->GetItem().Which() )
    2294             :         {
    2295             :             // Fuer DropCaps noch die Anzahl der Zeichen anpassen. Wenn
    2296             :             // es am Ende 0 sind, wird das Attribut invalidiert und dann
    2297             :             // von _SetAttr gar nicht erst gesetzt.
    2298           0 :             xub_StrLen nChars = pPam->GetPoint()->nContent.GetIndex();
    2299           0 :             if( nChars < 1 )
    2300           0 :                 pAttr->Invalidate();
    2301           0 :             else if( nChars > MAX_DROPCAP_CHARS )
    2302           0 :                 nChars = MAX_DROPCAP_CHARS;
    2303           0 :             ((SwFmtDrop&)pAttr->GetItem()).GetChars() = (sal_uInt8)nChars;
    2304             :         }
    2305             : 
    2306           0 :         EndAttr( pAttr );
    2307             :     }
    2308             : 
    2309           0 :     if( bRemove && !rAttrs.empty() )
    2310           0 :         rAttrs.clear();
    2311           0 : }
    2312             : 
    2313           0 : void SwHTMLParser::InsertParaAttrs( const SfxItemSet& rItemSet )
    2314             : {
    2315           0 :     SfxItemIter aIter( rItemSet );
    2316             : 
    2317           0 :     const SfxPoolItem *pItem = aIter.FirstItem();
    2318           0 :     while( pItem )
    2319             :     {
    2320             :         // den zu dem Item gehoehrenden Tabellen-Eintrag ermitteln ...
    2321           0 :         sal_uInt16 nWhich = pItem->Which();
    2322           0 :         _HTMLAttr **ppAttr = GetAttrTabEntry( nWhich );
    2323             : 
    2324           0 :         if( ppAttr )
    2325             :         {
    2326           0 :             NewAttr( ppAttr, *pItem );
    2327           0 :             if( RES_PARATR_BEGIN > nWhich )
    2328           0 :                 (*ppAttr)->SetLikePara();
    2329           0 :             aParaAttrs.push_back( *ppAttr );
    2330           0 :             EndAttr( *ppAttr, 0, sal_False );
    2331             :         }
    2332             : 
    2333           0 :         pItem = aIter.NextItem();
    2334           0 :     }
    2335           0 : }
    2336             : 
    2337           0 : static void lcl_swcss1_setEncoding( SwFmt& rFmt, rtl_TextEncoding eEnc )
    2338             : {
    2339           0 :     if( RTL_TEXTENCODING_DONTKNOW == eEnc )
    2340           0 :         return;
    2341             : 
    2342           0 :     const SfxItemSet& rItemSet = rFmt.GetAttrSet();
    2343             :     static sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
    2344             :                                    RES_CHRATR_CTL_FONT };
    2345             :     const SfxPoolItem *pItem;
    2346           0 :     for( sal_uInt16 i=0; i<3; i++ )
    2347             :     {
    2348           0 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aWhichIds[i], sal_False,&pItem ) )
    2349             :         {
    2350           0 :             const SvxFontItem& rFont = *(const SvxFontItem *)pItem;
    2351           0 :             if( RTL_TEXTENCODING_SYMBOL != rFont.GetCharSet() )
    2352             :             {
    2353           0 :                 SvxFontItem aFont( rFont.GetFamily(), rFont.GetFamilyName(),
    2354           0 :                                    rFont.GetStyleName(), rFont.GetPitch(),
    2355           0 :                                    eEnc, aWhichIds[i]);
    2356           0 :                 rFmt.SetFmtAttr( aFont );
    2357             :             }
    2358             :         }
    2359             :     }
    2360             : }
    2361             : 
    2362           0 : void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
    2363             : {
    2364           0 :     if( eEnc != GetDfltEncoding() )
    2365             :     {
    2366           0 :         if( bIsNewDoc )
    2367             :         {
    2368             :             // Set new encoding as pool default
    2369             :             static sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
    2370             :                                            RES_CHRATR_CTL_FONT };
    2371             :             sal_uInt16 i;
    2372           0 :             for( i=0; i<3; i++ )
    2373             :             {
    2374             :                 const SvxFontItem& rDfltFont =
    2375           0 :                     (const SvxFontItem&)pDoc->GetDefault( aWhichIds[i]);
    2376             :                 SvxFontItem aFont( rDfltFont.GetFamily(),
    2377           0 :                                    rDfltFont.GetFamilyName(),
    2378           0 :                                    rDfltFont.GetStyleName(),
    2379             :                                    rDfltFont.GetPitch(),
    2380           0 :                                    eEnc, aWhichIds[i] );
    2381           0 :                 pDoc->SetDefault( aFont );
    2382           0 :             }
    2383             : 
    2384             :             // Change all paragraph styles that do specify a font.
    2385           0 :             sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->size();
    2386           0 :             for( i=1; i<nArrLen; i++ )
    2387           0 :                 lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i], eEnc );
    2388             : 
    2389             :             // Change all character styles that do specify a font.
    2390           0 :             nArrLen = pDoc->GetCharFmts()->size();
    2391           0 :             for( i=1; i<nArrLen; i++ )
    2392           0 :                 lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i], eEnc );
    2393             :         }
    2394             : 
    2395           0 :         SvxCSS1Parser::SetDfltEncoding( eEnc );
    2396             :     }
    2397          30 : }
    2398             : 
    2399             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10