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