LCOV - code coverage report
Current view: top level - sw/source/filter/html - swcss1.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 38 81.6 %
Date: 2015-06-13 12:38:46 Functions: 15 20 75.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             : #ifndef INCLUDED_SW_SOURCE_FILTER_HTML_SWCSS1_HXX
      21             : #define INCLUDED_SW_SOURCE_FILTER_HTML_SWCSS1_HXX
      22             : 
      23             : #include "poolfmt.hxx"
      24             : 
      25             : #include "svxcss1.hxx"
      26             : 
      27             : class SwDoc;
      28             : class SwCharFormat;
      29             : class SwTextFormatColl;
      30             : class SvxBrushItem;
      31             : class SwFormatDrop;
      32             : class SwPageDesc;
      33             : 
      34             : // Dieser Header seiht zwar harmlos aus, included aber eben doch
      35             : // ganz unauffaellig das ein oder andere! Andererseits wird diese
      36             : // Klasse recht selten benoetigt. Deshalb ein eigener Header.
      37             : 
      38             : class SwCSS1Parser : public SvxCSS1Parser
      39             : {
      40             :     SwDoc *pDoc;
      41             : 
      42             :     sal_uLong aFontHeights[7];
      43             : 
      44             :     sal_uInt16 nDropCapCnt;
      45             : 
      46             :     bool bIsNewDoc : 1;
      47             : 
      48             :     bool bBodyBGColorSet : 1;
      49             :     bool bBodyBackgroundSet : 1;
      50             :     bool bBodyTextSet : 1;
      51             :     bool bBodyLinkSet : 1;
      52             :     bool bBodyVLinkSet : 1;
      53             : 
      54             :     bool bSetFirstPageDesc : 1;
      55             :     bool bSetRightPageDesc : 1;
      56             : 
      57             :     bool bTableHeaderTextCollSet : 1;
      58             :     bool bTableTextCollSet : 1;
      59             : 
      60             :     bool bLinkCharFormatsSet : 1;
      61             : 
      62             :     // die Vorlagen fuer DL anlegen
      63             :     SwTextFormatColl* GetDefListTextFormatColl( sal_uInt16 nCollId, sal_uInt16 nDeep );
      64             : 
      65             :     const SwPageDesc* GetPageDesc( sal_uInt16 nPoolId, bool bCreate );
      66             : 
      67             :     void SetTableTextColl( bool bHeader );
      68             :     void SetLinkCharFormats();
      69             : 
      70             : protected:
      71             :     virtual bool StyleParsed( const CSS1Selector *pSelector,
      72             :                               SfxItemSet& rItemSet,
      73             :                               SvxCSS1PropertyInfo& rPropInfo ) SAL_OVERRIDE;
      74             : 
      75             :     using CSS1Parser::ParseStyleSheet;
      76             : 
      77             : public:
      78             :     SwCSS1Parser( SwDoc *pDoc, sal_uInt32 aFHeight[7], const OUString& rBaseURL, bool bNewDoc );
      79             :     virtual ~SwCSS1Parser();
      80             : 
      81             :     virtual bool ParseStyleSheet( const OUString& rIn ) SAL_OVERRIDE;
      82             : 
      83             :     // Die Font-Hoehe fuer eine bestimmte Font-Groesse (0-6) ermitteln
      84             :     virtual sal_uInt32 GetFontHeight( sal_uInt16 nSize ) const SAL_OVERRIDE;
      85             : 
      86             :     // Die aktuelle Font-Liste holen (auch 0 ist erlaubt)
      87             :     virtual const FontList *GetFontList() const SAL_OVERRIDE;
      88             : 
      89             :     // das Zeichen-Format zu einem Token und einer ggf leeren Klasse
      90             :     // ermitteln
      91             :     SwCharFormat* GetChrFormat( sal_uInt16 nToken, const OUString& rClass ) const;
      92             : 
      93             :     // eine TextFormatColl zu einer Pool-Id ermitteln
      94             :     SwTextFormatColl *GetTextFormatColl( sal_uInt16 nTextColl, const OUString& rClass );
      95             : 
      96             :     // This methods do the same as the one of SwDoc, but change the
      97             :     // encoding if required.
      98             :     SwTextFormatColl *GetTextCollFromPool( sal_uInt16 nPoolId ) const;
      99             :     SwCharFormat *GetCharFormatFromPool( sal_uInt16 nPoolId ) const;
     100             : 
     101             :     // Die linke oder rechte Seiten-Vorlage holen. In Dokumenten mit nur
     102             :     // einer Vorlage gibt es nur eine rechtee Seite.
     103             :     // Ansonsten ist die rechte Seite die HTML-Poolvorlage und die linke
     104             :     // eine Benutzter-Vorlage, die on-demand angelegt wird, wenn
     105             :     // bCreate gesetzt ist.
     106             :     SwPageDesc* GetMasterPageDesc();
     107             :     inline const SwPageDesc* GetFirstPageDesc( bool bCreate=false );
     108             :     inline const SwPageDesc* GetRightPageDesc( bool bCreate=false );
     109             :     inline const SwPageDesc* GetLeftPageDesc( bool bCreate=false );
     110             : 
     111             :     // Attribute an der HTML-Seitenvorlage setzen (gesetzte Attribute
     112             :     // werden aus dem Item-Set geloescht ). Wird fuer's BODY-Tag
     113             :     // aufgerufen.
     114             :     void SetPageDescAttrs( const SvxBrushItem *pBrush,
     115             :                            SfxItemSet *pItemSet=0 );
     116             : 
     117             :     void ChgPageDesc( const SwPageDesc *pPageDesc,
     118             :                       const SwPageDesc& rNewPageDesc );
     119             : 
     120             :     // Wird fuer @page aufgerufen.
     121             :     void SetPageDescAttrs( const SwPageDesc *pPageDesc, SfxItemSet& rItemSet,
     122             :                            const SvxCSS1PropertyInfo& rPropInfo );
     123             : 
     124             :     // Fuellen eines DropCap-Attributs
     125             :     void FillDropCap( SwFormatDrop& rDrop, SfxItemSet& rItemSet,
     126             :                       const OUString *pName=0 );
     127             : 
     128             :     bool SetFormatBreak( SfxItemSet& rItemSet,
     129             :                       const SvxCSS1PropertyInfo& rPropInfo );
     130             : 
     131             :     static void AddClassName( OUString& rFormatName, const OUString& rClass );
     132             : 
     133             :     static inline void AddFirstLetterExt( OUString& rFormatName );
     134             : 
     135             :     static bool MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
     136             :                                  bool bAutoWidth=false );
     137             : 
     138             :     static sal_uInt16 GetScriptFromClass( OUString& rClass,
     139             :                                       bool bSubClassOnly = true );
     140             : 
     141           3 :     bool IsBodyBGColorSet() const { return bBodyBGColorSet; }
     142           0 :     bool IsBodyBackgroundSet() const { return bBodyBackgroundSet; }
     143           5 :     bool IsBodyTextSet() const { return bBodyTextSet; }
     144           1 :     bool IsBodyLinkSet() const { return bBodyLinkSet; }
     145           0 :     bool IsBodyVLinkSet() const { return bBodyVLinkSet; }
     146             : 
     147          15 :     bool IsSetFirstPageDesc() const { return bSetFirstPageDesc; }
     148          15 :     bool IsSetRightPageDesc() const { return bSetRightPageDesc; }
     149             : 
     150           3 :     void SetBodyBGColorSet() { bBodyBGColorSet = true; }
     151           0 :     void SetBodyBackgroundSet() { bBodyBackgroundSet = true; }
     152           5 :     void SetBodyTextSet() { bBodyTextSet = true; }
     153           1 :     void SetBodyLinkSet() { bBodyLinkSet = true; }
     154           0 :     void SetBodyVLinkSet() { bBodyVLinkSet = true; }
     155             : 
     156             :     SvxBrushItem makePageDescBackground() const;
     157             : 
     158             :     inline void SetTHTagStyles();
     159             :     inline void SetTDTagStyles();
     160             :     inline void SetATagStyles();
     161             :     inline void SetDelayedStyles();
     162             : 
     163             :     virtual void SetDfltEncoding( rtl_TextEncoding eEnc ) SAL_OVERRIDE;
     164             : };
     165             : 
     166           0 : inline void SwCSS1Parser::AddFirstLetterExt( OUString& rFormatName )
     167             : {
     168           0 :     rFormatName += ".FL";   // first letter
     169           0 : }
     170             : 
     171           9 : inline const SwPageDesc* SwCSS1Parser::GetFirstPageDesc( bool bCreate )
     172             : {
     173           9 :     return GetPageDesc( RES_POOLPAGE_FIRST, bCreate );
     174             : }
     175             : 
     176           9 : inline const SwPageDesc* SwCSS1Parser::GetRightPageDesc( bool bCreate )
     177             : {
     178           9 :     return GetPageDesc( RES_POOLPAGE_RIGHT, bCreate );
     179             : }
     180             : 
     181           9 : inline const SwPageDesc* SwCSS1Parser::GetLeftPageDesc( bool bCreate )
     182             : {
     183           9 :     return GetPageDesc( RES_POOLPAGE_LEFT, bCreate );
     184             : }
     185             : 
     186          16 : inline void SwCSS1Parser::SetTHTagStyles()
     187             : {
     188          16 :     if( !bTableHeaderTextCollSet )
     189          16 :         SetTableTextColl( true );
     190          16 : }
     191             : 
     192         302 : inline void SwCSS1Parser::SetTDTagStyles()
     193             : {
     194         302 :     if( !bTableTextCollSet )
     195          16 :         SetTableTextColl( false );
     196         302 : }
     197             : 
     198          23 : inline void SwCSS1Parser::SetATagStyles()
     199             : {
     200          23 :     if( !bLinkCharFormatsSet )
     201          16 :         SetLinkCharFormats();
     202          23 : }
     203             : 
     204          16 : inline void SwCSS1Parser::SetDelayedStyles()
     205             : {
     206          16 :     SetTHTagStyles();
     207          16 :     SetTDTagStyles();
     208          16 :     SetATagStyles();
     209          16 : }
     210             : 
     211             : #endif
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11