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