LibreOffice Module sw (master)  1
swcss1.hxx
Go to the documentation of this file.
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 <svtools/htmltokn.h>
24 #include <tools/solar.h>
25 
26 #include <poolfmt.hxx>
27 
28 #include "svxcss1.hxx"
29 
30 class SwDoc;
31 class SwCharFormat;
32 class SwTextFormatColl;
33 class SvxBrushItem;
34 class SwFormatDrop;
35 class SwPageDesc;
36 
37 // This header looks harmless, but includes still quite
38 // inconspicuous one or the other! On the other hand this class
39 // is rarely needed. Therefore its own header.
40 
42 {
44 
46 
47  sal_uInt16 m_nDropCapCnt;
48 
49  bool const m_bIsNewDoc : 1;
50 
53  bool m_bBodyTextSet : 1;
54  bool m_bBodyLinkSet : 1;
55  bool m_bBodyVLinkSet : 1;
56 
59 
62 
64 
65  const SwPageDesc* GetPageDesc( sal_uInt16 nPoolId, bool bCreate );
66 
67  void SetTableTextColl( bool bHeader );
68  void SetLinkCharFormats();
69 
70 protected:
71  virtual void StyleParsed( const CSS1Selector *pSelector,
72  SfxItemSet& rItemSet,
73  SvxCSS1PropertyInfo& rPropInfo ) override;
74 
76 
77 public:
78  SwCSS1Parser( SwDoc *pDoc, sal_uInt32 const aFHeight[7], const OUString& rBaseURL, bool bNewDoc );
79  virtual ~SwCSS1Parser() override;
80 
81  virtual bool ParseStyleSheet( const OUString& rIn ) override;
82 
83  // determine font height for a certain font size (0-6)
84  virtual sal_uInt32 GetFontHeight( sal_uInt16 nSize ) const override;
85 
86  // fetch current font list (also zero is allowed)
87  virtual const FontList *GetFontList() const override;
88 
89  // determine the character format of a token and a maybe empty class
90  SwCharFormat* GetChrFormat( HtmlTokenId nToken, const OUString& rClass ) const;
91 
92  // determine a TextFormatColl of a Pool-Id
93  SwTextFormatColl *GetTextFormatColl( sal_uInt16 nTextColl, const OUString& rClass );
94 
95  // This methods do the same as the one of SwDoc, but change the
96  // encoding if required.
97  SwTextFormatColl *GetTextCollFromPool( sal_uInt16 nPoolId ) const;
98  SwCharFormat *GetCharFormatFromPool( sal_uInt16 nPoolId ) const;
99 
100  // Fetch the left or right page style. In documents with only
101  // one style there is only a right page.
102  // Otherwise the right page is the HTML pool style and the left
103  // page a user style which is created on-demand if bCreate is set.
105  inline const SwPageDesc* GetFirstPageDesc( bool bCreate=false );
106  inline const SwPageDesc* GetRightPageDesc( bool bCreate=false );
107  inline const SwPageDesc* GetLeftPageDesc( bool bCreate=false );
108 
109  // Set attributes on the HTML page style (set attributes are
110  // deleted from the Item-Set). Is called for the BODY tag.
111  void SetPageDescAttrs( const SvxBrushItem *pBrush,
112  SfxItemSet *pItemSet=nullptr );
113 
114  void ChgPageDesc( const SwPageDesc *pPageDesc,
115  const SwPageDesc& rNewPageDesc );
116 
117  // Is called for @page
118  void SetPageDescAttrs( const SwPageDesc *pPageDesc, SfxItemSet& rItemSet,
119  const SvxCSS1PropertyInfo& rPropInfo );
120 
121  // Fill a DropCap attribute
122  void FillDropCap( SwFormatDrop& rDrop, SfxItemSet& rItemSet,
123  const OUString *pName=nullptr );
124 
125  bool SetFormatBreak( SfxItemSet& rItemSet,
126  const SvxCSS1PropertyInfo& rPropInfo );
127 
128  static void AddClassName( OUString& rFormatName, const OUString& rClass );
129 
130  static bool MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
131  bool bAutoWidth=false );
132 
133  static Css1ScriptFlags GetScriptFromClass( OUString& rClass,
134  bool bSubClassOnly = true );
135 
136  bool IsBodyBGColorSet() const { return m_bBodyBGColorSet; }
137  bool IsBodyBackgroundSet() const { return m_bBodyBackgroundSet; }
138  bool IsBodyTextSet() const { return m_bBodyTextSet; }
139  bool IsBodyLinkSet() const { return m_bBodyLinkSet; }
140  bool IsBodyVLinkSet() const { return m_bBodyVLinkSet; }
141 
142  bool IsSetFirstPageDesc() const { return m_bSetFirstPageDesc; }
143  bool IsSetRightPageDesc() const { return m_bSetRightPageDesc; }
144 
147  void SetBodyTextSet() { m_bBodyTextSet = true; }
148  void SetBodyLinkSet() { m_bBodyLinkSet = true; }
149  void SetBodyVLinkSet() { m_bBodyVLinkSet = true; }
150 
151  std::shared_ptr<SvxBrushItem> makePageDescBackground() const;
152 
153  inline void SetTHTagStyles();
154  inline void SetTDTagStyles();
155  inline void SetATagStyles();
156  inline void SetDelayedStyles();
157 
158  virtual void SetDfltEncoding( rtl_TextEncoding eEnc ) override;
159 };
160 
161 inline const SwPageDesc* SwCSS1Parser::GetFirstPageDesc( bool bCreate )
162 {
163  return GetPageDesc( RES_POOLPAGE_FIRST, bCreate );
164 }
165 
166 inline const SwPageDesc* SwCSS1Parser::GetRightPageDesc( bool bCreate )
167 {
168  return GetPageDesc( RES_POOLPAGE_RIGHT, bCreate );
169 }
170 
171 inline const SwPageDesc* SwCSS1Parser::GetLeftPageDesc( bool bCreate )
172 {
173  return GetPageDesc( RES_POOLPAGE_LEFT, bCreate );
174 }
175 
177 {
179  SetTableTextColl( true );
180 }
181 
183 {
184  if( !m_bTableTextCollSet )
185  SetTableTextColl( false );
186 }
187 
189 {
190  if( !m_bLinkCharFormatsSet )
192 }
193 
195 {
196  SetTHTagStyles();
197  SetTDTagStyles();
198  SetATagStyles();
199 }
200 
201 #endif
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwPageDesc * GetFirstPageDesc(bool bCreate=false)
Definition: swcss1.hxx:161
Css1ScriptFlags
Definition: svxcss1.hxx:76
sal_uInt16 m_nDropCapCnt
Definition: swcss1.hxx:47
static Css1ScriptFlags GetScriptFromClass(OUString &rClass, bool bSubClassOnly=true)
Definition: htmlcss1.cxx:555
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwTextFormatColl * GetTextFormatColl(sal_uInt16 nTextColl, const OUString &rClass)
Definition: htmlcss1.cxx:1242
SwPageDesc * GetMasterPageDesc()
Definition: htmlcss1.cxx:1323
virtual ~SwCSS1Parser() override
Definition: htmlcss1.cxx:119
bool m_bSetRightPageDesc
Definition: swcss1.hxx:58
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1207
void SetDelayedStyles()
Definition: swcss1.hxx:194
void SetTDTagStyles()
Definition: swcss1.hxx:182
bool m_bBodyBGColorSet
Definition: swcss1.hxx:51
sal_uIntPtr sal_uLong
Definition: doc.hxx:185
void SetBodyVLinkSet()
Definition: swcss1.hxx:149
bool m_bBodyVLinkSet
Definition: swcss1.hxx:55
virtual sal_uInt32 GetFontHeight(sal_uInt16 nSize) const override
Definition: htmlcss1.cxx:1107
bool m_bTableTextCollSet
Definition: swcss1.hxx:61
bool m_bBodyLinkSet
Definition: swcss1.hxx:54
void SetBodyBackgroundSet()
Definition: swcss1.hxx:146
sal_uLong m_aFontHeights[7]
Definition: swcss1.hxx:45
void SetATagStyles()
Definition: swcss1.hxx:188
virtual void SetDfltEncoding(rtl_TextEncoding eEnc) override
Definition: htmlcss1.cxx:2291
void FillDropCap(SwFormatDrop &rDrop, SfxItemSet &rItemSet, const OUString *pName=nullptr)
Definition: htmlcss1.cxx:1453
bool IsBodyBGColorSet() const
Definition: swcss1.hxx:136
void ParseStyleSheet()
Definition: parcss1.cxx:672
void SetTHTagStyles()
Definition: swcss1.hxx:176
bool m_bBodyBackgroundSet
Definition: swcss1.hxx:52
bool m_bLinkCharFormatsSet
Definition: swcss1.hxx:63
void SetLinkCharFormats()
Definition: htmlcss1.cxx:216
First page.
Definition: poolfmt.hxx:172
const SwPageDesc * GetLeftPageDesc(bool bCreate=false)
Definition: swcss1.hxx:171
static void AddClassName(OUString &rFormatName, const OUString &rClass)
Definition: htmlcss1.cxx:1446
bool IsSetFirstPageDesc() const
Definition: swcss1.hxx:142
bool IsSetRightPageDesc() const
Definition: swcss1.hxx:143
const SwPageDesc * GetRightPageDesc(bool bCreate=false)
Definition: swcss1.hxx:166
void SetBodyTextSet()
Definition: swcss1.hxx:147
SwCharFormat * GetChrFormat(HtmlTokenId nToken, const OUString &rClass) const
Definition: htmlcss1.cxx:1127
void SetPageDescAttrs(const SvxBrushItem *pBrush, SfxItemSet *pItemSet=nullptr)
Definition: htmlcss1.cxx:377
sal_uInt16 sal_Char * pName
Left page.
Definition: poolfmt.hxx:173
SwCharFormat * GetCharFormatFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1224
virtual const FontList * GetFontList() const override
Definition: htmlcss1.cxx:1112
bool IsBodyVLinkSet() const
Definition: swcss1.hxx:140
HtmlTokenId
bool IsBodyLinkSet() const
Definition: swcss1.hxx:139
SwCSS1Parser(SwDoc *pDoc, sal_uInt32 const aFHeight[7], const OUString &rBaseURL, bool bNewDoc)
Definition: htmlcss1.cxx:93
bool m_bBodyTextSet
Definition: swcss1.hxx:53
bool const m_bIsNewDoc
Definition: swcss1.hxx:49
void ChgPageDesc(const SwPageDesc *pPageDesc, const SwPageDesc &rNewPageDesc)
Definition: htmlcss1.cxx:83
Right page.
Definition: poolfmt.hxx:174
SwDoc * m_pDoc
Definition: swcss1.hxx:43
bool m_bTableHeaderTextCollSet
Definition: swcss1.hxx:60
bool m_bSetFirstPageDesc
Definition: swcss1.hxx:57
const SwPageDesc * GetPageDesc(sal_uInt16 nPoolId, bool bCreate)
Definition: htmlcss1.cxx:1339
void SetTableTextColl(bool bHeader)
Definition: htmlcss1.cxx:332
SfxItemSet * pItemSet
Definition: svxcss1.hxx:198
std::shared_ptr< SvxBrushItem > makePageDescBackground() const
Definition: htmlcss1.cxx:549
bool SetFormatBreak(SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rPropInfo)
Definition: htmlcss1.cxx:124
bool IsBodyBackgroundSet() const
Definition: swcss1.hxx:137
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
A simple selector.
Definition: parcss1.hxx:91
void SetBodyBGColorSet()
Definition: swcss1.hxx:145
void SetBodyLinkSet()
Definition: swcss1.hxx:148
bool IsBodyTextSet() const
Definition: swcss1.hxx:138
virtual void StyleParsed(const CSS1Selector *pSelector, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo) override
Definition: htmlcss1.cxx:686
static bool MayBePositioned(const SvxCSS1PropertyInfo &rPropInfo, bool bAutoWidth=false)
Definition: htmlcss1.cxx:1420