LCOV - code coverage report
Current view: top level - sw/source/filter/html - svxcss1.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 655 1374 47.7 %
Date: 2014-04-11 Functions: 65 100 65.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdlib.h>
      21             : 
      22             : #include <svx/svxids.hrc>
      23             : #include <i18nlangtag/languagetag.hxx>
      24             : #include <svtools/ctrltool.hxx>
      25             : #include <svl/urihelper.hxx>
      26             : #include <editeng/udlnitem.hxx>
      27             : #include <editeng/adjustitem.hxx>
      28             : #include <editeng/blinkitem.hxx>
      29             : #include <editeng/crossedoutitem.hxx>
      30             : #include <editeng/kernitem.hxx>
      31             : #include <editeng/lspcitem.hxx>
      32             : #include <editeng/fontitem.hxx>
      33             : #include <editeng/postitem.hxx>
      34             : #include <editeng/colritem.hxx>
      35             : #include <editeng/cmapitem.hxx>
      36             : #include <editeng/brushitem.hxx>
      37             : #include <editeng/wghtitem.hxx>
      38             : #include <editeng/fhgtitem.hxx>
      39             : #include <editeng/boxitem.hxx>
      40             : #include <editeng/ulspitem.hxx>
      41             : #include <editeng/lrspitem.hxx>
      42             : #include <editeng/langitem.hxx>
      43             : #include <svl/itempool.hxx>
      44             : #include <editeng/spltitem.hxx>
      45             : #include <editeng/widwitem.hxx>
      46             : #include <editeng/frmdiritem.hxx>
      47             : #include <editeng/orphitem.hxx>
      48             : #include <svtools/svparser.hxx>
      49             : #include <vcl/svapp.hxx>
      50             : #include <vcl/wrkwin.hxx>
      51             : 
      52             : #include "css1kywd.hxx"
      53             : #include "svxcss1.hxx"
      54             : 
      55             : #include <memory>
      56             : 
      57             : using namespace ::com::sun::star;
      58             : 
      59             : // die Funktionen zum Parsen einer CSS1-Property sind von folgendem Typ:
      60             : typedef void (*FnParseCSS1Prop)( const CSS1Expression *pExpr,
      61             :                                  SfxItemSet& rItemSet,
      62             :                                  SvxCSS1PropertyInfo& rPropInfo,
      63             :                                  const SvxCSS1Parser& rParser );
      64             : 
      65             : static CSS1PropertyEnum const aFontSizeTable[] =
      66             : {
      67             :     { "xx-small",    0                   },
      68             :     { "x-small",     1                   },
      69             :     { "small",       2                   },
      70             :     { "medium",      3                   },
      71             :     { "large",       4                   },
      72             :     { "x-large",     5                   },
      73             :     { "xx-large",    6                   },
      74             :     { 0,                    0                   }
      75             : };
      76             : 
      77             : static CSS1PropertyEnum const aFontWeightTable[] =
      78             : {
      79             :     { "extra-light", WEIGHT_NORMAL       }, // WEIGHT_ULTRALIGHT (OBS)
      80             :     { "light",       WEIGHT_NORMAL       }, // WEIGHT_LIGHT (OBSOLETE)
      81             :     { "demi-light",  WEIGHT_NORMAL       }, // WEIGHT_SEMILIGHT (OBS)
      82             :     { "medium",      WEIGHT_NORMAL       }, // WEIGHT_MEDIUM (OBS)
      83             :     { "normal",      WEIGHT_NORMAL       }, // WEIGHT_MEDIUM
      84             :     { "demi-bold",   WEIGHT_NORMAL       }, // WEIGHT_SEMIBOLD (OBS)
      85             :     { "bold",        WEIGHT_BOLD         }, // WEIGHT_BOLD (OBSOLETE)
      86             :     { "extra-bold",  WEIGHT_BOLD         }, // WEIGHT_ULTRABOLD (OBS)
      87             :     { "bolder",      WEIGHT_BOLD         },
      88             :     { "lighter",     WEIGHT_NORMAL       },
      89             :     { 0,                    0                   }
      90             : };
      91             : 
      92             : static CSS1PropertyEnum const aFontStyleTable[] =
      93             : {
      94             :     { "normal",      ITALIC_NONE         },
      95             :     { "italic",      ITALIC_NORMAL       },
      96             :     { "oblique",     ITALIC_NORMAL       },
      97             :     { 0,                    0                   }
      98             : };
      99             : 
     100             : static CSS1PropertyEnum const aFontVariantTable[] =
     101             : {
     102             :     { "normal",      SVX_CASEMAP_NOT_MAPPED      },
     103             :     { "small-caps",  SVX_CASEMAP_KAPITAELCHEN    },
     104             :     { 0,                    0                   }
     105             : };
     106             : 
     107             : static CSS1PropertyEnum const aTextTransformTable[] =
     108             : {
     109             :     { "uppercase",  SVX_CASEMAP_VERSALIEN },
     110             :     { "lowercase",  SVX_CASEMAP_GEMEINE   },
     111             :     { "capitalize", SVX_CASEMAP_TITEL     },
     112             :     { 0,                   0                     }
     113             : };
     114             : 
     115             : static CSS1PropertyEnum const aDirectionTable[] =
     116             : {
     117             :     { "ltr",         FRMDIR_HORI_LEFT_TOP        },
     118             :     { "rtl",         FRMDIR_HORI_RIGHT_TOP       },
     119             :     { "inherit",     FRMDIR_ENVIRONMENT          },
     120             :     { 0,                    0                   }
     121             : };
     122             : 
     123             : static CSS1PropertyEnum const aBGRepeatTable[] =
     124             : {
     125             :     { "repeat",      GPOS_TILED                  },
     126             :     { "repeat-x",    GPOS_TILED                  },
     127             :     { "repeat-y",    GPOS_TILED                  },
     128             :     { "no-repeat",   GPOS_NONE                   },
     129             :     { 0,                    0                           }
     130             : };
     131             : 
     132             : static CSS1PropertyEnum const aBGHoriPosTable[] =
     133             : {
     134             :     { "left",        GPOS_LT                 },
     135             :     { "center",      GPOS_MT                 },
     136             :     { "right",       GPOS_RT                 },
     137             :     { 0,                    0                       }
     138             : };
     139             : 
     140             : static CSS1PropertyEnum const aBGVertPosTable[] =
     141             : {
     142             :     { "top",         GPOS_LT                 },
     143             :     { "middle",      GPOS_LM                 },
     144             :     { "bottom",      GPOS_LB                 },
     145             :     { 0,                    0                       }
     146             : };
     147             : 
     148             : static CSS1PropertyEnum const aTextAlignTable[] =
     149             : {
     150             :     { "left",        SVX_ADJUST_LEFT     },
     151             :     { "center",      SVX_ADJUST_CENTER   },
     152             :     { "right",       SVX_ADJUST_RIGHT    },
     153             :     { "justify",     SVX_ADJUST_BLOCK    },
     154             :     { 0,                    0                   }
     155             : };
     156             : 
     157             : static CSS1PropertyEnum const aBorderWidthTable[] =
     158             : {
     159             :     { "thin",        0   },  // DEF_LINE_WIDTH_0 / DEF_DOUBLE_LINE0
     160             :     { "medium",      1   },  // DEF_LINE_WIDTH_1 / DEF_DOUBLE_LINE1
     161             :     { "thick",       2   },  // DEF_LINE_WIDTH_2 / DEF_DOUBLE_LINE2
     162             :     { 0,                    0   }
     163             : };
     164             : 
     165             : enum CSS1BorderStyle { CSS1_BS_NONE, CSS1_BS_SINGLE, CSS1_BS_DOUBLE, CSS1_BS_DOTTED, CSS1_BS_DASHED, CSS1_BS_GROOVE, CSS1_BS_RIDGE, CSS1_BS_INSET, CSS1_BS_OUTSET };
     166             : 
     167             : static CSS1PropertyEnum const aBorderStyleTable[] =
     168             : {
     169             :     { "none",        CSS1_BS_NONE        },
     170             :     { "dotted",      CSS1_BS_DOTTED      },
     171             :     { "dashed",      CSS1_BS_DASHED      },
     172             :     { "solid",       CSS1_BS_SINGLE      },
     173             :     { "double",      CSS1_BS_DOUBLE      },
     174             :     { "groove",      CSS1_BS_GROOVE      },
     175             :     { "ridge",       CSS1_BS_RIDGE       },
     176             :     { "inset",       CSS1_BS_INSET       },
     177             :     { "outset",      CSS1_BS_OUTSET      },
     178             :     { 0,                    0                   }
     179             : };
     180             : 
     181             : static CSS1PropertyEnum const aFloatTable[] =
     182             : {
     183             :     { "left",    SVX_ADJUST_LEFT         },
     184             :     { "right",   SVX_ADJUST_RIGHT        },
     185             :     { "none",    SVX_ADJUST_END          },
     186             :     { 0,                0                       }
     187             : };
     188             : 
     189             : static CSS1PropertyEnum const aPositionTable[] =
     190             : {
     191             :     { "absolute",    SVX_CSS1_POS_ABSOLUTE   },
     192             :     { "relative",    SVX_CSS1_POS_RELATIVE   },
     193             :     { "static",      SVX_CSS1_POS_STATIC     },
     194             :     { 0,                    0                       }
     195             : };
     196             : 
     197             : // Feature: PrintExt
     198             : static CSS1PropertyEnum const aSizeTable[] =
     199             : {
     200             :     { "auto",        SVX_CSS1_STYPE_AUTO         },
     201             :     { "landscape",   SVX_CSS1_STYPE_LANDSCAPE    },
     202             :     { "portrait",    SVX_CSS1_STYPE_PORTRAIT     },
     203             :     { 0,                    0                           }
     204             : };
     205             : 
     206             : static CSS1PropertyEnum const aPageBreakTable[] =
     207             : {
     208             :     { "auto",        SVX_CSS1_PBREAK_AUTO        },
     209             :     { "always",      SVX_CSS1_PBREAK_ALWAYS      },
     210             :     { "avoid",       SVX_CSS1_PBREAK_AVOID       },
     211             :     { "left",        SVX_CSS1_PBREAK_LEFT        },
     212             :     { "right",       SVX_CSS1_PBREAK_RIGHT       },
     213             :     { 0,                    0                           }
     214             : };
     215             : 
     216             : // /Feature: PrintExt
     217             : 
     218             : static sal_uInt16 const aBorderWidths[] =
     219             : {
     220             :     DEF_LINE_WIDTH_0,
     221             :     DEF_LINE_WIDTH_5,
     222             :     DEF_LINE_WIDTH_1
     223             : };
     224             : 
     225             : #undef SBORDER_ENTRY
     226             : #undef DBORDER_ENTRY
     227             : 
     228             : struct SvxCSS1ItemIds
     229             : {
     230             :     sal_uInt16 nFont;
     231             :     sal_uInt16 nFontCJK;
     232             :     sal_uInt16 nFontCTL;
     233             :     sal_uInt16 nPosture;
     234             :     sal_uInt16 nPostureCJK;
     235             :     sal_uInt16 nPostureCTL;
     236             :     sal_uInt16 nWeight;
     237             :     sal_uInt16 nWeightCJK;
     238             :     sal_uInt16 nWeightCTL;
     239             :     sal_uInt16 nFontHeight;
     240             :     sal_uInt16 nFontHeightCJK;
     241             :     sal_uInt16 nFontHeightCTL;
     242             :     sal_uInt16 nUnderline;
     243             :     sal_uInt16 nOverline;
     244             :     sal_uInt16 nCrossedOut;
     245             :     sal_uInt16 nColor;
     246             :     sal_uInt16 nKerning;
     247             :     sal_uInt16 nCaseMap;
     248             :     sal_uInt16 nBlink;
     249             : 
     250             :     sal_uInt16 nLineSpacing;
     251             :     sal_uInt16 nAdjust;
     252             :     sal_uInt16 nWidows;
     253             :     sal_uInt16 nOrphans;
     254             :     sal_uInt16 nFmtSplit;
     255             : 
     256             :     sal_uInt16 nLRSpace;
     257             :     sal_uInt16 nULSpace;
     258             :     sal_uInt16 nBox;
     259             :     sal_uInt16 nBrush;
     260             : 
     261             :     sal_uInt16 nLanguage;
     262             :     sal_uInt16 nLanguageCJK;
     263             :     sal_uInt16 nLanguageCTL;
     264             :     sal_uInt16 nDirection;
     265             : };
     266             : 
     267             : static SvxCSS1ItemIds aItemIds;
     268             : 
     269             : struct SvxCSS1BorderInfo
     270             : {
     271             :     Color aColor;
     272             :     sal_uInt16 nAbsWidth;
     273             :     sal_uInt16 nNamedWidth;
     274             :     CSS1BorderStyle eStyle;
     275             : 
     276        2084 :     SvxCSS1BorderInfo() :
     277             :         aColor( COL_BLACK ), nAbsWidth( USHRT_MAX ),
     278        2084 :         nNamedWidth( USHRT_MAX ), eStyle( CSS1_BS_NONE )
     279        2084 :     {}
     280             : 
     281           0 :     SvxCSS1BorderInfo( const SvxCSS1BorderInfo& rInfo ) :
     282             :         aColor( rInfo.aColor ), nAbsWidth( rInfo.nAbsWidth ),
     283           0 :         nNamedWidth( rInfo.nNamedWidth ), eStyle( rInfo.eStyle )
     284           0 :     {}
     285             : 
     286             :     void SetBorderLine( sal_uInt16 nLine, SvxBoxItem &rBoxItem ) const;
     287             : };
     288             : 
     289        1044 : void SvxCSS1BorderInfo::SetBorderLine( sal_uInt16 nLine, SvxBoxItem &rBoxItem ) const
     290             : {
     291        2088 :     if( CSS1_BS_NONE==eStyle || nAbsWidth==0 ||
     292        1044 :         (nAbsWidth==USHRT_MAX && nNamedWidth==USHRT_MAX) )
     293             :     {
     294           0 :         rBoxItem.SetLine( 0, nLine );
     295        1044 :         return;
     296             :     }
     297             : 
     298        1044 :     ::editeng::SvxBorderLine aBorderLine( &aColor );
     299             : 
     300             :     // Linien-Stil doppelt oder einfach?
     301        1044 :     switch ( eStyle )
     302             :     {
     303             :         case CSS1_BS_SINGLE:
     304        1041 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
     305        1041 :             break;
     306             :         case CSS1_BS_DOUBLE:
     307           1 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
     308           1 :             break;
     309             :         case CSS1_BS_DOTTED:
     310           1 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOTTED);
     311           1 :             break;
     312             :         case CSS1_BS_DASHED:
     313           1 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DASHED);
     314           1 :             break;
     315             :         case CSS1_BS_GROOVE:
     316           0 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::ENGRAVED);
     317           0 :             break;
     318             :         case CSS1_BS_RIDGE:
     319           0 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::EMBOSSED);
     320           0 :             break;
     321             :         case CSS1_BS_INSET:
     322           0 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::INSET);
     323           0 :             break;
     324             :         case CSS1_BS_OUTSET:
     325           0 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::OUTSET);
     326           0 :             break;
     327             :         default:
     328           0 :             aBorderLine.SetBorderLineStyle(table::BorderLineStyle::NONE);
     329           0 :             break;
     330             :     }
     331             : 
     332             :     // benannte Breite umrechnenen, wenn keine absolute gegeben ist
     333        1044 :     if( nAbsWidth==USHRT_MAX )
     334           0 :         aBorderLine.SetWidth( aBorderWidths[ nNamedWidth ] );
     335             :     else
     336        1044 :         aBorderLine.SetWidth( nAbsWidth );
     337             : 
     338        1044 :     rBoxItem.SetLine( &aBorderLine, nLine );
     339             : }
     340             : 
     341         832 : SvxCSS1PropertyInfo::SvxCSS1PropertyInfo()
     342             : {
     343        4160 :     for( sal_uInt16 i=0; i<4; i++ )
     344        3328 :         aBorderInfos[i] = 0;
     345             : 
     346         832 :     Clear();
     347         832 : }
     348             : 
     349           3 : SvxCSS1PropertyInfo::SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp ) :
     350             :     aId( rProp.aId ),
     351             :     bTopMargin( rProp.bTopMargin ),
     352             :     bBottomMargin( rProp.bBottomMargin ),
     353             :     bLeftMargin( rProp.bLeftMargin ),
     354             :     bRightMargin( rProp.bRightMargin ),
     355             :     bTextIndent( rProp.bTextIndent ),
     356             :     eFloat( rProp.eFloat ),
     357             :     ePosition( rProp.ePosition ),
     358             :     nTopBorderDistance( rProp.nTopBorderDistance ),
     359             :     nBottomBorderDistance( rProp.nBottomBorderDistance ),
     360             :     nLeftBorderDistance( rProp.nLeftBorderDistance ),
     361             :     nRightBorderDistance( rProp.nRightBorderDistance ),
     362             :     nColumnCount( rProp.nColumnCount ),
     363             :     nLeft( rProp.nLeft ),
     364             :     nTop( rProp.nTop ),
     365             :     nWidth( rProp.nWidth ),
     366             :     nHeight( rProp.nHeight ),
     367             :     nLeftMargin( rProp.nLeftMargin ),
     368             :     nRightMargin( rProp.nRightMargin ),
     369             :     eLeftType( rProp.eLeftType ),
     370             :     eTopType( rProp.eTopType ),
     371             :     eWidthType( rProp.eWidthType ),
     372             :     eHeightType( rProp.eHeightType ),
     373             : // Feature: PrintExt
     374             :     eSizeType( rProp.eSizeType ),
     375             :     ePageBreakBefore( rProp.ePageBreakBefore ),
     376           3 :     ePageBreakAfter( rProp.ePageBreakAfter )
     377             : // /Feature: PrintExt
     378             : {
     379          15 :     for( sal_uInt16 i=0; i<4; i++ )
     380          24 :         aBorderInfos[i] = rProp.aBorderInfos[i]
     381           0 :                             ? new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] )
     382          24 :                             : 0;
     383           3 : }
     384             : 
     385        1670 : SvxCSS1PropertyInfo::~SvxCSS1PropertyInfo()
     386             : {
     387         835 :     DestroyBorderInfos();
     388         835 : }
     389             : 
     390        1938 : void SvxCSS1PropertyInfo::DestroyBorderInfos()
     391             : {
     392        9690 :     for( sal_uInt16 i=0; i<4; i++ )
     393             :     {
     394        7752 :         delete aBorderInfos[i];
     395        7752 :         aBorderInfos[i] = 0;
     396             :     }
     397        1938 : }
     398             : 
     399         842 : void SvxCSS1PropertyInfo::Clear()
     400             : {
     401         842 :     aId = "";
     402         842 :     bTopMargin = bBottomMargin = sal_False;
     403         842 :     bLeftMargin = bRightMargin = bTextIndent = sal_False;
     404         842 :     nLeftMargin = nRightMargin = 0;
     405         842 :     eFloat = SVX_ADJUST_END;
     406             : 
     407         842 :     ePosition = SVX_CSS1_POS_NONE;
     408             :     nTopBorderDistance = nBottomBorderDistance =
     409         842 :     nLeftBorderDistance = nRightBorderDistance = USHRT_MAX;
     410             : 
     411         842 :     nColumnCount = 0;
     412             : 
     413         842 :     nLeft = nTop = nWidth = nHeight = 0;
     414         842 :     eLeftType = eTopType = eWidthType = eHeightType = SVX_CSS1_LTYPE_NONE;
     415             : 
     416             : // Feature: PrintExt
     417         842 :     eSizeType = SVX_CSS1_STYPE_NONE;
     418         842 :     ePageBreakBefore = SVX_CSS1_PBREAK_NONE;
     419         842 :     ePageBreakAfter = SVX_CSS1_PBREAK_NONE;
     420             : 
     421         842 :     DestroyBorderInfos();
     422         842 : }
     423             : 
     424           0 : void SvxCSS1PropertyInfo::Merge( const SvxCSS1PropertyInfo& rProp )
     425             : {
     426           0 :     if( rProp.bTopMargin )
     427           0 :         bTopMargin = sal_True;
     428           0 :     if( rProp.bBottomMargin )
     429           0 :         bBottomMargin = sal_True;
     430             : 
     431           0 :     if( rProp.bLeftMargin )
     432             :     {
     433           0 :         bLeftMargin = sal_True;
     434           0 :         nLeftMargin = rProp.nLeftMargin;
     435             :     }
     436           0 :     if( rProp.bRightMargin )
     437             :     {
     438           0 :         bRightMargin = sal_True;
     439           0 :         nRightMargin = rProp.nRightMargin;
     440             :     }
     441           0 :     if( rProp.bTextIndent )
     442           0 :         bTextIndent = sal_True;
     443             : 
     444           0 :     for( sal_uInt16 i=0; i<4; i++ )
     445             :     {
     446           0 :         if( rProp.aBorderInfos[i] )
     447             :         {
     448           0 :             if( aBorderInfos[i] )
     449           0 :                 delete aBorderInfos[i];
     450             : 
     451           0 :             aBorderInfos[i] = new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] );
     452             :         }
     453             :     }
     454             : 
     455           0 :     if( USHRT_MAX != rProp.nTopBorderDistance )
     456           0 :         nTopBorderDistance = rProp.nTopBorderDistance;
     457           0 :     if( USHRT_MAX != rProp.nBottomBorderDistance )
     458           0 :         nBottomBorderDistance = rProp.nBottomBorderDistance;
     459           0 :     if( USHRT_MAX != rProp.nLeftBorderDistance )
     460           0 :         nLeftBorderDistance = rProp.nLeftBorderDistance;
     461           0 :     if( USHRT_MAX != rProp.nRightBorderDistance )
     462           0 :         nRightBorderDistance = rProp.nRightBorderDistance;
     463             : 
     464           0 :     nColumnCount = rProp.nColumnCount;
     465             : 
     466           0 :     if( rProp.eFloat != SVX_ADJUST_END )
     467           0 :         eFloat = rProp.eFloat;
     468             : 
     469           0 :     if( rProp.ePosition != SVX_CSS1_POS_NONE )
     470           0 :         ePosition = rProp.ePosition;
     471             : 
     472             : // Feature: PrintExt
     473           0 :     if( rProp.eSizeType != SVX_CSS1_STYPE_NONE )
     474             :     {
     475           0 :         eSizeType = rProp.eSizeType;
     476           0 :         nWidth = rProp.nWidth;
     477           0 :         nHeight = rProp.nHeight;
     478             :     }
     479             : 
     480           0 :     if( rProp.ePageBreakBefore != SVX_CSS1_PBREAK_NONE )
     481           0 :         ePageBreakBefore = rProp.ePageBreakBefore;
     482             : 
     483           0 :     if( rProp.ePageBreakAfter != SVX_CSS1_PBREAK_NONE )
     484           0 :         ePageBreakAfter = rProp.ePageBreakAfter;
     485             : 
     486             : // /Feature: PrintExt
     487             : 
     488           0 :     if( rProp.eLeftType != SVX_CSS1_LTYPE_NONE )
     489             :     {
     490           0 :         eLeftType = rProp.eLeftType;
     491           0 :         nLeft = rProp.nLeft;
     492             :     }
     493             : 
     494           0 :     if( rProp.eTopType != SVX_CSS1_LTYPE_NONE )
     495             :     {
     496           0 :         eTopType = rProp.eTopType;
     497           0 :         nTop = rProp.nTop;
     498             :     }
     499             : 
     500           0 :     if( rProp.eWidthType != SVX_CSS1_LTYPE_NONE )
     501             :     {
     502           0 :         eWidthType = rProp.eWidthType;
     503           0 :         nWidth = rProp.nWidth;
     504             :     }
     505             : 
     506           0 :     if( rProp.eHeightType != SVX_CSS1_LTYPE_NONE )
     507             :     {
     508           0 :         eHeightType = rProp.eHeightType;
     509           0 :         nHeight = rProp.nHeight;
     510             :     }
     511           0 : }
     512             : 
     513        3128 : SvxCSS1BorderInfo *SvxCSS1PropertyInfo::GetBorderInfo( sal_uInt16 nLine, sal_Bool bCreate )
     514             : {
     515        3128 :     sal_uInt16 nPos = 0;
     516        3128 :     switch( nLine )
     517             :     {
     518         782 :     case BOX_LINE_TOP:      nPos = 0;   break;
     519         782 :     case BOX_LINE_BOTTOM:   nPos = 1;   break;
     520         782 :     case BOX_LINE_LEFT:     nPos = 2;   break;
     521         782 :     case BOX_LINE_RIGHT:    nPos = 3;   break;
     522             :     }
     523             : 
     524        3128 :     if( !aBorderInfos[nPos] && bCreate )
     525        2084 :         aBorderInfos[nPos] = new SvxCSS1BorderInfo;
     526             : 
     527        3128 :     return aBorderInfos[nPos];
     528             : }
     529             : 
     530           0 : void SvxCSS1PropertyInfo::CopyBorderInfo( sal_uInt16 nSrcLine, sal_uInt16 nDstLine,
     531             :                                           sal_uInt16 nWhat )
     532             : {
     533           0 :     SvxCSS1BorderInfo *pSrcInfo = GetBorderInfo( nSrcLine, sal_False );
     534           0 :     if( !pSrcInfo )
     535           0 :         return;
     536             : 
     537           0 :     SvxCSS1BorderInfo *pDstInfo = GetBorderInfo( nDstLine );
     538           0 :     if( (nWhat & SVX_CSS1_BORDERINFO_WIDTH) != 0 )
     539             :     {
     540           0 :         pDstInfo->nAbsWidth = pSrcInfo->nAbsWidth;
     541           0 :         pDstInfo->nNamedWidth = pSrcInfo->nNamedWidth;
     542             :     }
     543             : 
     544           0 :     if( (nWhat & SVX_CSS1_BORDERINFO_COLOR) != 0 )
     545           0 :         pDstInfo->aColor = pSrcInfo->aColor;
     546             : 
     547           0 :     if( (nWhat & SVX_CSS1_BORDERINFO_STYLE) != 0 )
     548           0 :         pDstInfo->eStyle = pSrcInfo->eStyle;
     549             : }
     550             : 
     551           0 : void SvxCSS1PropertyInfo::CopyBorderInfo( sal_uInt16 nCount, sal_uInt16 nWhat )
     552             : {
     553           0 :     if( nCount==0 )
     554             :     {
     555           0 :         CopyBorderInfo( BOX_LINE_BOTTOM, BOX_LINE_TOP, nWhat );
     556           0 :         CopyBorderInfo( BOX_LINE_TOP, BOX_LINE_LEFT, nWhat );
     557             :     }
     558           0 :     if( nCount<=1 )
     559             :     {
     560           0 :         CopyBorderInfo( BOX_LINE_LEFT, BOX_LINE_RIGHT, nWhat );
     561             :     }
     562           0 : }
     563             : 
     564         504 : void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
     565             :                                       sal_uInt16 nMinBorderDist,
     566             :                                       const SvxBoxItem *pDfltItem,
     567             :                                       bool bTable )
     568             : {
     569         747 :     bool bChg = nTopBorderDistance != USHRT_MAX ||
     570         486 :                 nBottomBorderDistance != USHRT_MAX ||
     571         990 :                 nLeftBorderDistance != USHRT_MAX ||
     572         747 :                 nRightBorderDistance != USHRT_MAX;
     573             :     sal_uInt16 i;
     574             : 
     575        1476 :     for( i = 0; !bChg && i < 4; i++ )
     576         972 :         bChg = aBorderInfos[i]!=0;
     577             : 
     578         504 :     if( !bChg )
     579         747 :         return;
     580             : 
     581         261 :     SvxBoxItem aBoxItem( aItemIds.nBox );
     582         261 :     if( pDfltItem )
     583           0 :         aBoxItem = *pDfltItem;
     584             : 
     585         261 :     SvxCSS1BorderInfo *pInfo = GetBorderInfo( BOX_LINE_TOP, sal_False );
     586         261 :     if( pInfo )
     587         261 :         pInfo->SetBorderLine( BOX_LINE_TOP, aBoxItem );
     588             : 
     589         261 :     pInfo = GetBorderInfo( BOX_LINE_BOTTOM, sal_False );
     590         261 :     if( pInfo )
     591         261 :         pInfo->SetBorderLine( BOX_LINE_BOTTOM, aBoxItem );
     592             : 
     593         261 :     pInfo = GetBorderInfo( BOX_LINE_LEFT, sal_False );
     594         261 :     if( pInfo )
     595         261 :         pInfo->SetBorderLine( BOX_LINE_LEFT, aBoxItem );
     596             : 
     597         261 :     pInfo = GetBorderInfo( BOX_LINE_RIGHT, sal_False );
     598         261 :     if( pInfo )
     599         261 :         pInfo->SetBorderLine( BOX_LINE_RIGHT, aBoxItem );
     600             : 
     601        1305 :     for( i=0; i<4; i++ )
     602             :     {
     603        1044 :         sal_uInt16 nLine = BOX_LINE_TOP, nDist = 0;
     604        1044 :         switch( i )
     605             :         {
     606         261 :         case 0: nLine = BOX_LINE_TOP;
     607         261 :                 nDist = nTopBorderDistance;
     608         261 :                 nTopBorderDistance = USHRT_MAX;
     609         261 :                 break;
     610         261 :         case 1: nLine = BOX_LINE_BOTTOM;
     611         261 :                 nDist = nBottomBorderDistance;
     612         261 :                 nBottomBorderDistance = USHRT_MAX;
     613         261 :                 break;
     614         261 :         case 2: nLine = BOX_LINE_LEFT;
     615         261 :                 nDist = nLeftBorderDistance;
     616         261 :                 nLeftBorderDistance = USHRT_MAX;
     617         261 :                 break;
     618         261 :         case 3: nLine = BOX_LINE_RIGHT;
     619         261 :                 nDist = nRightBorderDistance;
     620         261 :                 nRightBorderDistance = USHRT_MAX;
     621         261 :                 break;
     622             :         }
     623             : 
     624        1044 :         if( aBoxItem.GetLine( nLine ) )
     625             :         {
     626        1044 :             if( USHRT_MAX == nDist )
     627           0 :                 nDist = aBoxItem.GetDistance( nLine );
     628             : 
     629        1044 :             if( nDist < nMinBorderDist )
     630           0 :                 nDist = nMinBorderDist;
     631             :         }
     632             :         else
     633             :         {
     634           0 :             if( USHRT_MAX == nDist )
     635           0 :                 nDist = aBoxItem.GetDistance( nLine );
     636             : 
     637           0 :             if( !bTable )
     638           0 :                 nDist = 0U;
     639           0 :             else if( nDist && nDist < nMinBorderDist )
     640           0 :                 nDist = nMinBorderDist;
     641             :         }
     642             : 
     643        1044 :         aBoxItem.SetDistance( nDist, nLine );
     644             :     }
     645             : 
     646         261 :     rItemSet.Put( aBoxItem );
     647             : 
     648         261 :     DestroyBorderInfos();
     649             : }
     650             : 
     651           3 : SvxCSS1MapEntry::SvxCSS1MapEntry( const OUString& rKey, const SfxItemSet& rItemSet,
     652             :                                   const SvxCSS1PropertyInfo& rProp ) :
     653             :     aKey( rKey.toAsciiUpperCase() ),
     654             :     aItemSet( rItemSet ),
     655           3 :     aPropInfo( rProp )
     656           3 : {}
     657             : 
     658           0 : sal_Bool SvxCSS1Parser::StyleParsed( const CSS1Selector * /*pSelector*/,
     659             :                                  SfxItemSet& /*rItemSet*/,
     660             :                                  SvxCSS1PropertyInfo& /*rPropInfo*/ )
     661             : {
     662             :     // wie man sieht passiert hier gar nichts
     663           0 :     return sal_True;
     664             : }
     665             : 
     666           8 : bool SvxCSS1Parser::SelectorParsed( CSS1Selector *pSelector, bool bFirst )
     667             : {
     668           8 :     if( bFirst )
     669             :     {
     670             :         OSL_ENSURE( pSheetItemSet, "Where is the Item-Set for Style-Sheets?" );
     671             : 
     672          14 :         for (size_t i = 0; i < aSelectors.size(); ++i)
     673             :         {
     674           6 :             StyleParsed( &aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
     675             :         }
     676           8 :         pSheetItemSet->ClearItem();
     677           8 :         pSheetPropInfo->Clear();
     678             : 
     679             :         // und die naechste Rule vorbereiten
     680           8 :         aSelectors.clear();
     681             :     }
     682             : 
     683           8 :     aSelectors.push_back(pSelector);
     684             : 
     685           8 :     return false; // den Selektor haben wir gespeichert. Loeschen toedlich!
     686             : }
     687             : 
     688        2867 : sal_Bool SvxCSS1Parser::DeclarationParsed( const OUString& rProperty,
     689             :                                        const CSS1Expression *pExpr )
     690             : {
     691             :     OSL_ENSURE( pExpr, "DeclarationParsed() without Expression" );
     692             : 
     693        2867 :     if( !pExpr )
     694           0 :         return sal_True;
     695             : 
     696        2867 :     ParseProperty( rProperty, pExpr );
     697             : 
     698        2867 :     return sal_True;    // die Deklaration brauchen wir nicht mehr. Loeschen!
     699             : }
     700             : 
     701           6 : SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, const OUString& rBaseURL, sal_uInt16 nMinFixLineSp,
     702             :                               sal_uInt16 *pWhichIds, sal_uInt16 nWhichIds ) :
     703             :     CSS1Parser(),
     704             :     sBaseURL( rBaseURL ),
     705             :     pSheetItemSet(0),
     706             :     pItemSet(0),
     707             :     pSearchEntry( 0 ),
     708             :     pPropInfo( 0 ),
     709             :     nMinFixLineSpace( nMinFixLineSp ),
     710             :     eDfltEnc( RTL_TEXTENCODING_DONTKNOW ),
     711             :     nScriptFlags( CSS1_SCRIPT_ALL ),
     712           6 :     bIgnoreFontFamily( sal_False )
     713             : {
     714             :     // Item-Ids auch initialisieren
     715           6 :     aItemIds.nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, false );
     716           6 :     aItemIds.nFontCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONT, false );
     717           6 :     aItemIds.nFontCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONT, false );
     718           6 :     aItemIds.nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, false );
     719           6 :     aItemIds.nPostureCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_POSTURE, false );
     720           6 :     aItemIds.nPostureCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_POSTURE, false );
     721           6 :     aItemIds.nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, false );
     722           6 :     aItemIds.nWeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT, false );
     723           6 :     aItemIds.nWeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT, false );
     724           6 :     aItemIds.nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, false );
     725           6 :     aItemIds.nFontHeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT, false );
     726           6 :     aItemIds.nFontHeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT, false );
     727           6 :     aItemIds.nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, false );
     728           6 :     aItemIds.nOverline = rPool.GetTrueWhich( SID_ATTR_CHAR_OVERLINE, false );
     729           6 :     aItemIds.nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, false );
     730           6 :     aItemIds.nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, false );
     731           6 :     aItemIds.nKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, false );
     732           6 :     aItemIds.nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, false );
     733           6 :     aItemIds.nBlink = rPool.GetTrueWhich( SID_ATTR_FLASH, false );
     734             : 
     735           6 :     aItemIds.nLineSpacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, false );
     736           6 :     aItemIds.nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, false );
     737           6 :     aItemIds.nWidows = rPool.GetTrueWhich( SID_ATTR_PARA_WIDOWS, false );
     738           6 :     aItemIds.nOrphans = rPool.GetTrueWhich( SID_ATTR_PARA_ORPHANS, false );
     739           6 :     aItemIds.nFmtSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, false );
     740             : 
     741           6 :     aItemIds.nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, false );
     742           6 :     aItemIds.nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, false );
     743           6 :     aItemIds.nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, false );
     744           6 :     aItemIds.nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, false );
     745             : 
     746           6 :     aItemIds.nLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_LANGUAGE, false );
     747           6 :     aItemIds.nLanguageCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE, false );
     748           6 :     aItemIds.nLanguageCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, false );
     749           6 :     aItemIds.nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false );
     750             : 
     751           6 :     aWhichMap.insert( aWhichMap.begin(), 0 );
     752             :     SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16 *)&aItemIds,
     753           6 :                              sizeof(aItemIds) / sizeof(sal_uInt16) );
     754           6 :     if( pWhichIds && nWhichIds )
     755           6 :         SvParser::BuildWhichTbl( aWhichMap, pWhichIds, nWhichIds );
     756             : 
     757           6 :     pSheetItemSet = new SfxItemSet( rPool, &aWhichMap[0] );
     758           6 :     pSheetPropInfo = new SvxCSS1PropertyInfo;
     759           6 :     pSearchEntry = new SvxCSS1MapEntry( rPool, &aWhichMap[0] );
     760           6 : }
     761             : 
     762          12 : SvxCSS1Parser::~SvxCSS1Parser()
     763             : {
     764           6 :     delete pSheetItemSet;
     765           6 :     delete pSheetPropInfo;
     766           6 :     delete pSearchEntry;
     767           6 : }
     768             : 
     769           0 : void SvxCSS1Parser::InsertId( const OUString& rId,
     770             :                               const SfxItemSet& rItemSet,
     771             :                               const SvxCSS1PropertyInfo& rProp )
     772             : {
     773           0 :     InsertMapEntry( rId, rItemSet, rProp, aIds );
     774           0 : }
     775             : 
     776          14 : const SvxCSS1MapEntry* SvxCSS1Parser::GetId( const OUString& rId ) const
     777             : {
     778          14 :     CSS1Map::const_iterator itr = aIds.find(rId);
     779          14 :     return itr == aIds.end() ? NULL : itr->second;
     780             : }
     781             : 
     782           0 : void SvxCSS1Parser::InsertClass( const OUString& rClass,
     783             :                                  const SfxItemSet& rItemSet,
     784             :                                  const SvxCSS1PropertyInfo& rProp )
     785             : {
     786           0 :     InsertMapEntry( rClass, rItemSet, rProp, aClasses );
     787           0 : }
     788             : 
     789          11 : const SvxCSS1MapEntry* SvxCSS1Parser::GetClass( const OUString& rClass ) const
     790             : {
     791          11 :     CSS1Map::const_iterator itr = aClasses.find(rClass);
     792          11 :     return itr == aClasses.end() ? NULL : itr->second;
     793             : }
     794             : 
     795           2 : void SvxCSS1Parser::InsertPage( const OUString& rPage,
     796             :                                 sal_Bool bPseudo,
     797             :                                 const SfxItemSet& rItemSet,
     798             :                                 const SvxCSS1PropertyInfo& rProp )
     799             : {
     800           2 :     OUString aKey( rPage );
     801           2 :     if( bPseudo )
     802           0 :         aKey = ":" + aKey;
     803           2 :     InsertMapEntry( aKey, rItemSet, rProp, aPages );
     804           2 : }
     805             : 
     806           8 : SvxCSS1MapEntry* SvxCSS1Parser::GetPage( const OUString& rPage, bool bPseudo )
     807             : {
     808           8 :     OUString aKey( rPage );
     809           8 :     if( bPseudo )
     810           6 :         aKey = ":" + aKey;
     811             : 
     812           8 :     CSS1Map::iterator itr = aPages.find(aKey);
     813           8 :     return itr == aPages.end() ? NULL : itr->second;
     814             : }
     815             : 
     816           1 : void SvxCSS1Parser::InsertTag( const OUString& rTag,
     817             :                                const SfxItemSet& rItemSet,
     818             :                                const SvxCSS1PropertyInfo& rProp )
     819             : {
     820           1 :     InsertMapEntry( rTag, rItemSet, rProp, aTags );
     821           1 : }
     822             : 
     823          42 : SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const OUString& rTag )
     824             : {
     825          42 :     CSS1Map::iterator itr = aTags.find(rTag);
     826          42 :     return itr == aTags.end() ? NULL : itr->second;
     827             : }
     828             : 
     829           2 : sal_Bool SvxCSS1Parser::ParseStyleSheet( const OUString& rIn )
     830             : {
     831           2 :     pItemSet = pSheetItemSet;
     832           2 :     pPropInfo = pSheetPropInfo;
     833             : 
     834           2 :     sal_Bool bSuccess = CSS1Parser::ParseStyleSheet( rIn );
     835             : 
     836           4 :     for (size_t i = 0; i < aSelectors.size(); ++i)
     837             :     {
     838           2 :         StyleParsed( &aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
     839             :     }
     840             : 
     841             :     // und etwas aufrauemen
     842           2 :     aSelectors.clear();
     843           2 :     pSheetItemSet->ClearItem();
     844           2 :     pSheetPropInfo->Clear();
     845             : 
     846           2 :     pItemSet = 0;
     847           2 :     pPropInfo = 0;
     848             : 
     849           2 :     return bSuccess;
     850             : }
     851             : 
     852         751 : sal_Bool SvxCSS1Parser::ParseStyleOption( const OUString& rIn,
     853             :                                       SfxItemSet& rItemSet,
     854             :                                       SvxCSS1PropertyInfo& rPropInfo )
     855             : {
     856         751 :     pItemSet = &rItemSet;
     857         751 :     pPropInfo = &rPropInfo;
     858             : 
     859         751 :     sal_Bool bSuccess = CSS1Parser::ParseStyleOption( rIn );
     860         751 :     rItemSet.ClearItem( aItemIds.nDirection );
     861             : 
     862         751 :     pItemSet = 0;
     863         751 :     pPropInfo = 0;
     864             : 
     865         751 :     return bSuccess;
     866             : }
     867             : 
     868        1062 : sal_Bool SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
     869             :                           const OUString &rValue, sal_uInt16& rEnum )
     870             : {
     871        5283 :     while( pPropTable->pName )
     872             :     {
     873        3694 :         if( !rValue.equalsIgnoreAsciiCaseAscii( pPropTable->pName ) )
     874        3159 :             pPropTable++;
     875             :         else
     876         535 :             break;
     877             :     }
     878             : 
     879        1062 :     if( pPropTable->pName )
     880         535 :         rEnum = pPropTable->nEnum;
     881             : 
     882        1062 :     return (pPropTable->pName != 0);
     883             : }
     884             : 
     885           8 : void SvxCSS1Parser::PixelToTwip( long &rWidth, long &rHeight )
     886             : {
     887           8 :     if( Application::GetDefaultDevice() )
     888             :     {
     889           8 :         Size aTwipSz( rWidth, rHeight );
     890             :         aTwipSz = Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
     891           8 :                                                           MapMode(MAP_TWIP) );
     892             : 
     893           8 :         rWidth = aTwipSz.Width();
     894           8 :         rHeight = aTwipSz.Height();
     895             :     }
     896           8 : }
     897             : 
     898           0 : sal_uInt32 SvxCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
     899             : {
     900             :     sal_uInt16 nHeight;
     901             : 
     902           0 :     switch( nSize )
     903             :     {
     904           0 :     case 0:     nHeight =  8*20;    break;
     905           0 :     case 1:     nHeight = 10*20;    break;
     906           0 :     case 2:     nHeight = 11*20;    break;
     907           0 :     case 3:     nHeight = 12*20;    break;
     908           0 :     case 4:     nHeight = 17*20;    break;
     909           0 :     case 5:     nHeight = 20*20;    break;
     910             :     case 6:
     911           0 :     default:    nHeight = 32*20;    break;
     912             :     }
     913             : 
     914           0 :     return nHeight;
     915             : }
     916             : 
     917           0 : const FontList *SvxCSS1Parser::GetFontList() const
     918             : {
     919           0 :         return 0;
     920             : }
     921             : 
     922           3 : void SvxCSS1Parser::InsertMapEntry( const OUString& rKey,
     923             :                                     const SfxItemSet& rItemSet,
     924             :                                     const SvxCSS1PropertyInfo& rProp,
     925             :                                     CSS1Map& rMap )
     926             : {
     927           3 :     CSS1Map::iterator itr = rMap.find(rKey);
     928           3 :     if (itr == rMap.end())
     929             :     {
     930           3 :         std::auto_ptr<SvxCSS1MapEntry> p(new SvxCSS1MapEntry(rKey, rItemSet, rProp));
     931           3 :         rMap.insert(rKey, p);
     932             :     }
     933             :     else
     934             :     {
     935           0 :         SvxCSS1MapEntry* p = itr->second;
     936             :         MergeStyles( rItemSet, rProp,
     937           0 :                      p->GetItemSet(), p->GetPropertyInfo(), sal_True );
     938             :     }
     939           3 : }
     940             : 
     941           0 : void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
     942             :                                  const SvxCSS1PropertyInfo& rSrcInfo,
     943             :                                  SfxItemSet& rTargetSet,
     944             :                                  SvxCSS1PropertyInfo& rTargetInfo,
     945             :                                  sal_Bool bSmart )
     946             : {
     947           0 :     if( !bSmart )
     948             :     {
     949           0 :         rTargetSet.Put( rSrcSet );
     950             :     }
     951             :     else
     952             :     {
     953           0 :         SvxLRSpaceItem aLRSpace( (const SvxLRSpaceItem&)rTargetSet.Get(aItemIds.nLRSpace) );
     954           0 :         SvxULSpaceItem aULSpace( (const SvxULSpaceItem&)rTargetSet.Get(aItemIds.nULSpace) );
     955           0 :         SvxBoxItem aBox( (const SvxBoxItem&)rTargetSet.Get(aItemIds.nBox) );
     956             : 
     957           0 :         rTargetSet.Put( rSrcSet );
     958             : 
     959           0 :         if( rSrcInfo.bLeftMargin || rSrcInfo.bRightMargin ||
     960             :             rSrcInfo.bTextIndent )
     961             :         {
     962             :             const SvxLRSpaceItem& rNewLRSpace =
     963           0 :                 (const SvxLRSpaceItem&)rSrcSet.Get( aItemIds.nLRSpace );
     964             : 
     965           0 :             if( rSrcInfo.bLeftMargin )
     966           0 :                 aLRSpace.SetLeft( rNewLRSpace.GetLeft() );
     967           0 :             if( rSrcInfo.bRightMargin )
     968           0 :                 aLRSpace.SetRight( rNewLRSpace.GetRight() );
     969           0 :             if( rSrcInfo.bTextIndent )
     970           0 :                 aLRSpace.SetTxtFirstLineOfst( rNewLRSpace.GetTxtFirstLineOfst() );
     971             : 
     972           0 :             rTargetSet.Put( aLRSpace );
     973             :         }
     974             : 
     975           0 :         if( rSrcInfo.bTopMargin || rSrcInfo.bBottomMargin )
     976             :         {
     977             :             const SvxULSpaceItem& rNewULSpace =
     978           0 :                 (const SvxULSpaceItem&)rSrcSet.Get( aItemIds.nULSpace );
     979             : 
     980           0 :             if( rSrcInfo.bTopMargin )
     981           0 :                 aULSpace.SetUpper( rNewULSpace.GetUpper() );
     982           0 :             if( rSrcInfo.bBottomMargin )
     983           0 :                 aULSpace.SetLower( rNewULSpace.GetLower() );
     984             : 
     985           0 :             rTargetSet.Put( aULSpace );
     986           0 :         }
     987             :     }
     988             : 
     989           0 :     rTargetInfo.Merge( rSrcInfo );
     990           0 : }
     991             : 
     992           6 : void SvxCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
     993             : {
     994           6 :     eDfltEnc = eEnc;
     995           6 : }
     996             : 
     997           8 : static void ParseCSS1_font_size( const CSS1Expression *pExpr,
     998             :                                  SfxItemSet &rItemSet,
     999             :                                  SvxCSS1PropertyInfo& /*rPropInfo*/,
    1000             :                                  const SvxCSS1Parser& rParser )
    1001             : {
    1002             :     OSL_ENSURE( pExpr, "no expression" );
    1003             : 
    1004           8 :     sal_uLong nHeight = 0;
    1005           8 :     sal_uInt16 nPropHeight = 100;
    1006             : 
    1007           8 :     switch( pExpr->GetType() )
    1008             :     {
    1009             :     case CSS1_LENGTH:
    1010           8 :         nHeight = pExpr->GetULength();
    1011           8 :         break;
    1012             :     case CSS1_PIXLENGTH:
    1013             :         {
    1014           0 :             long nPWidth = 0;
    1015           0 :             long nPHeight = (long)pExpr->GetNumber();
    1016           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    1017           0 :             nHeight = (sal_uLong)nPHeight;
    1018             :         }
    1019           0 :         break;
    1020             :     case CSS1_PERCENTAGE:
    1021             :         // nur fuer Drop-Caps!
    1022           0 :         nPropHeight = (sal_uInt16)pExpr->GetNumber();
    1023           0 :         break;
    1024             :     case CSS1_IDENT:
    1025             :         {
    1026             :             sal_uInt16 nSize;
    1027             : 
    1028           0 :             if( SvxCSS1Parser::GetEnum( aFontSizeTable, pExpr->GetString(),
    1029           0 :                                         nSize ) )
    1030             :             {
    1031           0 :                 nHeight = rParser.GetFontHeight( nSize );
    1032             :             }
    1033             :         }
    1034           0 :         break;
    1035             : 
    1036             :     default:
    1037             :         ;
    1038             :     }
    1039             : 
    1040           8 :     if( nHeight || nPropHeight!=100 )
    1041             :     {
    1042             :         SvxFontHeightItem aFontHeight( nHeight, nPropHeight,
    1043           8 :                                        aItemIds.nFontHeight );
    1044           8 :         if( rParser.IsSetWesternProps() )
    1045           8 :             rItemSet.Put( aFontHeight );
    1046           8 :         if( rParser.IsSetCJKProps() )
    1047             :         {
    1048           8 :             aFontHeight.SetWhich( aItemIds.nFontHeightCJK );
    1049           8 :             rItemSet.Put( aFontHeight );
    1050             :         }
    1051           8 :         if( rParser.IsSetCTLProps() )
    1052             :         {
    1053           8 :             aFontHeight.SetWhich( aItemIds.nFontHeightCTL );
    1054           8 :             rItemSet.Put( aFontHeight );
    1055           8 :         }
    1056             :     }
    1057           8 : }
    1058             : 
    1059           2 : static void ParseCSS1_font_family( const CSS1Expression *pExpr,
    1060             :                                    SfxItemSet &rItemSet,
    1061             :                                    SvxCSS1PropertyInfo& /*rPropInfo*/,
    1062             :                                    const SvxCSS1Parser& rParser )
    1063             : {
    1064             :     OSL_ENSURE( pExpr, "no expression" );
    1065             : 
    1066           4 :     OUString aName, aStyleName;
    1067           2 :     FontFamily eFamily = FAMILY_DONTKNOW;
    1068           2 :     FontPitch ePitch = PITCH_DONTKNOW;
    1069           2 :     rtl_TextEncoding eEnc = rParser.GetDfltEncoding();
    1070           2 :     const FontList *pFList = rParser.GetFontList();
    1071           2 :     sal_Bool bFirst = sal_True;
    1072           2 :     sal_Bool bFound = sal_False;
    1073           6 :     while( pExpr && (bFirst || ','==pExpr->GetOp() || !pExpr->GetOp()) )
    1074             :     {
    1075           2 :         CSS1Token eType = pExpr->GetType();
    1076           2 :         if( CSS1_IDENT==eType || CSS1_STRING==eType )
    1077             :         {
    1078           2 :             OUString aIdent( pExpr->GetString() );
    1079             : 
    1080           2 :             if( CSS1_IDENT==eType )
    1081             :             {
    1082             :                 // Alle nachfolgenden id's sammeln und mit einem
    1083             :                 // Space getrennt hintendranhaengen
    1084           1 :                 const CSS1Expression *pNext = pExpr->GetNext();
    1085           2 :                 while( pNext && !pNext->GetOp() &&
    1086           0 :                        CSS1_IDENT==pNext->GetType() )
    1087             :                 {
    1088           0 :                     aIdent += " " + pNext->GetString();
    1089           0 :                     pExpr = pNext;
    1090           0 :                     pNext = pExpr->GetNext();
    1091             :                 }
    1092             :             }
    1093           2 :             if( !aIdent.isEmpty() )
    1094             :             {
    1095           2 :                 if( !bFound && pFList )
    1096             :                 {
    1097           2 :                     sal_Handle hFont = pFList->GetFirstFontInfo( aIdent );
    1098           2 :                     if( 0 != hFont )
    1099             :                     {
    1100           0 :                         const FontInfo& rFInfo = pFList->GetFontInfo( hFont );
    1101           0 :                         if( RTL_TEXTENCODING_DONTKNOW != rFInfo.GetCharSet() )
    1102             :                         {
    1103           0 :                             bFound = sal_True;
    1104           0 :                             if( RTL_TEXTENCODING_SYMBOL == rFInfo.GetCharSet() )
    1105           0 :                                 eEnc = RTL_TEXTENCODING_SYMBOL;
    1106             :                         }
    1107             :                     }
    1108             :                 }
    1109           2 :                 if( !bFirst )
    1110           0 :                     aName += ";";
    1111           2 :                 aName += aIdent;
    1112           2 :             }
    1113             :         }
    1114             : 
    1115           2 :         pExpr = pExpr->GetNext();
    1116           2 :         bFirst = sal_False;
    1117             :     }
    1118             : 
    1119           2 :     if( !aName.isEmpty() && !rParser.IsIgnoreFontFamily() )
    1120             :     {
    1121             :         SvxFontItem aFont( eFamily, aName, aStyleName, ePitch,
    1122           2 :                             eEnc, aItemIds.nFont );
    1123           2 :         if( rParser.IsSetWesternProps() )
    1124           2 :             rItemSet.Put( aFont );
    1125           2 :         if( rParser.IsSetCJKProps() )
    1126             :         {
    1127           2 :             aFont.SetWhich( aItemIds.nFontCJK );
    1128           2 :             rItemSet.Put( aFont );
    1129             :         }
    1130           2 :         if( rParser.IsSetCTLProps() )
    1131             :         {
    1132           2 :             aFont.SetWhich( aItemIds.nFontCTL );
    1133           2 :             rItemSet.Put( aFont );
    1134           2 :         }
    1135           2 :     }
    1136           2 : }
    1137             : 
    1138           0 : static void ParseCSS1_font_weight( const CSS1Expression *pExpr,
    1139             :                                    SfxItemSet &rItemSet,
    1140             :                                    SvxCSS1PropertyInfo& /*rPropInfo*/,
    1141             :                                    const SvxCSS1Parser& rParser )
    1142             : {
    1143             :     OSL_ENSURE( pExpr, "no expression" );
    1144             : 
    1145           0 :     switch( pExpr->GetType() )
    1146             :     {
    1147             :     case CSS1_IDENT:
    1148             :     case CSS1_STRING:   // MS-IE, was sonst
    1149             :         {
    1150             :             sal_uInt16 nWeight;
    1151           0 :             if( SvxCSS1Parser::GetEnum( aFontWeightTable, pExpr->GetString(),
    1152           0 :                                         nWeight ) )
    1153             :             {
    1154           0 :                 SvxWeightItem aWeight( (FontWeight)nWeight, aItemIds.nWeight );
    1155           0 :                 if( rParser.IsSetWesternProps() )
    1156           0 :                     rItemSet.Put( aWeight );
    1157           0 :                 if( rParser.IsSetCJKProps() )
    1158             :                 {
    1159           0 :                     aWeight.SetWhich( aItemIds.nWeightCJK );
    1160           0 :                     rItemSet.Put( aWeight );
    1161             :                 }
    1162           0 :                 if( rParser.IsSetCTLProps() )
    1163             :                 {
    1164           0 :                     aWeight.SetWhich( aItemIds.nWeightCTL );
    1165           0 :                     rItemSet.Put( aWeight );
    1166           0 :                 }
    1167             :             }
    1168             :         }
    1169           0 :         break;
    1170             :     case CSS1_NUMBER:
    1171             :         {
    1172           0 :             sal_uInt16 nWeight = (sal_uInt16)pExpr->GetNumber();
    1173             :             SvxWeightItem aWeight( nWeight>400 ? WEIGHT_BOLD : WEIGHT_NORMAL,
    1174           0 :                                    aItemIds.nWeight );
    1175           0 :             if( rParser.IsSetWesternProps() )
    1176           0 :                 rItemSet.Put( aWeight );
    1177           0 :             if( rParser.IsSetCJKProps() )
    1178             :             {
    1179           0 :                 aWeight.SetWhich( aItemIds.nWeightCJK );
    1180           0 :                 rItemSet.Put( aWeight );
    1181             :             }
    1182           0 :             if( rParser.IsSetCTLProps() )
    1183             :             {
    1184           0 :                 aWeight.SetWhich( aItemIds.nWeightCTL );
    1185           0 :                 rItemSet.Put( aWeight );
    1186           0 :             }
    1187             :         }
    1188           0 :         break;
    1189             : 
    1190             :     default:
    1191             :         ;
    1192             :     }
    1193           0 : }
    1194             : 
    1195           0 : static void ParseCSS1_font_style( const CSS1Expression *pExpr,
    1196             :                                   SfxItemSet &rItemSet,
    1197             :                                   SvxCSS1PropertyInfo& /*rPropInfo*/,
    1198             :                                   const SvxCSS1Parser& rParser )
    1199             : {
    1200             :     OSL_ENSURE( pExpr, "no expression" );
    1201             : 
    1202           0 :     sal_Bool bPosture = sal_False;
    1203           0 :     sal_Bool bCaseMap = sal_False;
    1204           0 :     FontItalic eItalic = ITALIC_NONE;
    1205           0 :     SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
    1206             : 
    1207             :     // normal | italic || small-caps | oblique || small-caps | small-caps
    1208             :     // (wobei nor noch normal | italic und oblique zulaessig sind
    1209             : 
    1210             :     // der Wert kann zwei Werte enthalten!
    1211           0 :     for( sal_uInt16 i=0; pExpr && i<2; i++ )
    1212             :     {
    1213             :         // Auch hier hinterlaesst MS-IEs Parser seine Spuren
    1214           0 :         if( (CSS1_IDENT==pExpr->GetType() || CSS1_STRING==pExpr->GetType()) &&
    1215           0 :             !pExpr->GetOp() )
    1216             :         {
    1217           0 :             const OUString& rValue = pExpr->GetString();
    1218             :             // erstmal pruefen, ob es ein Italic-Wert oder 'normal' ist
    1219             :             sal_uInt16 nItalic;
    1220           0 :             if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nItalic ) )
    1221             :             {
    1222           0 :                 eItalic = (FontItalic)nItalic;
    1223           0 :                 if( !bCaseMap && ITALIC_NONE==eItalic )
    1224             :                 {
    1225             :                     // fuer 'normal' muessen wir auch die case-map aussch.
    1226           0 :                     eCaseMap = SVX_CASEMAP_NOT_MAPPED;
    1227           0 :                     bCaseMap = sal_True;
    1228             :                 }
    1229           0 :                 bPosture = sal_True;
    1230             :             }
    1231           0 :             else if( !bCaseMap &&
    1232           0 :                      rValue.equalsIgnoreAsciiCase( "small-caps" ) )
    1233             :             {
    1234           0 :                 eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
    1235           0 :                 bCaseMap = sal_True;
    1236             :             }
    1237             :         }
    1238             : 
    1239             :         // den naechsten Ausdruck holen
    1240           0 :         pExpr = pExpr->GetNext();
    1241             :     }
    1242             : 
    1243           0 :     if( bPosture )
    1244             :     {
    1245           0 :         SvxPostureItem aPosture( eItalic, aItemIds.nPosture );
    1246           0 :         if( rParser.IsSetWesternProps() )
    1247           0 :             rItemSet.Put( aPosture );
    1248           0 :         if( rParser.IsSetCJKProps() )
    1249             :         {
    1250           0 :             aPosture.SetWhich( aItemIds.nPostureCJK );
    1251           0 :             rItemSet.Put( aPosture );
    1252             :         }
    1253           0 :         if( rParser.IsSetCTLProps() )
    1254             :         {
    1255           0 :             aPosture.SetWhich( aItemIds.nPostureCTL );
    1256           0 :             rItemSet.Put( aPosture );
    1257           0 :         }
    1258             :     }
    1259             : 
    1260           0 :     if( bCaseMap )
    1261           0 :         rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
    1262           0 : }
    1263             : 
    1264           6 : static void ParseCSS1_font_variant( const CSS1Expression *pExpr,
    1265             :                                     SfxItemSet &rItemSet,
    1266             :                                     SvxCSS1PropertyInfo& /*rPropInfo*/,
    1267             :                                     const SvxCSS1Parser& /*rParser*/ )
    1268             : {
    1269             :     OSL_ENSURE( pExpr, "no expression" );
    1270             : 
    1271             :     // normal | small-caps
    1272             : 
    1273           6 :     switch( pExpr->GetType() )
    1274             :     {
    1275             :     case CSS1_IDENT:
    1276             :         {
    1277             :             sal_uInt16 nCaseMap;
    1278          12 :             if( SvxCSS1Parser::GetEnum( aFontVariantTable, pExpr->GetString(),
    1279           6 :                                         nCaseMap ) )
    1280             :             {
    1281             :                 rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
    1282           6 :                                                 aItemIds.nCaseMap ) );
    1283             :             }
    1284             :         }
    1285             :     default:
    1286             :         ;
    1287             :     }
    1288           6 : }
    1289             : 
    1290           0 : static void ParseCSS1_text_transform( const CSS1Expression *pExpr,
    1291             :                                     SfxItemSet &rItemSet,
    1292             :                                     SvxCSS1PropertyInfo& /*rPropInfo*/,
    1293             :                                     const SvxCSS1Parser& /*rParser*/ )
    1294             : {
    1295             :     OSL_ENSURE( pExpr, "no expression" );
    1296             : 
    1297             :     // none | capitalize | uppercase | lowercase
    1298             : 
    1299           0 :     switch( pExpr->GetType() )
    1300             :     {
    1301             :     case CSS1_IDENT:
    1302             :         {
    1303             :             sal_uInt16 nCaseMap;
    1304           0 :             if( SvxCSS1Parser::GetEnum( aTextTransformTable, pExpr->GetString(),
    1305           0 :                                         nCaseMap ) )
    1306             :             {
    1307             :                 rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
    1308           0 :                                                 aItemIds.nCaseMap ) );
    1309             :             }
    1310             :         }
    1311             :     default:
    1312             :         ;
    1313             :     }
    1314           0 : }
    1315             : 
    1316           1 : static void ParseCSS1_color( const CSS1Expression *pExpr,
    1317             :                              SfxItemSet &rItemSet,
    1318             :                              SvxCSS1PropertyInfo& /*rPropInfo*/,
    1319             :                              const SvxCSS1Parser& /*rParser*/ )
    1320             : {
    1321             :     OSL_ENSURE( pExpr, "no expression" );
    1322             : 
    1323           1 :     switch( pExpr->GetType() )
    1324             :     {
    1325             :     case CSS1_IDENT:
    1326             :     case CSS1_RGB:
    1327             :     case CSS1_HEXCOLOR:
    1328             :     case CSS1_STRING:       // Wegen MS-IE
    1329             :         {
    1330           1 :             Color aColor;
    1331           1 :             if( pExpr->GetColor( aColor ) )
    1332           1 :                 rItemSet.Put( SvxColorItem( aColor, aItemIds.nColor ) );
    1333             :         }
    1334           1 :         break;
    1335             :     default:
    1336             :         ;
    1337             :     }
    1338           1 : }
    1339             : 
    1340           0 : static void ParseCSS1_column_count( const CSS1Expression *pExpr,
    1341             :                              SfxItemSet& /*rItemSet*/,
    1342             :                              SvxCSS1PropertyInfo &rPropInfo,
    1343             :                              const SvxCSS1Parser& /*rParser*/ )
    1344             : {
    1345             :     OSL_ENSURE( pExpr, "no expression" );
    1346             : 
    1347           0 :     if ( pExpr->GetType() == CSS1_NUMBER )
    1348             :     {
    1349           0 :         double columnCount = pExpr->GetNumber();
    1350           0 :         if ( columnCount >= 2 )
    1351             :         {
    1352           0 :             rPropInfo.nColumnCount = columnCount;
    1353             :         }
    1354             :     }
    1355           0 : }
    1356             : 
    1357           1 : static void ParseCSS1_direction( const CSS1Expression *pExpr,
    1358             :                              SfxItemSet &rItemSet,
    1359             :                              SvxCSS1PropertyInfo& /*rPropInfo*/,
    1360             :                              const SvxCSS1Parser& /*rParser*/ )
    1361             : {
    1362             :     OSL_ENSURE( pExpr, "no expression" );
    1363             : 
    1364             :     sal_uInt16 nDir;
    1365           1 :     switch( pExpr->GetType() )
    1366             :     {
    1367             :     case CSS1_IDENT:
    1368             :     case CSS1_STRING:
    1369           2 :         if( SvxCSS1Parser::GetEnum( aDirectionTable, pExpr->GetString(),
    1370           1 :                                         nDir ) )
    1371             :         {
    1372             :             rItemSet.Put( SvxFrameDirectionItem(
    1373             :                        static_cast < SvxFrameDirection >( nDir ),
    1374           1 :                        aItemIds.nDirection ) );
    1375             :         }
    1376           1 :         break;
    1377             :     default:
    1378             :         ;
    1379             :     }
    1380           1 : }
    1381             : 
    1382           0 : static void MergeHori( SvxGraphicPosition& ePos, SvxGraphicPosition eHori )
    1383             : {
    1384             :     OSL_ENSURE( GPOS_LT==eHori || GPOS_MT==eHori || GPOS_RT==eHori,
    1385             :                 "vertical position not at the top" );
    1386             : 
    1387           0 :     switch( ePos )
    1388             :     {
    1389             :     case GPOS_LT:
    1390             :     case GPOS_MT:
    1391             :     case GPOS_RT:
    1392           0 :         ePos = eHori;
    1393           0 :         break;
    1394             : 
    1395             :     case GPOS_LM:
    1396             :     case GPOS_MM:
    1397             :     case GPOS_RM:
    1398           0 :         ePos = GPOS_LT==eHori ? GPOS_LM : (GPOS_MT==eHori ? GPOS_MM : GPOS_RM);
    1399           0 :         break;
    1400             : 
    1401             :     case GPOS_LB:
    1402             :     case GPOS_MB:
    1403             :     case GPOS_RB:
    1404           0 :         ePos = GPOS_LT==eHori ? GPOS_LB : (GPOS_MT==eHori ? GPOS_MB : GPOS_RB);
    1405           0 :         break;
    1406             : 
    1407             :     default:
    1408             :         ;
    1409             :     }
    1410           0 : }
    1411             : 
    1412           0 : static void MergeVert( SvxGraphicPosition& ePos, SvxGraphicPosition eVert )
    1413             : {
    1414             :     OSL_ENSURE( GPOS_LT==eVert || GPOS_LM==eVert || GPOS_LB==eVert,
    1415             :                 "horizontal position not on the left side" );
    1416             : 
    1417           0 :     switch( ePos )
    1418             :     {
    1419             :     case GPOS_LT:
    1420             :     case GPOS_LM:
    1421             :     case GPOS_LB:
    1422           0 :         ePos = eVert;
    1423           0 :         break;
    1424             : 
    1425             :     case GPOS_MT:
    1426             :     case GPOS_MM:
    1427             :     case GPOS_MB:
    1428           0 :         ePos = GPOS_LT==eVert ? GPOS_MT : (GPOS_LM==eVert ? GPOS_MM : GPOS_MB);
    1429           0 :         break;
    1430             : 
    1431             :     case GPOS_RT:
    1432             :     case GPOS_RM:
    1433             :     case GPOS_RB:
    1434           0 :         ePos = GPOS_LT==eVert ? GPOS_RT : (GPOS_LM==eVert ? GPOS_RM : GPOS_RB);
    1435           0 :         break;
    1436             : 
    1437             :     default:
    1438             :         ;
    1439             :     }
    1440           0 : }
    1441             : 
    1442           1 : static void ParseCSS1_background( const CSS1Expression *pExpr,
    1443             :                                   SfxItemSet &rItemSet,
    1444             :                                   SvxCSS1PropertyInfo& /*rPropInfo*/,
    1445             :                                   const SvxCSS1Parser& rParser )
    1446             : {
    1447             :     OSL_ENSURE( pExpr, "no expression" );
    1448             : 
    1449           1 :     Color aColor;
    1450           1 :     OUString aURL;
    1451             : 
    1452           1 :     sal_Bool bColor = sal_False, bTransparent = sal_False;
    1453           1 :     SvxGraphicPosition eRepeat = GPOS_TILED;
    1454           1 :     SvxGraphicPosition ePos = GPOS_LT;
    1455           1 :     sal_Bool bHori = sal_False, bVert = sal_False;
    1456             : 
    1457           3 :     while( pExpr && !pExpr->GetOp() )
    1458             :     {
    1459           1 :         switch( pExpr->GetType() )
    1460             :         {
    1461             :         case CSS1_URL:
    1462           0 :             pExpr->GetURL( aURL );
    1463           0 :             break;
    1464             : 
    1465             :         case CSS1_RGB:
    1466           0 :             bColor = pExpr->GetColor( aColor );
    1467           0 :             break;
    1468             : 
    1469             :         case CSS1_LENGTH:
    1470             :         case CSS1_PIXLENGTH:
    1471             :             {
    1472             :                 // da wir keine absolute Positionierung koennen,
    1473             :                 // unterscheiden wir nur zwischen  0 und !0. Deshalb
    1474             :                 // koennen Pixel auch wie alle anderen Einheiten behandelt
    1475             :                 // werden.
    1476             : 
    1477           0 :                 sal_uLong nLength = (sal_uLong)pExpr->GetNumber();
    1478           0 :                 if( !bHori )
    1479             :                 {
    1480           0 :                     ePos = nLength ? GPOS_MM : GPOS_LT;
    1481           0 :                     bHori = sal_True;
    1482             :                 }
    1483           0 :                 else if( !bVert )
    1484             :                 {
    1485           0 :                     MergeVert( ePos, (nLength ? GPOS_LM : GPOS_LT) );
    1486           0 :                     bVert = sal_True;
    1487             :                 }
    1488             :             }
    1489           0 :             break;
    1490             : 
    1491             :         case CSS1_PERCENTAGE:
    1492             :             {
    1493             :                 // die %-Angabe wird auf den enum abgebildet
    1494             : 
    1495           0 :                 sal_uInt16 nPerc = (sal_uInt16)pExpr->GetNumber();
    1496           0 :                 if( !bHori )
    1497             :                 {
    1498             :                     ePos = nPerc < 25 ? GPOS_LT
    1499             :                                       : (nPerc < 75 ? GPOS_MM
    1500           0 :                                                     : GPOS_RB);
    1501             :                 }
    1502           0 :                 else if( !bVert )
    1503             :                 {
    1504             :                     SvxGraphicPosition eVert =
    1505             :                         nPerc < 25 ? GPOS_LT: (nPerc < 75 ? GPOS_LM
    1506           0 :                                                           : GPOS_LB);
    1507           0 :                     MergeVert( ePos, eVert );
    1508             :                 }
    1509             :             }
    1510           0 :             break;
    1511             : 
    1512             :         case CSS1_IDENT:
    1513             :         case CSS1_HEXCOLOR:
    1514             :         case CSS1_STRING:       // Wegen MS-IE
    1515             :             {
    1516             :                 sal_uInt16 nEnum;
    1517           1 :                 const OUString &rValue = pExpr->GetString();
    1518           1 :                 if( rValue.equalsIgnoreAsciiCase( "transparent" ) )
    1519             :                 {
    1520           1 :                     bTransparent = sal_True;
    1521             :                 }
    1522           1 :                 if( SvxCSS1Parser::GetEnum( aBGRepeatTable, rValue, nEnum ) )
    1523             :                 {
    1524           0 :                     eRepeat = (SvxGraphicPosition)nEnum;
    1525             :                 }
    1526           1 :                 else if( SvxCSS1Parser::GetEnum( aBGHoriPosTable, rValue, nEnum ) )
    1527             :                 {
    1528             :                     // <position>, horizontal
    1529           0 :                     MergeHori( ePos, (SvxGraphicPosition)nEnum );
    1530             :                 }
    1531           1 :                 else if( SvxCSS1Parser::GetEnum( aBGVertPosTable, rValue, nEnum ) )
    1532             :                 {
    1533             :                     // <position>, vertikal
    1534           0 :                     MergeVert( ePos, (SvxGraphicPosition)nEnum );
    1535             :                 }
    1536           1 :                 else if( !bColor )
    1537             :                 {
    1538             :                     // <color>
    1539           1 :                     bColor = pExpr->GetColor( aColor );
    1540             :                 }
    1541             :                 // <scroll> kennen wir nicht
    1542             :             }
    1543           1 :             break;
    1544             : 
    1545             :         default:
    1546             :             ;
    1547             :         }
    1548             : 
    1549           1 :         pExpr = pExpr->GetNext();
    1550             :     }
    1551             : 
    1552             :     // transparent schlaegt alles
    1553           1 :     if( bTransparent )
    1554             :     {
    1555           1 :         bColor = sal_False;
    1556           1 :         aURL = "";
    1557             :     }
    1558             : 
    1559             :     // repeat hat prio gegenueber einer Position
    1560           1 :     if( GPOS_NONE == eRepeat )
    1561           0 :         eRepeat = ePos;
    1562             : 
    1563           1 :     if( bTransparent || bColor || !aURL.isEmpty() )
    1564             :     {
    1565           1 :         SvxBrushItem aBrushItem( aItemIds.nBrush );
    1566             : 
    1567           1 :         if( bTransparent )
    1568           1 :             aBrushItem.SetColor( Color(COL_TRANSPARENT));
    1569           0 :         else if( bColor )
    1570           0 :             aBrushItem.SetColor( aColor );
    1571             : 
    1572           1 :         if( !aURL.isEmpty() )
    1573             :         {
    1574           0 :             aBrushItem.SetGraphicLink( URIHelper::SmartRel2Abs( INetURLObject( rParser.GetBaseURL()), aURL, Link(), false ) );
    1575           0 :             aBrushItem.SetGraphicPos( eRepeat );
    1576             :         }
    1577             : 
    1578           1 :         rItemSet.Put( aBrushItem );
    1579           1 :     }
    1580           1 : }
    1581             : 
    1582           0 : static void ParseCSS1_background_color( const CSS1Expression *pExpr,
    1583             :                                   SfxItemSet &rItemSet,
    1584             :                                   SvxCSS1PropertyInfo& /*rPropInfo*/,
    1585             :                                   const SvxCSS1Parser& /*rParser*/ )
    1586             : {
    1587             :     OSL_ENSURE( pExpr, "no expression" );
    1588             : 
    1589           0 :     Color aColor;
    1590             : 
    1591           0 :     sal_Bool bColor = sal_False, bTransparent = sal_False;
    1592             : 
    1593           0 :     switch( pExpr->GetType() )
    1594             :     {
    1595             :     case CSS1_RGB:
    1596           0 :         bColor = pExpr->GetColor( aColor );
    1597           0 :         break;
    1598             :     case CSS1_IDENT:
    1599             :     case CSS1_HEXCOLOR:
    1600             :     case CSS1_STRING:       // Wegen MS-IE
    1601           0 :         if( pExpr->GetString().equalsIgnoreAsciiCase( "transparent" ) )
    1602             :         {
    1603           0 :             bTransparent = sal_True;
    1604             :         }
    1605             :         else
    1606             :         {
    1607             :             // <color>
    1608           0 :             bColor = pExpr->GetColor( aColor );
    1609             :         }
    1610           0 :         break;
    1611             :     default:
    1612             :         ;
    1613             :     }
    1614             : 
    1615           0 :     if( bTransparent || bColor )
    1616             :     {
    1617           0 :         SvxBrushItem aBrushItem( aItemIds.nBrush );
    1618             : 
    1619           0 :         if( bTransparent )
    1620           0 :             aBrushItem.SetColor( Color(COL_TRANSPARENT) );
    1621           0 :         else if( bColor )
    1622           0 :             aBrushItem.SetColor( aColor);
    1623             : 
    1624           0 :         rItemSet.Put( aBrushItem );
    1625             :     }
    1626           0 : }
    1627             : 
    1628           2 : static void ParseCSS1_line_height( const CSS1Expression *pExpr,
    1629             :                                    SfxItemSet &rItemSet,
    1630             :                                    SvxCSS1PropertyInfo& /*rPropInfo*/,
    1631             :                                    const SvxCSS1Parser& rParser )
    1632             : {
    1633             :     OSL_ENSURE( pExpr, "no expression" );
    1634             : 
    1635           2 :     sal_uInt16 nHeight = 0;
    1636           2 :     sal_uInt8 nPropHeight = 0;
    1637             : 
    1638           2 :     switch( pExpr->GetType() )
    1639             :     {
    1640             :     case CSS1_LENGTH:
    1641           0 :         nHeight = (sal_uInt16)pExpr->GetULength();
    1642           0 :         break;
    1643             :     case CSS1_PIXLENGTH:
    1644             :         {
    1645           0 :             long nPWidth = 0;
    1646           0 :             long nPHeight = (long)pExpr->GetNumber();
    1647           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    1648           0 :             nHeight = (sal_uInt16)nPHeight;
    1649             :         }
    1650           0 :         break;
    1651             :     case CSS1_PERCENTAGE:
    1652             :         {
    1653           2 :             sal_uInt16 nPHeight = (sal_uInt16)pExpr->GetNumber();
    1654           2 :             nPropHeight = nPHeight <= 200 ? (sal_uInt8)nPHeight : 200;
    1655             :         }
    1656           2 :         break;
    1657             :     case CSS1_NUMBER:
    1658             :         {
    1659           0 :             sal_uInt16 nPHeight = (sal_uInt16)(pExpr->GetNumber() * 100);
    1660           0 :             nPropHeight = nPHeight <= 200 ? (sal_uInt8)nPHeight : 200;
    1661             :         }
    1662           0 :         break;
    1663             :     default:
    1664             :         ;
    1665             :     }
    1666             : 
    1667           2 :     if( nHeight )
    1668             :     {
    1669           0 :         if( nHeight < rParser.GetMinFixLineSpace() )
    1670           0 :             nHeight = rParser.GetMinFixLineSpace();
    1671           0 :         SvxLineSpacingItem aLSItem( nHeight, aItemIds.nLineSpacing );
    1672           0 :         aLSItem.SetLineHeight( nHeight );
    1673             :         // interpret <line-height> attribute as minimum line height
    1674           0 :         aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_MIN;
    1675           0 :         aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
    1676           0 :         rItemSet.Put( aLSItem );
    1677             :     }
    1678           2 :     else if( nPropHeight )
    1679             :     {
    1680           2 :         SvxLineSpacingItem aLSItem( nPropHeight, aItemIds.nLineSpacing );
    1681           2 :         aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
    1682           2 :         if( 100 == nPropHeight )
    1683           2 :             aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
    1684             :         else
    1685           0 :             aLSItem.SetPropLineSpace( nPropHeight );
    1686           2 :         rItemSet.Put( aLSItem );
    1687             :     }
    1688             : 
    1689           2 : }
    1690             : 
    1691           0 : static void ParseCSS1_font( const CSS1Expression *pExpr,
    1692             :                             SfxItemSet &rItemSet,
    1693             :                             SvxCSS1PropertyInfo& rPropInfo,
    1694             :                             const SvxCSS1Parser& rParser )
    1695             : {
    1696             :     OSL_ENSURE( pExpr, "no expression" );
    1697             : 
    1698           0 :     FontItalic eItalic = ITALIC_NONE;
    1699           0 :     SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
    1700           0 :     FontWeight eWeight = WEIGHT_NORMAL;
    1701             : 
    1702             :     // [ <font-style> || <font-variant> || <font-weight> ] ?
    1703           0 :     while( pExpr && !pExpr->GetOp() &&
    1704           0 :            (CSS1_IDENT==pExpr->GetType() ||
    1705           0 :             CSS1_STRING==pExpr->GetType() ||
    1706           0 :             CSS1_NUMBER==pExpr->GetType()) )
    1707             :     {
    1708           0 :         if( CSS1_IDENT==pExpr->GetType() ||
    1709           0 :             CSS1_STRING==pExpr->GetType() )
    1710             :         {
    1711           0 :             const OUString& rValue = pExpr->GetString();
    1712             : 
    1713             :             sal_uInt16 nEnum;
    1714             : 
    1715           0 :             if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nEnum ) )
    1716             :             {
    1717           0 :                 eItalic = (FontItalic)nEnum;
    1718             :             }
    1719           0 :             else if( SvxCSS1Parser::GetEnum( aFontVariantTable, rValue, nEnum ) )
    1720             :             {
    1721           0 :                 eCaseMap = (SvxCaseMap)nEnum;
    1722             :             }
    1723           0 :             else if( SvxCSS1Parser::GetEnum( aFontWeightTable, rValue, nEnum ) )
    1724             :             {
    1725           0 :                 eWeight = (FontWeight)nEnum;
    1726             :             }
    1727             :         }
    1728             :         else
    1729             :         {
    1730           0 :             eWeight = (sal_uInt16)pExpr->GetNumber() > 400 ? WEIGHT_BOLD
    1731           0 :                                                        : WEIGHT_NORMAL;
    1732             :         }
    1733             : 
    1734           0 :         pExpr = pExpr->GetNext();
    1735             :     }
    1736             : 
    1737           0 :     if( !pExpr || pExpr->GetOp() )
    1738           0 :         return;
    1739             : 
    1740             :     // Da "font" alle Werte zurecksetzt, fuer die nichts angegeben ist,
    1741             :     // tun wir das hier.
    1742           0 :     SvxPostureItem aPosture( eItalic, aItemIds.nPosture );
    1743           0 :     if( rParser.IsSetWesternProps() )
    1744           0 :         rItemSet.Put( aPosture );
    1745           0 :     if( rParser.IsSetCJKProps() )
    1746             :     {
    1747           0 :         aPosture.SetWhich( aItemIds.nPostureCJK );
    1748           0 :         rItemSet.Put( aPosture );
    1749             :     }
    1750           0 :     if( rParser.IsSetCTLProps() )
    1751             :     {
    1752           0 :         aPosture.SetWhich( aItemIds.nPostureCTL );
    1753           0 :         rItemSet.Put( aPosture );
    1754             :     }
    1755             : 
    1756           0 :     rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
    1757             : 
    1758           0 :     SvxWeightItem aWeight( eWeight, aItemIds.nWeight );
    1759           0 :     if( rParser.IsSetWesternProps() )
    1760           0 :         rItemSet.Put( aWeight );
    1761           0 :     if( rParser.IsSetCJKProps() )
    1762             :     {
    1763           0 :         aWeight.SetWhich( aItemIds.nWeightCJK );
    1764           0 :         rItemSet.Put( aWeight );
    1765             :     }
    1766           0 :     if( rParser.IsSetCTLProps() )
    1767             :     {
    1768           0 :         aWeight.SetWhich( aItemIds.nWeightCTL );
    1769           0 :         rItemSet.Put( aWeight );
    1770             :     }
    1771             : 
    1772             :     // font-size
    1773           0 :     CSS1Expression aExpr( pExpr->GetType(), pExpr->GetString(),
    1774           0 :                           pExpr->GetNumber() );
    1775           0 :     ParseCSS1_font_size( &aExpr, rItemSet, rPropInfo, rParser );
    1776           0 :     pExpr = pExpr->GetNext();
    1777             : 
    1778           0 :     if( !pExpr )
    1779           0 :         return;
    1780             : 
    1781             :     // [ '/' line-height ]?
    1782           0 :     if( '/' == pExpr->GetOp() )
    1783             :     {
    1784             :         // '/' line-height
    1785           0 :         aExpr.Set( pExpr->GetType(), pExpr->GetString(), pExpr->GetNumber() );
    1786           0 :         ParseCSS1_line_height( &aExpr, rItemSet, rPropInfo, rParser );
    1787             : 
    1788           0 :         pExpr = pExpr->GetNext();
    1789             :     }
    1790             : 
    1791           0 :     if( !pExpr || pExpr->GetOp() )
    1792           0 :         return;
    1793             : 
    1794             :     // font-family
    1795           0 :     ParseCSS1_font_family( pExpr, rItemSet, rPropInfo, rParser );
    1796             : }
    1797             : 
    1798           0 : static void ParseCSS1_letter_spacing( const CSS1Expression *pExpr,
    1799             :                                       SfxItemSet &rItemSet,
    1800             :                                       SvxCSS1PropertyInfo& /*rPropInfo*/,
    1801             :                                       const SvxCSS1Parser& /*rParser*/ )
    1802             : {
    1803             :     OSL_ENSURE( pExpr, "no expression" );
    1804             : 
    1805           0 :     switch( pExpr->GetType() )
    1806             :     {
    1807             :     case CSS1_LENGTH:
    1808           0 :         rItemSet.Put( SvxKerningItem( (short)pExpr->GetSLength(),
    1809           0 :                                       aItemIds.nKerning ) );
    1810           0 :         break;
    1811             : 
    1812             :     case CSS1_PIXLENGTH:
    1813             :         {
    1814           0 :             long nPWidth = (long)pExpr->GetNumber();
    1815           0 :             long nPHeight = 0;
    1816           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    1817           0 :             rItemSet.Put( SvxKerningItem( (short)nPWidth, aItemIds.nKerning ) );
    1818             :         }
    1819           0 :         break;
    1820             : 
    1821             :     case CSS1_NUMBER:
    1822           0 :         if( pExpr->GetNumber() == 0 )
    1823             :         {
    1824             :             // eigentlich unnoetig, aber wir sind ja tollerant
    1825           0 :             rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
    1826             :         }
    1827           0 :         break;
    1828             : 
    1829             :     case CSS1_IDENT:
    1830             :     case CSS1_STRING: // Vorschtshalber auch MS-IE
    1831           0 :         if( pExpr->GetString().equalsIgnoreAsciiCase( "normal" ) )
    1832             :         {
    1833           0 :             rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
    1834             :         }
    1835           0 :         break;
    1836             :     default:
    1837             :         ;
    1838             :     }
    1839           0 : }
    1840             : 
    1841           0 : static void ParseCSS1_text_decoration( const CSS1Expression *pExpr,
    1842             :                                        SfxItemSet &rItemSet,
    1843             :                                        SvxCSS1PropertyInfo& /*rPropInfo*/,
    1844             :                                        const SvxCSS1Parser& /*rParser*/ )
    1845             : {
    1846             :     OSL_ENSURE( pExpr, "no expression" );
    1847             : 
    1848           0 :     sal_Bool bUnderline = sal_False;
    1849           0 :     sal_Bool bOverline = sal_False;
    1850           0 :     sal_Bool bCrossedOut = sal_False;
    1851           0 :     sal_Bool bBlink = sal_False;
    1852           0 :     sal_Bool bBlinkOn = sal_False;
    1853           0 :     FontUnderline eUnderline  = UNDERLINE_NONE;
    1854           0 :     FontUnderline eOverline   = UNDERLINE_NONE;
    1855           0 :     FontStrikeout eCrossedOut = STRIKEOUT_NONE;
    1856             : 
    1857             :     // der Wert kann zwei Werte enthalten! Und MS-IE auch Strings
    1858           0 :     while( pExpr && (pExpr->GetType() == CSS1_IDENT ||
    1859           0 :                      pExpr->GetType() == CSS1_STRING) && !pExpr->GetOp() )
    1860             :     {
    1861           0 :         OUString aValue = pExpr->GetString().toAsciiLowerCase();
    1862           0 :         sal_Bool bKnown = sal_False;
    1863             : 
    1864           0 :         switch( aValue[0] )
    1865             :         {
    1866             :         case 'n':
    1867           0 :             if( aValue == "none" )
    1868             :             {
    1869           0 :                 bUnderline = sal_True;
    1870           0 :                 eUnderline = UNDERLINE_NONE;
    1871             : 
    1872           0 :                 bOverline = sal_True;
    1873           0 :                 eOverline = UNDERLINE_NONE;
    1874             : 
    1875           0 :                 bCrossedOut = sal_True;
    1876           0 :                 eCrossedOut = STRIKEOUT_NONE;
    1877             : 
    1878           0 :                 bBlink = sal_True;
    1879           0 :                 bBlinkOn = sal_False;
    1880             : 
    1881           0 :                 bKnown = sal_True;
    1882             :             }
    1883           0 :             break;
    1884             : 
    1885             :         case 'u':
    1886           0 :             if( aValue == "underline" )
    1887             :             {
    1888           0 :                 bUnderline = sal_True;
    1889           0 :                 eUnderline = UNDERLINE_SINGLE;
    1890             : 
    1891           0 :                 bKnown = sal_True;
    1892             :             }
    1893           0 :             break;
    1894             : 
    1895             :         case 'o':
    1896           0 :             if( aValue == "overline" )
    1897             :             {
    1898           0 :                 bOverline = sal_True;
    1899           0 :                 eOverline = UNDERLINE_SINGLE;
    1900             : 
    1901           0 :                 bKnown = sal_True;
    1902             :             }
    1903           0 :             break;
    1904             : 
    1905             :         case 'l':
    1906           0 :             if( aValue == "line-through" )
    1907             :             {
    1908           0 :                 bCrossedOut = sal_True;
    1909           0 :                 eCrossedOut = STRIKEOUT_SINGLE;
    1910             : 
    1911           0 :                 bKnown = sal_True;
    1912             :             }
    1913           0 :             break;
    1914             : 
    1915             :         case 'b':
    1916           0 :             if( aValue == "blink" )
    1917             :             {
    1918           0 :                 bBlink = sal_True;
    1919           0 :                 bBlinkOn = sal_True;
    1920             : 
    1921           0 :                 bKnown = sal_True;
    1922             :             }
    1923           0 :             break;
    1924             :         }
    1925             : 
    1926           0 :         if( !bKnown )
    1927             :         {
    1928           0 :             bUnderline = sal_True;
    1929           0 :             eUnderline = UNDERLINE_SINGLE;
    1930             :         }
    1931             : 
    1932           0 :         pExpr = pExpr->GetNext();
    1933           0 :     }
    1934             : 
    1935           0 :     if( bUnderline )
    1936           0 :         rItemSet.Put( SvxUnderlineItem( eUnderline, aItemIds.nUnderline ) );
    1937             : 
    1938           0 :     if( bOverline )
    1939           0 :         rItemSet.Put( SvxOverlineItem( eOverline, aItemIds.nOverline ) );
    1940             : 
    1941           0 :     if( bCrossedOut )
    1942           0 :         rItemSet.Put( SvxCrossedOutItem( eCrossedOut, aItemIds.nCrossedOut ) );
    1943             : 
    1944           0 :     if( bBlink )
    1945           0 :         rItemSet.Put( SvxBlinkItem( bBlinkOn, aItemIds.nBlink ) );
    1946           0 : }
    1947             : 
    1948           1 : static void ParseCSS1_text_align( const CSS1Expression *pExpr,
    1949             :                                   SfxItemSet &rItemSet,
    1950             :                                   SvxCSS1PropertyInfo& /*rPropInfo*/,
    1951             :                                   const SvxCSS1Parser& /*rParser*/ )
    1952             : {
    1953             :     OSL_ENSURE( pExpr, "no expression" );
    1954             : 
    1955           1 :     if( CSS1_IDENT==pExpr->GetType() ||
    1956           0 :         CSS1_STRING==pExpr->GetType() ) // MS-IE, mal wieder
    1957             :     {
    1958             :         sal_uInt16 nAdjust;
    1959           2 :         if( SvxCSS1Parser::GetEnum( aTextAlignTable, pExpr->GetString(),
    1960           1 :                                     nAdjust ) )
    1961             :         {
    1962             :             rItemSet.Put( SvxAdjustItem( (SvxAdjust)nAdjust,
    1963           1 :                                          aItemIds.nAdjust ) );
    1964             :         }
    1965             :     }
    1966           1 : }
    1967             : 
    1968           0 : static void ParseCSS1_text_indent( const CSS1Expression *pExpr,
    1969             :                                    SfxItemSet &rItemSet,
    1970             :                                    SvxCSS1PropertyInfo& rPropInfo,
    1971             :                                    const SvxCSS1Parser& /*rParser*/ )
    1972             : {
    1973             :     OSL_ENSURE( pExpr, "no expression" );
    1974             : 
    1975           0 :     short nIndent = 0;
    1976           0 :     sal_Bool bSet = sal_False;
    1977           0 :     switch( pExpr->GetType() )
    1978             :     {
    1979             :     case CSS1_LENGTH:
    1980           0 :         nIndent = (short)pExpr->GetSLength();
    1981           0 :         bSet = sal_True;
    1982           0 :         break;
    1983             :     case CSS1_PIXLENGTH:
    1984             :         {
    1985           0 :             long nPWidth = (long)pExpr->GetNumber();
    1986           0 :             long nPHeight = 0;
    1987           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    1988           0 :             nIndent = (short)nPWidth;
    1989           0 :             bSet = sal_True;
    1990             :         }
    1991           0 :         break;
    1992             :     case CSS1_PERCENTAGE:
    1993             :         // koennen wir nicht
    1994           0 :         break;
    1995             :     default:
    1996             :         ;
    1997             :     }
    1998             : 
    1999           0 :     if( bSet )
    2000             :     {
    2001             :         const SfxPoolItem* pItem;
    2002           0 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
    2003           0 :                                                    &pItem ) )
    2004             :         {
    2005           0 :             SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
    2006           0 :             aLRItem.SetTxtFirstLineOfst( nIndent );
    2007           0 :             rItemSet.Put( aLRItem );
    2008             :         }
    2009             :         else
    2010             :         {
    2011           0 :             SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
    2012           0 :             aLRItem.SetTxtFirstLineOfst( nIndent );
    2013           0 :             rItemSet.Put( aLRItem );
    2014             :         }
    2015           0 :         rPropInfo.bTextIndent = sal_True;
    2016             :     }
    2017           0 : }
    2018             : 
    2019           1 : static void ParseCSS1_margin_left( const CSS1Expression *pExpr,
    2020             :                                    SfxItemSet &rItemSet,
    2021             :                                    SvxCSS1PropertyInfo& rPropInfo,
    2022             :                                    const SvxCSS1Parser& /*rParser*/ )
    2023             : {
    2024             :     OSL_ENSURE( pExpr, "no expression" );
    2025             : 
    2026           1 :     long nLeft = 0;
    2027           1 :     sal_Bool bSet = sal_False;
    2028           1 :     switch( pExpr->GetType() )
    2029             :     {
    2030             :     case CSS1_LENGTH:
    2031             :         {
    2032           1 :             nLeft = pExpr->GetSLength();
    2033           1 :             bSet = sal_True;
    2034             :         }
    2035           1 :         break;
    2036             :     case CSS1_PIXLENGTH:
    2037             :         {
    2038           0 :             nLeft = (long)pExpr->GetNumber();
    2039           0 :             long nPHeight = 0;
    2040           0 :             SvxCSS1Parser::PixelToTwip( nLeft, nPHeight );
    2041           0 :             bSet = sal_True;
    2042             :         }
    2043           0 :         break;
    2044             :     case CSS1_PERCENTAGE:
    2045             :         // koennen wir nicht
    2046           0 :         break;
    2047             :     default:
    2048             :         ;
    2049             :     }
    2050             : 
    2051           1 :     if( bSet )
    2052             :     {
    2053           1 :         rPropInfo.nLeftMargin = nLeft;
    2054           1 :         if( nLeft < 0 )
    2055           0 :             nLeft = 0;
    2056             :         const SfxPoolItem* pItem;
    2057           1 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
    2058           1 :                                                    &pItem ) )
    2059             :         {
    2060           0 :             SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
    2061           0 :             aLRItem.SetTxtLeft( (sal_uInt16)nLeft );
    2062           0 :             rItemSet.Put( aLRItem );
    2063             :         }
    2064             :         else
    2065             :         {
    2066           1 :             SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
    2067           1 :             aLRItem.SetTxtLeft( (sal_uInt16)nLeft );
    2068           1 :             rItemSet.Put( aLRItem );
    2069             :         }
    2070           1 :         rPropInfo.bLeftMargin = sal_True;
    2071             :     }
    2072           1 : }
    2073             : 
    2074           0 : static void ParseCSS1_margin_right( const CSS1Expression *pExpr,
    2075             :                                     SfxItemSet &rItemSet,
    2076             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2077             :                                     const SvxCSS1Parser& /*rParser*/ )
    2078             : {
    2079             :     OSL_ENSURE( pExpr, "no expression" );
    2080             : 
    2081           0 :     long nRight = 0;
    2082           0 :     sal_Bool bSet = sal_False;
    2083           0 :     switch( pExpr->GetType() )
    2084             :     {
    2085             :     case CSS1_LENGTH:
    2086             :         {
    2087           0 :             nRight = pExpr->GetSLength();
    2088           0 :             bSet = sal_True;
    2089             :         }
    2090           0 :         break;
    2091             :     case CSS1_PIXLENGTH:
    2092             :         {
    2093           0 :             nRight = (long)pExpr->GetNumber();
    2094           0 :             long nPHeight = 0;
    2095           0 :             SvxCSS1Parser::PixelToTwip( nRight, nPHeight );
    2096           0 :             bSet = sal_True;
    2097             :         }
    2098           0 :         break;
    2099             :     case CSS1_PERCENTAGE:
    2100             :         // koennen wir nicht
    2101           0 :         break;
    2102             :     default:
    2103             :         ;
    2104             :     }
    2105             : 
    2106           0 :     if( bSet )
    2107             :     {
    2108           0 :         rPropInfo.nRightMargin = nRight;
    2109           0 :         if( nRight < 0 )
    2110           0 :             nRight = 0;
    2111             :         const SfxPoolItem* pItem;
    2112           0 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
    2113           0 :                                                    &pItem ) )
    2114             :         {
    2115           0 :             SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
    2116           0 :             aLRItem.SetRight( (sal_uInt16)nRight );
    2117           0 :             rItemSet.Put( aLRItem );
    2118             :         }
    2119             :         else
    2120             :         {
    2121           0 :             SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
    2122           0 :             aLRItem.SetRight( (sal_uInt16)nRight );
    2123           0 :             rItemSet.Put( aLRItem );
    2124             :         }
    2125           0 :         rPropInfo.bRightMargin = sal_True;
    2126             :     }
    2127           0 : }
    2128             : 
    2129         210 : static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
    2130             :                                   SfxItemSet &rItemSet,
    2131             :                                   SvxCSS1PropertyInfo& rPropInfo,
    2132             :                                   const SvxCSS1Parser& /*rParser*/ )
    2133             : {
    2134             :     OSL_ENSURE( pExpr, "no expression" );
    2135             : 
    2136         210 :     sal_uInt16 nUpper = 0;
    2137         210 :     sal_Bool bSet = sal_False;
    2138         210 :     switch( pExpr->GetType() )
    2139             :     {
    2140             :     case CSS1_LENGTH:
    2141             :         {
    2142         210 :             long nTmp = pExpr->GetSLength();
    2143         210 :             if( nTmp < 0 )
    2144           0 :                 nTmp = 0;
    2145         210 :             nUpper = (sal_uInt16)nTmp;
    2146         210 :             bSet = sal_True;
    2147             :         }
    2148         210 :         break;
    2149             :     case CSS1_PIXLENGTH:
    2150             :         {
    2151           0 :             long nPWidth = 0;
    2152           0 :             long nPHeight =  (long)pExpr->GetNumber();
    2153           0 :             if( nPHeight < 0 )
    2154           0 :                 nPHeight = 0;
    2155           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2156           0 :             nUpper = (sal_uInt16)nPHeight;
    2157           0 :             bSet = sal_True;
    2158             :         }
    2159           0 :         break;
    2160             :     case CSS1_PERCENTAGE:
    2161             :         // koennen wir nicht
    2162           0 :         break;
    2163             :     default:
    2164             :         ;
    2165             :     }
    2166             : 
    2167         210 :     if( bSet )
    2168             :     {
    2169             :         const SfxPoolItem* pItem;
    2170         210 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
    2171         210 :                                                    &pItem ) )
    2172             :         {
    2173           0 :             SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
    2174           0 :             aULItem.SetUpper( nUpper );
    2175           0 :             rItemSet.Put( aULItem );
    2176             :         }
    2177             :         else
    2178             :         {
    2179         210 :             SvxULSpaceItem aULItem( aItemIds.nULSpace );
    2180         210 :             aULItem.SetUpper( nUpper );
    2181         210 :             rItemSet.Put( aULItem );
    2182             :         }
    2183         210 :         rPropInfo.bTopMargin = sal_True;
    2184             :     }
    2185         210 : }
    2186             : 
    2187           4 : static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
    2188             :                                      SfxItemSet &rItemSet,
    2189             :                                      SvxCSS1PropertyInfo& rPropInfo,
    2190             :                                      const SvxCSS1Parser& /*rParser*/ )
    2191             : {
    2192             :     OSL_ENSURE( pExpr, "no expression" );
    2193             : 
    2194           4 :     sal_uInt16 nLower = 0;
    2195           4 :     sal_Bool bSet = sal_False;
    2196           4 :     switch( pExpr->GetType() )
    2197             :     {
    2198             :     case CSS1_LENGTH:
    2199             :         {
    2200           4 :             long nTmp = pExpr->GetSLength();
    2201           4 :             if( nTmp < 0 )
    2202           0 :                 nTmp = 0;
    2203           4 :             nLower = (sal_uInt16)nTmp;
    2204           4 :             bSet = sal_True;
    2205             :         }
    2206           4 :         break;
    2207             :     case CSS1_PIXLENGTH:
    2208             :         {
    2209           0 :             long nPWidth = 0;
    2210           0 :             long nPHeight =  (long)pExpr->GetNumber();
    2211           0 :             if( nPHeight < 0 )
    2212           0 :                 nPHeight = 0;
    2213           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2214           0 :             nLower = (sal_uInt16)nPHeight;
    2215           0 :             bSet = sal_True;
    2216             :         }
    2217           0 :         break;
    2218             :     case CSS1_PERCENTAGE:
    2219             :         // koennen wir nicht
    2220           0 :         break;
    2221             :     default:
    2222             :         ;
    2223             :     }
    2224             : 
    2225           4 :     if( bSet )
    2226             :     {
    2227             :         const SfxPoolItem* pItem;
    2228           4 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
    2229           4 :                                                    &pItem ) )
    2230             :         {
    2231           1 :             SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
    2232           1 :             aULItem.SetLower( nLower );
    2233           1 :             rItemSet.Put( aULItem );
    2234             :         }
    2235             :         else
    2236             :         {
    2237           3 :             SvxULSpaceItem aULItem( aItemIds.nULSpace );
    2238           3 :             aULItem.SetLower( nLower );
    2239           3 :             rItemSet.Put( aULItem );
    2240             :         }
    2241           4 :         rPropInfo.bBottomMargin = sal_True;
    2242             :     }
    2243           4 : }
    2244             : 
    2245           2 : static void ParseCSS1_margin( const CSS1Expression *pExpr,
    2246             :                               SfxItemSet &rItemSet,
    2247             :                               SvxCSS1PropertyInfo& rPropInfo,
    2248             :                               const SvxCSS1Parser& /*rParser*/ )
    2249             : {
    2250             :     OSL_ENSURE( pExpr, "no expression" );
    2251             : 
    2252           2 :     long nMargins[4] = { 0, 0, 0, 0 };
    2253           2 :     sal_Bool bSetMargins[4] = { sal_False, sal_False, sal_False, sal_False };
    2254             : 
    2255           4 :     for( sal_uInt16 i=0; pExpr && i<4 && !pExpr->GetOp(); i++ )
    2256             :     {
    2257           2 :         sal_Bool bSetThis = sal_False;
    2258           2 :         long nMargin = 0;
    2259             : 
    2260           2 :         switch( pExpr->GetType() )
    2261             :         {
    2262             :         case CSS1_LENGTH:
    2263             :             {
    2264           2 :                 nMargin = pExpr->GetSLength();
    2265           2 :                 bSetThis = sal_True;
    2266             :             }
    2267           2 :             break;
    2268             :         case CSS1_PIXLENGTH:
    2269             :             {
    2270           0 :                 long nPWidth = 0;
    2271           0 :                 nMargin =  (long)pExpr->GetNumber();
    2272           0 :                 SvxCSS1Parser::PixelToTwip( nPWidth, nMargin );
    2273           0 :                 bSetThis = sal_True;
    2274             :             }
    2275           0 :             break;
    2276             :         case CSS1_PERCENTAGE:
    2277             :             // koennen wir nicht
    2278           0 :             break;
    2279             :         default:
    2280             :             ;
    2281             :         }
    2282             : 
    2283           2 :         if( bSetThis )
    2284             :         {
    2285             :             // 0 = top
    2286             :             // 1 = right
    2287             :             // 2 = bottom
    2288             :             // 3 = left
    2289           2 :             switch( i )
    2290             :             {
    2291             :             case 0:
    2292           2 :                 nMargins[0] = nMargins[1] =nMargins[2] = nMargins[3] = nMargin;
    2293           2 :                 bSetMargins[0] = bSetMargins[1] =
    2294           4 :                 bSetMargins[2] = bSetMargins[3] = sal_True;
    2295           2 :                 break;
    2296             :             case 1:
    2297           0 :                 nMargins[1] = nMargins[3] = nMargin;    // right + left
    2298           0 :                 bSetMargins[1] = bSetMargins[3] = sal_True;
    2299           0 :                 break;
    2300             :             case 2:
    2301           0 :                 nMargins[2] = nMargin;  // bottom
    2302           0 :                 bSetMargins[2] = sal_True;
    2303           0 :                 break;
    2304             :             case 3:
    2305           0 :                 nMargins[3] = nMargin;  // left
    2306           0 :                 bSetMargins[3] = sal_True;
    2307           0 :                 break;
    2308             :             }
    2309             :         }
    2310           2 :         pExpr = pExpr->GetNext();
    2311             :     }
    2312             : 
    2313           2 :     if( bSetMargins[3] || bSetMargins[1] )
    2314             :     {
    2315           2 :         if( bSetMargins[3] )
    2316             :         {
    2317           2 :             rPropInfo.bLeftMargin = sal_True;
    2318           2 :             rPropInfo.nLeftMargin = nMargins[3];
    2319           2 :             if( nMargins[3] < 0 )
    2320           0 :                 nMargins[3] = 0;
    2321             :         }
    2322           2 :         if( bSetMargins[1] )
    2323             :         {
    2324           2 :             rPropInfo.bRightMargin = sal_True;
    2325           2 :             rPropInfo.nRightMargin = nMargins[1];
    2326           2 :             if( nMargins[1] < 0 )
    2327           0 :                 nMargins[1] = 0;
    2328             :         }
    2329             : 
    2330             :         const SfxPoolItem* pItem;
    2331           2 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, false,
    2332           2 :                                                    &pItem ) )
    2333             :         {
    2334           0 :             SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
    2335           0 :             if( bSetMargins[3] )
    2336           0 :                 aLRItem.SetLeft( (sal_uInt16)nMargins[3] );
    2337           0 :             if( bSetMargins[1] )
    2338           0 :                 aLRItem.SetRight( (sal_uInt16)nMargins[1] );
    2339           0 :             rItemSet.Put( aLRItem );
    2340             :         }
    2341             :         else
    2342             :         {
    2343           2 :             SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
    2344           2 :             if( bSetMargins[3] )
    2345           2 :                 aLRItem.SetLeft( (sal_uInt16)nMargins[3] );
    2346           2 :             if( bSetMargins[1] )
    2347           2 :                 aLRItem.SetRight( (sal_uInt16)nMargins[1] );
    2348           2 :             rItemSet.Put( aLRItem );
    2349             :         }
    2350             :     }
    2351             : 
    2352           2 :     if( bSetMargins[0] || bSetMargins[2] )
    2353             :     {
    2354           2 :         if( nMargins[0] < 0 )
    2355           0 :             nMargins[0] = 0;
    2356           2 :         if( nMargins[2] < 0 )
    2357           0 :             nMargins[2] = 0;
    2358             : 
    2359             :         const SfxPoolItem* pItem;
    2360           2 :         if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, false,
    2361           2 :                                                    &pItem ) )
    2362             :         {
    2363           0 :             SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
    2364           0 :             if( bSetMargins[0] )
    2365           0 :                 aULItem.SetUpper( (sal_uInt16)nMargins[0] );
    2366           0 :             if( bSetMargins[2] )
    2367           0 :                 aULItem.SetLower( (sal_uInt16)nMargins[2] );
    2368           0 :             rItemSet.Put( aULItem );
    2369             :         }
    2370             :         else
    2371             :         {
    2372           2 :             SvxULSpaceItem aULItem( aItemIds.nULSpace );
    2373           2 :             if( bSetMargins[0] )
    2374           2 :                 aULItem.SetUpper( (sal_uInt16)nMargins[0] );
    2375           2 :             if( bSetMargins[2] )
    2376           2 :                 aULItem.SetLower( (sal_uInt16)nMargins[2] );
    2377           2 :             rItemSet.Put( aULItem );
    2378             :         }
    2379             : 
    2380           2 :         rPropInfo.bTopMargin |= bSetMargins[0];
    2381           2 :         rPropInfo.bBottomMargin |= bSetMargins[2];
    2382             :     }
    2383           2 : }
    2384             : 
    2385        2084 : static sal_Bool ParseCSS1_padding_xxx( const CSS1Expression *pExpr,
    2386             :                                    SfxItemSet & /*rItemSet*/,
    2387             :                                    SvxCSS1PropertyInfo& rPropInfo,
    2388             :                                    const SvxCSS1Parser& /*rParser*/,
    2389             :                                    sal_uInt16 nWhichLine )
    2390             : {
    2391             :     OSL_ENSURE( pExpr, "no expression" );
    2392             : 
    2393        2084 :     sal_Bool bSet = sal_False;
    2394        2084 :     sal_uInt16 nDist = 0;
    2395             : 
    2396        2084 :     switch( pExpr->GetType() )
    2397             :     {
    2398             :     case CSS1_LENGTH:
    2399             :         {
    2400        2084 :             long nTmp = pExpr->GetSLength();
    2401        2084 :             if( nTmp < 0 )
    2402           0 :                 nTmp = 0;
    2403        2084 :             else if( nTmp > USHRT_MAX-1 )
    2404           0 :                 nTmp = USHRT_MAX-1;
    2405        2084 :             nDist = (sal_uInt16)nTmp;
    2406        2084 :             bSet = sal_True;
    2407             :         }
    2408        2084 :         break;
    2409             :     case CSS1_PIXLENGTH:
    2410             :         {
    2411           0 :             long nPWidth = (long)pExpr->GetNumber();
    2412           0 :             long nPHeight = 0;
    2413           0 :             if( nPWidth < 0 )
    2414           0 :                 nPWidth = 0;
    2415           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2416           0 :             if( nPWidth > USHRT_MAX-1 )
    2417           0 :                 nPWidth = USHRT_MAX-1;
    2418           0 :             nDist = (sal_uInt16)nPWidth;
    2419           0 :             bSet = sal_True;
    2420             :         }
    2421           0 :         break;
    2422             :     case CSS1_PERCENTAGE:
    2423             :         // koennen wir nicht
    2424           0 :         break;
    2425             :     default:
    2426             :         ;
    2427             :     }
    2428             : 
    2429        2084 :     if( bSet )
    2430             :     {
    2431        2084 :         switch( nWhichLine )
    2432             :         {
    2433         521 :         case BOX_LINE_TOP:      rPropInfo.nTopBorderDistance = nDist;   break;
    2434         521 :         case BOX_LINE_BOTTOM:   rPropInfo.nBottomBorderDistance = nDist;break;
    2435         521 :         case BOX_LINE_LEFT:     rPropInfo.nLeftBorderDistance = nDist;  break;
    2436         521 :         case BOX_LINE_RIGHT:    rPropInfo.nRightBorderDistance = nDist; break;
    2437             :         }
    2438             :     }
    2439             : 
    2440        2084 :     return bSet;
    2441             : }
    2442             : 
    2443         521 : static void ParseCSS1_padding_top( const CSS1Expression *pExpr,
    2444             :                                    SfxItemSet &rItemSet,
    2445             :                                    SvxCSS1PropertyInfo& rPropInfo,
    2446             :                                    const SvxCSS1Parser& rParser )
    2447             : {
    2448         521 :     ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
    2449         521 : }
    2450             : 
    2451         521 : static void ParseCSS1_padding_bottom( const CSS1Expression *pExpr,
    2452             :                                       SfxItemSet &rItemSet,
    2453             :                                       SvxCSS1PropertyInfo& rPropInfo,
    2454             :                                       const SvxCSS1Parser& rParser )
    2455             : {
    2456             :     ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
    2457         521 :                            BOX_LINE_BOTTOM );
    2458         521 : }
    2459             : 
    2460         521 : static void ParseCSS1_padding_left( const CSS1Expression *pExpr,
    2461             :                                     SfxItemSet &rItemSet,
    2462             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2463             :                                     const SvxCSS1Parser& rParser )
    2464             : {
    2465         521 :     ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
    2466         521 : }
    2467             : 
    2468         521 : static void ParseCSS1_padding_right( const CSS1Expression *pExpr,
    2469             :                                      SfxItemSet &rItemSet,
    2470             :                                      SvxCSS1PropertyInfo& rPropInfo,
    2471             :                                      const SvxCSS1Parser& rParser )
    2472             : {
    2473             :     ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
    2474         521 :                            BOX_LINE_RIGHT );
    2475         521 : }
    2476             : 
    2477           0 : static void ParseCSS1_padding( const CSS1Expression *pExpr,
    2478             :                                SfxItemSet &rItemSet,
    2479             :                                SvxCSS1PropertyInfo& rPropInfo,
    2480             :                                const SvxCSS1Parser& rParser )
    2481             : {
    2482           0 :     sal_uInt16 n=0;
    2483           0 :     while( n<4 && pExpr && !pExpr->GetOp() )
    2484             :     {
    2485           0 :         sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
    2486           0 :         if( ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
    2487           0 :                                    nLine ) )
    2488             :         {
    2489           0 :             if( n==0 )
    2490             :             {
    2491           0 :                 rPropInfo.nTopBorderDistance = rPropInfo.nBottomBorderDistance;
    2492           0 :                 rPropInfo.nLeftBorderDistance = rPropInfo.nTopBorderDistance;
    2493             :             }
    2494           0 :             if( n <= 1 )
    2495           0 :                 rPropInfo.nRightBorderDistance = rPropInfo.nLeftBorderDistance;
    2496             :         }
    2497             : 
    2498           0 :         pExpr = pExpr->GetNext();
    2499           0 :         n++;
    2500             :     }
    2501           0 : }
    2502             : 
    2503         524 : static void ParseCSS1_border_xxx( const CSS1Expression *pExpr,
    2504             :                                   SfxItemSet & /*rItemSet*/,
    2505             :                                   SvxCSS1PropertyInfo& rPropInfo,
    2506             :                                   const SvxCSS1Parser& /*rParser*/,
    2507             :                                   sal_uInt16 nWhichLine, sal_Bool bAll )
    2508             : {
    2509             :     OSL_ENSURE( pExpr, "no expression" );
    2510             : 
    2511         524 :     sal_uInt16 nWidth = USHRT_MAX;      // die Linien-Dicke
    2512         524 :     sal_uInt16 nNWidth = 1;             // benannte Linien-Dicke (und default)
    2513         524 :     CSS1BorderStyle eStyle = CSS1_BS_NONE; // Linien-Style
    2514         524 :     Color aColor;
    2515         524 :     sal_Bool bColor = sal_False;
    2516             : 
    2517        2620 :     while( pExpr && !pExpr->GetOp() )
    2518             :     {
    2519        1572 :         switch( pExpr->GetType() )
    2520             :         {
    2521             :         case CSS1_RGB:
    2522             :         case CSS1_HEXCOLOR:
    2523         524 :             if( pExpr->GetColor( aColor ) )
    2524         524 :                 bColor = sal_True;
    2525         524 :             break;
    2526             : 
    2527             :         case CSS1_IDENT:
    2528             :             {
    2529         524 :                 const OUString& rValue = pExpr->GetString();
    2530             :                 sal_uInt16 nValue;
    2531         524 :                 if( SvxCSS1Parser::GetEnum( aBorderWidthTable, rValue, nValue ) )
    2532             :                 {
    2533           0 :                     nNWidth = nValue;
    2534             :                 }
    2535         524 :                 else if( SvxCSS1Parser::GetEnum( aBorderStyleTable, rValue, nValue ) )
    2536             :                 {
    2537         524 :                     eStyle = (CSS1BorderStyle)nValue;
    2538             :                 }
    2539           0 :                 else if( pExpr->GetColor( aColor ) )
    2540             :                 {
    2541           0 :                     bColor = sal_True;
    2542             :                 }
    2543             :             }
    2544         524 :             break;
    2545             : 
    2546             :         case CSS1_LENGTH:
    2547           4 :             nWidth = (sal_uInt16)pExpr->GetULength();
    2548           4 :             break;
    2549             : 
    2550             :         case CSS1_PIXLENGTH:
    2551             :             {
    2552         520 :                 sal_Bool bHori = nWhichLine == BOX_LINE_TOP ||
    2553         520 :                              nWhichLine == BOX_LINE_BOTTOM;
    2554             :                 // Ein Pixel wird zur Haarlinie (ist huebscher)
    2555         520 :                 long nWidthL = (long)pExpr->GetNumber();
    2556         520 :                 if( nWidthL > 1 )
    2557             :                 {
    2558           0 :                     long nPWidth = bHori ? 0 : nWidthL;
    2559           0 :                     long nPHeight = bHori ? nWidthL : 0;
    2560           0 :                     SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2561           0 :                     nWidth = (sal_uInt16)(bHori ? nPHeight : nPWidth);
    2562             :                 }
    2563             :                 else
    2564         520 :                     nWidth = 1;
    2565             :             }
    2566         520 :             break;
    2567             : 
    2568             :         default:
    2569             :             ;
    2570             :         }
    2571             : 
    2572        1572 :         pExpr = pExpr->GetNext();
    2573             :     }
    2574             : 
    2575        2620 :     for( sal_uInt16 i=0; i<4; i++ )
    2576             :     {
    2577        2096 :         sal_uInt16 nLine = 0;
    2578        2096 :         switch( i )
    2579             :         {
    2580         524 :         case 0: nLine = BOX_LINE_TOP; break;
    2581         524 :         case 1: nLine = BOX_LINE_BOTTOM; break;
    2582         524 :         case 2: nLine = BOX_LINE_LEFT; break;
    2583         524 :         case 3: nLine = BOX_LINE_RIGHT; break;
    2584             :         }
    2585             : 
    2586        2096 :         if( bAll || nLine == nWhichLine )
    2587             :         {
    2588        2084 :             SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nLine );
    2589        2084 :             pInfo->eStyle = eStyle;
    2590        2084 :             pInfo->nAbsWidth = nWidth;
    2591        2084 :             pInfo->nNamedWidth = nNWidth;
    2592        2084 :             if( bColor )
    2593        2084 :                 pInfo->aColor = aColor;
    2594             :         }
    2595             :     }
    2596         524 : }
    2597             : 
    2598           0 : static void ParseCSS1_border_xxx_width( const CSS1Expression *pExpr,
    2599             :                                         SfxItemSet & /*rItemSet*/,
    2600             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2601             :                                         const SvxCSS1Parser& /*rParser*/,
    2602             :                                         sal_uInt16 nWhichLine )
    2603             : {
    2604             :     OSL_ENSURE( pExpr, "no expression" );
    2605             : 
    2606           0 :     sal_uInt16 nWidth = USHRT_MAX;      // die Linien-Dicke
    2607           0 :     sal_uInt16 nNWidth = 1;             // benannte Linien-Dicke (und default)
    2608             : 
    2609           0 :     switch( pExpr->GetType() )
    2610             :     {
    2611             :     case CSS1_IDENT:
    2612             :         {
    2613             :             sal_uInt16 nValue;
    2614           0 :             if( SvxCSS1Parser::GetEnum( aBorderWidthTable, pExpr->GetString(), nValue ) )
    2615             :             {
    2616           0 :                 nNWidth = nValue;
    2617             :             }
    2618             :         }
    2619           0 :         break;
    2620             : 
    2621             :     case CSS1_LENGTH:
    2622           0 :         nWidth = (sal_uInt16)pExpr->GetULength();
    2623           0 :         break;
    2624             : 
    2625             :     case CSS1_PIXLENGTH:
    2626             :         {
    2627           0 :             sal_Bool bHori = nWhichLine == BOX_LINE_TOP ||
    2628           0 :                          nWhichLine == BOX_LINE_BOTTOM;
    2629           0 :             long nWidthL = (long)pExpr->GetNumber();
    2630           0 :             long nPWidth = bHori ? 0 : nWidthL;
    2631           0 :             long nPHeight = bHori ? nWidthL : 0;
    2632           0 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2633           0 :             nWidth = (sal_uInt16)(bHori ? nPHeight : nPWidth);
    2634             :         }
    2635           0 :         break;
    2636             : 
    2637             :     default:
    2638             :         ;
    2639             :     }
    2640             : 
    2641           0 :     SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nWhichLine );
    2642           0 :     pInfo->nAbsWidth = nWidth;
    2643           0 :     pInfo->nNamedWidth = nNWidth;
    2644           0 : }
    2645             : 
    2646           0 : static void ParseCSS1_border_top_width( const CSS1Expression *pExpr,
    2647             :                                         SfxItemSet &rItemSet,
    2648             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2649             :                                         const SvxCSS1Parser& rParser )
    2650             : {
    2651           0 :     ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
    2652           0 : }
    2653             : 
    2654           0 : static void ParseCSS1_border_right_width( const CSS1Expression *pExpr,
    2655             :                                         SfxItemSet &rItemSet,
    2656             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2657             :                                         const SvxCSS1Parser& rParser )
    2658             : {
    2659           0 :     ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT );
    2660           0 : }
    2661             : 
    2662           0 : static void ParseCSS1_border_bottom_width( const CSS1Expression *pExpr,
    2663             :                                         SfxItemSet &rItemSet,
    2664             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2665             :                                         const SvxCSS1Parser& rParser )
    2666             : {
    2667           0 :     ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM );
    2668           0 : }
    2669             : 
    2670           0 : static void ParseCSS1_border_left_width( const CSS1Expression *pExpr,
    2671             :                                         SfxItemSet &rItemSet,
    2672             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2673             :                                         const SvxCSS1Parser& rParser )
    2674             : {
    2675           0 :     ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
    2676           0 : }
    2677             : 
    2678           0 : static void ParseCSS1_border_width( const CSS1Expression *pExpr,
    2679             :                                     SfxItemSet &rItemSet,
    2680             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2681             :                                     const SvxCSS1Parser& rParser )
    2682             : {
    2683           0 :     sal_uInt16 n=0;
    2684           0 :     while( n<4 && pExpr && !pExpr->GetOp() )
    2685             :     {
    2686           0 :         sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
    2687           0 :         ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, nLine );
    2688           0 :         rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_WIDTH );
    2689             : 
    2690           0 :         pExpr = pExpr->GetNext();
    2691           0 :         n++;
    2692             :     }
    2693           0 : }
    2694             : 
    2695           0 : static void ParseCSS1_border_color( const CSS1Expression *pExpr,
    2696             :                                     SfxItemSet & /*rItemSet*/,
    2697             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2698             :                                     const SvxCSS1Parser& /*rParser*/ )
    2699             : {
    2700           0 :     sal_uInt16 n=0;
    2701           0 :     while( n<4 && pExpr && !pExpr->GetOp() )
    2702             :     {
    2703           0 :         sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
    2704           0 :         Color aColor;
    2705           0 :         switch( pExpr->GetType() )
    2706             :         {
    2707             :         case CSS1_RGB:
    2708             :         case CSS1_HEXCOLOR:
    2709             :         case CSS1_IDENT:
    2710           0 :             if( pExpr->GetColor( aColor ) )
    2711           0 :                 rPropInfo.GetBorderInfo( nLine )->aColor = aColor;
    2712           0 :             break;
    2713             :         default:
    2714             :             ;
    2715             :         }
    2716           0 :         rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_COLOR );
    2717             : 
    2718           0 :         pExpr = pExpr->GetNext();
    2719           0 :         n++;
    2720             :     }
    2721           0 : }
    2722             : 
    2723           0 : static void ParseCSS1_border_style( const CSS1Expression *pExpr,
    2724             :                                     SfxItemSet & /*rItemSet*/,
    2725             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2726             :                                     const SvxCSS1Parser& /*rParser*/ )
    2727             : {
    2728           0 :     sal_uInt16 n=0;
    2729           0 :     while( n<4 && pExpr && !pExpr->GetOp() )
    2730             :     {
    2731           0 :         sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
    2732           0 :         sal_uInt16 nValue = 0;
    2733           0 :         if( CSS1_IDENT==pExpr->GetType() &&
    2734           0 :             SvxCSS1Parser::GetEnum( aBorderStyleTable, pExpr->GetString(),
    2735           0 :                                     nValue ) )
    2736             :         {
    2737           0 :             rPropInfo.GetBorderInfo( nLine )->eStyle = (CSS1BorderStyle)nValue;
    2738             :         }
    2739           0 :         rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_STYLE );
    2740             : 
    2741           0 :         pExpr = pExpr->GetNext();
    2742           0 :         n++;
    2743             :     }
    2744           0 : }
    2745             : 
    2746           1 : static void ParseCSS1_border_top( const CSS1Expression *pExpr,
    2747             :                                   SfxItemSet &rItemSet,
    2748             :                                   SvxCSS1PropertyInfo& rPropInfo,
    2749             :                                   const SvxCSS1Parser& rParser )
    2750             : {
    2751           1 :     ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP, sal_False );
    2752           1 : }
    2753             : 
    2754           1 : static void ParseCSS1_border_right( const CSS1Expression *pExpr,
    2755             :                                     SfxItemSet &rItemSet,
    2756             :                                     SvxCSS1PropertyInfo& rPropInfo,
    2757             :                                     const SvxCSS1Parser& rParser )
    2758             : {
    2759           1 :     ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT, sal_False );
    2760           1 : }
    2761             : 
    2762           1 : static void ParseCSS1_border_bottom( const CSS1Expression *pExpr,
    2763             :                                      SfxItemSet &rItemSet,
    2764             :                                      SvxCSS1PropertyInfo& rPropInfo,
    2765             :                                      const SvxCSS1Parser& rParser )
    2766             : {
    2767           1 :     ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM, sal_False );
    2768           1 : }
    2769             : 
    2770           1 : static void ParseCSS1_border_left( const CSS1Expression *pExpr,
    2771             :                                    SfxItemSet &rItemSet,
    2772             :                                    SvxCSS1PropertyInfo& rPropInfo,
    2773             :                                    const SvxCSS1Parser& rParser )
    2774             : {
    2775           1 :     ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT, sal_False );
    2776           1 : }
    2777             : 
    2778         520 : static void ParseCSS1_border( const CSS1Expression *pExpr,
    2779             :                               SfxItemSet &rItemSet,
    2780             :                               SvxCSS1PropertyInfo& rPropInfo,
    2781             :                               const SvxCSS1Parser& rParser )
    2782             : {
    2783         520 :     ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, 0, sal_True );
    2784         520 : }
    2785             : 
    2786           0 : static void ParseCSS1_float( const CSS1Expression *pExpr,
    2787             :                              SfxItemSet & /*rItemSet*/,
    2788             :                              SvxCSS1PropertyInfo& rPropInfo,
    2789             :                              const SvxCSS1Parser& /*rParser*/ )
    2790             : {
    2791             :     OSL_ENSURE( pExpr, "no expression" );
    2792             : 
    2793           0 :     if( CSS1_IDENT==pExpr->GetType() )
    2794             :     {
    2795             :         sal_uInt16 nFloat;
    2796           0 :         if( SvxCSS1Parser::GetEnum( aFloatTable, pExpr->GetString(), nFloat ) )
    2797           0 :             rPropInfo.eFloat = (SvxAdjust)nFloat;
    2798             :     }
    2799           0 : }
    2800             : 
    2801           2 : static void ParseCSS1_position( const CSS1Expression *pExpr,
    2802             :                                 SfxItemSet & /*rItemSet*/,
    2803             :                                 SvxCSS1PropertyInfo& rPropInfo,
    2804             :                                 const SvxCSS1Parser& /*rParser*/ )
    2805             : {
    2806             :     OSL_ENSURE( pExpr, "no expression" );
    2807             : 
    2808           2 :     if( CSS1_IDENT==pExpr->GetType() )
    2809             :     {
    2810             :         sal_uInt16 nPos;
    2811           2 :         if( SvxCSS1Parser::GetEnum( aPositionTable, pExpr->GetString(), nPos ) )
    2812           2 :             rPropInfo.ePosition = (SvxCSS1Position)nPos;
    2813             :     }
    2814           2 : }
    2815             : 
    2816           6 : static void ParseCSS1_length( const CSS1Expression *pExpr,
    2817             :                               long& rLength,
    2818             :                               SvxCSS1LengthType& rLengthType,
    2819             :                               sal_Bool bHori )
    2820             : {
    2821           6 :     switch( pExpr->GetType() )
    2822             :     {
    2823             :     case CSS1_IDENT:
    2824           0 :         if( pExpr->GetString().equalsIgnoreAsciiCase( "auto" ) )
    2825             :         {
    2826           0 :             rLength = 0;
    2827           0 :             rLengthType = SVX_CSS1_LTYPE_AUTO;
    2828             :         }
    2829           0 :         break;
    2830             : 
    2831             :     case CSS1_LENGTH:
    2832           0 :         rLength = pExpr->GetSLength();
    2833           0 :         rLengthType = SVX_CSS1_LTYPE_TWIP;
    2834           0 :         break;
    2835             : 
    2836             :     case CSS1_PIXLENGTH:
    2837             :     case CSS1_NUMBER:       // wegen Netscape und IE
    2838             :         {
    2839           6 :             long nWidthL = (long)pExpr->GetNumber();
    2840           6 :             long nPWidth = bHori ? 0 : nWidthL;
    2841           6 :             long nPHeight = bHori ? nWidthL : 0;
    2842           6 :             SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2843           6 :             rLength = (bHori ? nPHeight : nPWidth);
    2844           6 :             rLengthType = SVX_CSS1_LTYPE_TWIP;
    2845             :         }
    2846           6 :         break;
    2847             : 
    2848             :     case CSS1_PERCENTAGE:
    2849           0 :         rLength = (long)pExpr->GetNumber();
    2850           0 :         if( rLength > 100 )
    2851           0 :             rLength = 100;
    2852           0 :         rLengthType = SVX_CSS1_LTYPE_PERCENTAGE;
    2853           0 :         break;
    2854             : 
    2855             :     default:
    2856             :         ;
    2857             :     }
    2858           6 : }
    2859             : 
    2860           1 : static void ParseCSS1_width( const CSS1Expression *pExpr,
    2861             :                              SfxItemSet & /*rItemSet*/,
    2862             :                              SvxCSS1PropertyInfo& rPropInfo,
    2863             :                              const SvxCSS1Parser& /*rParser*/ )
    2864             : {
    2865           1 :     ParseCSS1_length( pExpr, rPropInfo.nWidth, rPropInfo.eWidthType, sal_True );
    2866           1 : }
    2867             : 
    2868           1 : static void ParseCSS1_height( const CSS1Expression *pExpr,
    2869             :                               SfxItemSet & /*rItemSet*/,
    2870             :                               SvxCSS1PropertyInfo& rPropInfo,
    2871             :                               const SvxCSS1Parser& /*rParser*/ )
    2872             : {
    2873           1 :     ParseCSS1_length( pExpr, rPropInfo.nHeight, rPropInfo.eHeightType, sal_False );
    2874           1 : }
    2875             : 
    2876           2 : static void ParseCSS1_left( const CSS1Expression *pExpr,
    2877             :                              SfxItemSet & /*rItemSet*/,
    2878             :                              SvxCSS1PropertyInfo& rPropInfo,
    2879             :                              const SvxCSS1Parser& /*rParser*/ )
    2880             : {
    2881           2 :     ParseCSS1_length( pExpr, rPropInfo.nLeft, rPropInfo.eLeftType, sal_True );
    2882           2 : }
    2883             : 
    2884           2 : static void ParseCSS1_top( const CSS1Expression *pExpr,
    2885             :                            SfxItemSet & /*rItemSet*/,
    2886             :                            SvxCSS1PropertyInfo& rPropInfo,
    2887             :                            const SvxCSS1Parser& /*rParser*/ )
    2888             : {
    2889           2 :     ParseCSS1_length( pExpr, rPropInfo.nTop, rPropInfo.eTopType, sal_False );
    2890           2 : }
    2891             : 
    2892             : // Feature: PrintExt
    2893           2 : static void ParseCSS1_size( const CSS1Expression *pExpr,
    2894             :                             SfxItemSet & /*rItemSet*/,
    2895             :                             SvxCSS1PropertyInfo& rPropInfo,
    2896             :                             const SvxCSS1Parser& /*rParser*/ )
    2897             : {
    2898           2 :     sal_uInt16 n=0;
    2899           8 :     while( n<2 && pExpr && !pExpr->GetOp() )
    2900             :     {
    2901           4 :         switch( pExpr->GetType() )
    2902             :         {
    2903             :         case CSS1_IDENT:
    2904             :             {
    2905             :                 sal_uInt16 nValue;
    2906           0 :                 if( SvxCSS1Parser::GetEnum( aSizeTable, pExpr->GetString(),
    2907           0 :                                             nValue ) )
    2908             :                 {
    2909           0 :                     rPropInfo.eSizeType = (SvxCSS1SizeType)nValue;
    2910             :                 }
    2911             :             }
    2912           0 :             break;
    2913             : 
    2914             :         case CSS1_LENGTH:
    2915           4 :             rPropInfo.nHeight = pExpr->GetSLength();
    2916           4 :             if( n==0 )
    2917           2 :                 rPropInfo.nWidth = rPropInfo.nHeight;
    2918           4 :             rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
    2919           4 :             break;
    2920             : 
    2921             :         case CSS1_PIXLENGTH:
    2922             :             {
    2923           0 :                 long nPHeight = (long)pExpr->GetNumber();
    2924           0 :                 long nPWidth = n==0 ? nPHeight : 0;
    2925           0 :                 SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
    2926           0 :                 rPropInfo.nHeight = nPHeight;
    2927           0 :                 if( n==0 )
    2928           0 :                     rPropInfo.nWidth = nPWidth;
    2929           0 :                 rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
    2930             :             }
    2931           0 :             break;
    2932             : 
    2933             :         default:
    2934             :             ;
    2935             :         }
    2936             : 
    2937           4 :         pExpr = pExpr->GetNext();
    2938           4 :         n++;
    2939             :     }
    2940           2 : }
    2941             : 
    2942             : // /Feature: PrintExt
    2943             : 
    2944             : // Feature: PrintExt
    2945             : 
    2946           1 : static void ParseCSS1_page_break_xxx( const CSS1Expression *pExpr,
    2947             :                                       SvxCSS1PageBreak& rPBreak )
    2948             : {
    2949           1 :     if( CSS1_IDENT == pExpr->GetType() )
    2950             :     {
    2951             :         sal_uInt16 nValue;
    2952           2 :         if( SvxCSS1Parser::GetEnum( aPageBreakTable, pExpr->GetString(),
    2953           1 :                                     nValue ) )
    2954             :         {
    2955           1 :             rPBreak = (SvxCSS1PageBreak)nValue;
    2956             :         }
    2957             :     }
    2958           1 : }
    2959             : 
    2960           1 : static void ParseCSS1_page_break_before( const CSS1Expression *pExpr,
    2961             :                                          SfxItemSet & /*rItemSet*/,
    2962             :                                          SvxCSS1PropertyInfo& rPropInfo,
    2963             :                                          const SvxCSS1Parser& /*rParser*/ )
    2964             : {
    2965           1 :     ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakBefore );
    2966           1 : }
    2967             : 
    2968           0 : static void ParseCSS1_page_break_after( const CSS1Expression *pExpr,
    2969             :                                         SfxItemSet & /*rItemSet*/,
    2970             :                                         SvxCSS1PropertyInfo& rPropInfo,
    2971             :                                         const SvxCSS1Parser& /*rParser*/ )
    2972             : {
    2973           0 :     ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakAfter );
    2974           0 : }
    2975             : 
    2976           0 : static void ParseCSS1_page_break_inside( const CSS1Expression *pExpr,
    2977             :                                          SfxItemSet &rItemSet,
    2978             :                                          SvxCSS1PropertyInfo& /*rPropInfo*/,
    2979             :                                          const SvxCSS1Parser& /*rParser*/ )
    2980             : {
    2981           0 :     SvxCSS1PageBreak eBreak(SVX_CSS1_PBREAK_NONE);
    2982           0 :     ParseCSS1_page_break_xxx( pExpr, eBreak );
    2983             : 
    2984           0 :     sal_Bool bSetSplit = sal_False, bSplit = sal_True;
    2985           0 :     switch( eBreak )
    2986             :     {
    2987             :     case SVX_CSS1_PBREAK_AUTO:
    2988           0 :         bSetSplit = sal_True;
    2989           0 :         break;
    2990             :     case SVX_CSS1_PBREAK_AVOID:
    2991           0 :         bSplit = sal_False;
    2992           0 :         bSetSplit = sal_True;
    2993           0 :         break;
    2994             :     default:
    2995             :         ;
    2996             :     }
    2997             : 
    2998           0 :     if( bSetSplit )
    2999           0 :         rItemSet.Put( SvxFmtSplitItem( bSplit, aItemIds.nFmtSplit ) );
    3000           0 : }
    3001             : 
    3002           1 : static void ParseCSS1_widows( const CSS1Expression *pExpr,
    3003             :                               SfxItemSet &rItemSet,
    3004             :                               SvxCSS1PropertyInfo& /*rPropInfo*/,
    3005             :                               const SvxCSS1Parser& /*rParser*/ )
    3006             : {
    3007           1 :     if( CSS1_NUMBER == pExpr->GetType() )
    3008             :     {
    3009           1 :         sal_uInt8 nVal = pExpr->GetNumber() <= 255
    3010           1 :                         ? (sal_uInt8)pExpr->GetNumber()
    3011           2 :                         : 255;
    3012           1 :         SvxWidowsItem aWidowsItem( nVal, aItemIds.nWidows );
    3013           1 :         rItemSet.Put( aWidowsItem );
    3014             :     }
    3015           1 : }
    3016             : 
    3017           1 : static void ParseCSS1_orphans( const CSS1Expression *pExpr,
    3018             :                                SfxItemSet &rItemSet,
    3019             :                                SvxCSS1PropertyInfo& /*rPropInfo*/,
    3020             :                                const SvxCSS1Parser& /*rParser*/ )
    3021             : {
    3022           1 :     if( CSS1_NUMBER == pExpr->GetType() )
    3023             :     {
    3024           1 :         sal_uInt8 nVal = pExpr->GetNumber() <= 255
    3025           1 :                         ? (sal_uInt8)pExpr->GetNumber()
    3026           2 :                         : 255;
    3027           1 :         SvxOrphansItem aOrphansItem( nVal, aItemIds.nOrphans );
    3028           1 :         rItemSet.Put( aOrphansItem );
    3029             :     }
    3030           1 : }
    3031             : // /Feature: PrintExt
    3032             : 
    3033           2 : static void ParseCSS1_so_language( const CSS1Expression *pExpr,
    3034             :                                SfxItemSet &rItemSet,
    3035             :                                SvxCSS1PropertyInfo& /*rPropInfo*/,
    3036             :                                const SvxCSS1Parser& rParser )
    3037             : {
    3038           2 :     if( CSS1_IDENT == pExpr->GetType() ||
    3039           0 :         CSS1_STRING == pExpr->GetType() )
    3040             :     {
    3041           2 :         LanguageType eLang = LanguageTag::convertToLanguageTypeWithFallback( pExpr->GetString() );
    3042           2 :         if( LANGUAGE_DONTKNOW != eLang )
    3043             :         {
    3044           2 :             SvxLanguageItem aLang( eLang, aItemIds.nLanguage );
    3045           2 :             if( rParser.IsSetWesternProps() )
    3046           2 :                 rItemSet.Put( aLang );
    3047           2 :             if( rParser.IsSetCJKProps() )
    3048             :             {
    3049           2 :                 aLang.SetWhich( aItemIds.nLanguageCJK );
    3050           2 :                 rItemSet.Put( aLang );
    3051             :             }
    3052           2 :             if( rParser.IsSetCTLProps() )
    3053             :             {
    3054           2 :                 aLang.SetWhich( aItemIds.nLanguageCTL );
    3055           2 :                 rItemSet.Put( aLang );
    3056           2 :             }
    3057             :         }
    3058             :     }
    3059           2 : }
    3060             : 
    3061             : // die Zuordung Property zu parsender Funktion
    3062             : struct CSS1PropEntry
    3063             : {
    3064             :     union
    3065             :     {
    3066             :         const sal_Char  *sName;
    3067             :         OUString          *pName;
    3068             :     };
    3069             :     FnParseCSS1Prop pFunc;
    3070             : };
    3071             : 
    3072             : #define CSS1_PROP_ENTRY(p) \
    3073             :     {   { sCSS1_P_##p }, ParseCSS1_##p }
    3074             : 
    3075             : // die Tabelle mit den Zuordnungen
    3076             : static CSS1PropEntry aCSS1PropFnTab[] =
    3077             : {
    3078             :     CSS1_PROP_ENTRY(background),
    3079             :     CSS1_PROP_ENTRY(background_color),
    3080             :     CSS1_PROP_ENTRY(border_top_width),
    3081             :     CSS1_PROP_ENTRY(border_right_width),
    3082             :     CSS1_PROP_ENTRY(border_bottom_width),
    3083             :     CSS1_PROP_ENTRY(border_left_width),
    3084             :     CSS1_PROP_ENTRY(border_width),
    3085             :     CSS1_PROP_ENTRY(border_color),
    3086             :     CSS1_PROP_ENTRY(border_style),
    3087             :     CSS1_PROP_ENTRY(border_top),
    3088             :     CSS1_PROP_ENTRY(border_right),
    3089             :     CSS1_PROP_ENTRY(border_bottom),
    3090             :     CSS1_PROP_ENTRY(border_left),
    3091             :     CSS1_PROP_ENTRY(border),
    3092             :     CSS1_PROP_ENTRY(color),
    3093             :     CSS1_PROP_ENTRY(column_count),
    3094             :     CSS1_PROP_ENTRY(direction),
    3095             :     CSS1_PROP_ENTRY(float),
    3096             :     CSS1_PROP_ENTRY(font_size),
    3097             :     CSS1_PROP_ENTRY(font_family),
    3098             :     CSS1_PROP_ENTRY(font_style),
    3099             :     CSS1_PROP_ENTRY(font_variant),
    3100             :     CSS1_PROP_ENTRY(font_weight),
    3101             :     CSS1_PROP_ENTRY(letter_spacing),
    3102             :     CSS1_PROP_ENTRY(line_height),
    3103             :     CSS1_PROP_ENTRY(font),
    3104             :     CSS1_PROP_ENTRY(text_align),
    3105             :     CSS1_PROP_ENTRY(text_decoration),
    3106             :     CSS1_PROP_ENTRY(text_indent),
    3107             :     CSS1_PROP_ENTRY(text_transform),
    3108             :     CSS1_PROP_ENTRY(margin_left),
    3109             :     CSS1_PROP_ENTRY(margin_right),
    3110             :     CSS1_PROP_ENTRY(margin_top),
    3111             :     CSS1_PROP_ENTRY(margin_bottom),
    3112             :     CSS1_PROP_ENTRY(margin),
    3113             :     CSS1_PROP_ENTRY(padding_top),
    3114             :     CSS1_PROP_ENTRY(padding_bottom),
    3115             :     CSS1_PROP_ENTRY(padding_left),
    3116             :     CSS1_PROP_ENTRY(padding_right),
    3117             :     CSS1_PROP_ENTRY(padding),
    3118             :     CSS1_PROP_ENTRY(position),
    3119             :     CSS1_PROP_ENTRY(left),
    3120             :     CSS1_PROP_ENTRY(top),
    3121             :     CSS1_PROP_ENTRY(width),
    3122             :     CSS1_PROP_ENTRY(height),
    3123             : // Feature: PrintExt
    3124             :     CSS1_PROP_ENTRY(size),
    3125             :     CSS1_PROP_ENTRY(page_break_before),
    3126             :     CSS1_PROP_ENTRY(page_break_after),
    3127             :     CSS1_PROP_ENTRY(page_break_inside),
    3128             :     CSS1_PROP_ENTRY(widows),
    3129             :     CSS1_PROP_ENTRY(orphans),
    3130             : // /Feature: PrintExt
    3131             :     CSS1_PROP_ENTRY(so_language)
    3132          37 : };
    3133             : 
    3134             : static int bSortedPropFns = sal_False;
    3135             : 
    3136             : extern "C"
    3137             : {
    3138       15424 : static int SAL_CALL CSS1PropEntryCompare( const void *pFirst, const void *pSecond)
    3139             : {
    3140             :     int nRet;
    3141       15424 :     if( ((CSS1PropEntry*)pFirst)->pFunc )
    3142             :     {
    3143         573 :         if( ((CSS1PropEntry*)pSecond)->pFunc )
    3144             :             nRet = strcmp( ((CSS1PropEntry*)pFirst)->sName ,
    3145         573 :                     ((CSS1PropEntry*)pSecond)->sName );
    3146             :         else
    3147             :             nRet = -1 * ((CSS1PropEntry*)pSecond)->pName->compareToAscii(
    3148           0 :                             ((CSS1PropEntry*)pFirst)->sName );
    3149             :     }
    3150             :     else
    3151             :     {
    3152       14851 :         if( ((CSS1PropEntry*)pSecond)->pFunc )
    3153             :             nRet = ((CSS1PropEntry*)pFirst)->pName->compareToAscii(
    3154       14851 :                         ((CSS1PropEntry*)pSecond)->sName );
    3155             :         else
    3156             :             nRet = ((CSS1PropEntry*)pFirst)->pName->compareTo(
    3157           0 :                         *((CSS1PropEntry*)pSecond)->pName );
    3158             :     }
    3159             : 
    3160       15424 :     return nRet;
    3161             : }
    3162             : }
    3163             : 
    3164        2867 : void SvxCSS1Parser::ParseProperty( const OUString& rProperty,
    3165             :                                    const CSS1Expression *pExpr )
    3166             : {
    3167             :     OSL_ENSURE( pItemSet, "DeclarationParsed() without ItemSet" );
    3168             : 
    3169        2867 :     if( !bSortedPropFns )
    3170             :     {
    3171             :         qsort( (void*) aCSS1PropFnTab,
    3172             :                 sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
    3173             :                 sizeof( CSS1PropEntry ),
    3174           3 :                 CSS1PropEntryCompare );
    3175           3 :         bSortedPropFns = sal_True;
    3176             :     }
    3177             : 
    3178        2867 :     OUString aTmp( rProperty.toAsciiLowerCase() );
    3179             : 
    3180             :     CSS1PropEntry aSrch;
    3181        2867 :     aSrch.pName = &aTmp;
    3182        2867 :     aSrch.pFunc = 0;
    3183             : 
    3184             :     void* pFound;
    3185        2867 :     if( 0 != ( pFound = bsearch( (char *) &aSrch,
    3186             :                         (void*) aCSS1PropFnTab,
    3187             :                         sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
    3188             :                         sizeof( CSS1PropEntry ),
    3189        2867 :                         CSS1PropEntryCompare )))
    3190             :     {
    3191        2862 :         (((CSS1PropEntry*)pFound)->pFunc)( pExpr, *pItemSet, *pPropInfo, *this );
    3192        2867 :     }
    3193        2978 : }
    3194             : 
    3195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10