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 SwCharFmt;
29 : class SwTxtFmtColl;
30 : class SvxBrushItem;
31 : class SwFmtDrop;
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 : sal_Bool bIsNewDoc : 1;
47 :
48 : sal_Bool bBodyBGColorSet : 1;
49 : sal_Bool bBodyBackgroundSet : 1;
50 : sal_Bool bBodyTextSet : 1;
51 : sal_Bool bBodyLinkSet : 1;
52 : sal_Bool bBodyVLinkSet : 1;
53 :
54 : sal_Bool bSetFirstPageDesc : 1;
55 : sal_Bool bSetRightPageDesc : 1;
56 :
57 : sal_Bool bTableHeaderTxtCollSet : 1;
58 : sal_Bool bTableTxtCollSet : 1;
59 :
60 : sal_Bool bLinkCharFmtsSet : 1;
61 :
62 : // die Vorlagen fuer DL anlegen
63 : SwTxtFmtColl* GetDefListTxtFmtColl( sal_uInt16 nCollId, sal_uInt16 nDeep );
64 :
65 : const SwPageDesc* GetPageDesc( sal_uInt16 nPoolId, sal_Bool bCreate );
66 :
67 : void SetTableTxtColl( sal_Bool bHeader );
68 : void SetLinkCharFmts();
69 :
70 : protected:
71 : virtual sal_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, sal_Bool bNewDoc );
79 : virtual ~SwCSS1Parser();
80 :
81 : virtual sal_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 : SwCharFmt* GetChrFmt( sal_uInt16 nToken, const OUString& rClass ) const;
92 :
93 : // eine TextFmtColl zu einer Pool-Id ermitteln
94 : SwTxtFmtColl *GetTxtFmtColl( sal_uInt16 nTxtColl, const OUString& rClass );
95 :
96 : // This methods do the same as the one of SwDoc, but change the
97 : // encoding if required.
98 : SwTxtFmtColl *GetTxtCollFromPool( sal_uInt16 nPoolId ) const;
99 : SwCharFmt *GetCharFmtFromPool( 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( sal_Bool bCreate=sal_False );
108 : inline const SwPageDesc* GetRightPageDesc( sal_Bool bCreate=sal_False );
109 : inline const SwPageDesc* GetLeftPageDesc( sal_Bool bCreate=sal_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( SwFmtDrop& rDrop, SfxItemSet& rItemSet,
126 : const OUString *pName=0 );
127 :
128 : sal_Bool SetFmtBreak( SfxItemSet& rItemSet,
129 : const SvxCSS1PropertyInfo& rPropInfo );
130 :
131 : static void AddClassName( OUString& rFmtName, const OUString& rClass );
132 :
133 : static inline void AddFirstLetterExt( OUString& rFmtName );
134 :
135 : static sal_Bool MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
136 : sal_Bool bAutoWidth=sal_False );
137 :
138 : static sal_uInt16 GetScriptFromClass( OUString& rClass,
139 : sal_Bool bSubClassOnly = sal_True );
140 :
141 0 : sal_Bool IsBodyBGColorSet() const { return bBodyBGColorSet; }
142 0 : sal_Bool IsBodyBackgroundSet() const { return bBodyBackgroundSet; }
143 1 : sal_Bool IsBodyTextSet() const { return bBodyTextSet; }
144 1 : sal_Bool IsBodyLinkSet() const { return bBodyLinkSet; }
145 0 : sal_Bool IsBodyVLinkSet() const { return bBodyVLinkSet; }
146 :
147 5 : sal_Bool IsSetFirstPageDesc() const { return bSetFirstPageDesc; }
148 5 : sal_Bool IsSetRightPageDesc() const { return bSetRightPageDesc; }
149 :
150 0 : void SetBodyBGColorSet() { bBodyBGColorSet = sal_True; }
151 0 : void SetBodyBackgroundSet() { bBodyBackgroundSet = sal_True; }
152 1 : void SetBodyTextSet() { bBodyTextSet = sal_True; }
153 1 : void SetBodyLinkSet() { bBodyLinkSet = sal_True; }
154 0 : void SetBodyVLinkSet() { bBodyVLinkSet = sal_True; }
155 :
156 : const SvxBrushItem& GetPageDescBackground() 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& rFmtName )
167 : {
168 0 : rFmtName += ".FL"; // first letter
169 0 : }
170 :
171 2 : inline const SwPageDesc* SwCSS1Parser::GetFirstPageDesc( sal_Bool bCreate )
172 : {
173 2 : return GetPageDesc( RES_POOLPAGE_FIRST, bCreate );
174 : }
175 :
176 2 : inline const SwPageDesc* SwCSS1Parser::GetRightPageDesc( sal_Bool bCreate )
177 : {
178 2 : return GetPageDesc( RES_POOLPAGE_RIGHT, bCreate );
179 : }
180 :
181 2 : inline const SwPageDesc* SwCSS1Parser::GetLeftPageDesc( sal_Bool bCreate )
182 : {
183 2 : return GetPageDesc( RES_POOLPAGE_LEFT, bCreate );
184 : }
185 :
186 6 : inline void SwCSS1Parser::SetTHTagStyles()
187 : {
188 6 : if( !bTableHeaderTxtCollSet )
189 6 : SetTableTxtColl( sal_True );
190 6 : }
191 :
192 266 : inline void SwCSS1Parser::SetTDTagStyles()
193 : {
194 266 : if( !bTableTxtCollSet )
195 6 : SetTableTxtColl( sal_False );
196 266 : }
197 :
198 7 : inline void SwCSS1Parser::SetATagStyles()
199 : {
200 7 : if( !bLinkCharFmtsSet )
201 6 : SetLinkCharFmts();
202 7 : }
203 :
204 6 : inline void SwCSS1Parser::SetDelayedStyles()
205 : {
206 6 : SetTHTagStyles();
207 6 : SetTDTagStyles();
208 6 : SetATagStyles();
209 6 : }
210 :
211 : #endif
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|