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 _SWCSS1_HXX
21 : #define _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 :
39 : class SwCSS1Parser : public SvxCSS1Parser
40 : {
41 : SwDoc *pDoc;
42 :
43 : sal_uLong aFontHeights[7];
44 :
45 : sal_uInt16 nDropCapCnt;
46 :
47 : sal_Bool bIsNewDoc : 1;
48 :
49 : sal_Bool bBodyBGColorSet : 1;
50 : sal_Bool bBodyBackgroundSet : 1;
51 : sal_Bool bBodyTextSet : 1;
52 : sal_Bool bBodyLinkSet : 1;
53 : sal_Bool bBodyVLinkSet : 1;
54 :
55 : sal_Bool bSetFirstPageDesc : 1;
56 : sal_Bool bSetRightPageDesc : 1;
57 :
58 : sal_Bool bTableHeaderTxtCollSet : 1;
59 : sal_Bool bTableTxtCollSet : 1;
60 :
61 : sal_Bool bLinkCharFmtsSet : 1;
62 :
63 : // die Vorlagen fuer DL anlegen
64 : SwTxtFmtColl* GetDefListTxtFmtColl( sal_uInt16 nCollId, sal_uInt16 nDeep );
65 :
66 : const SwPageDesc* GetPageDesc( sal_uInt16 nPoolId, sal_Bool bCreate );
67 :
68 : void SetTableTxtColl( sal_Bool bHeader );
69 : void SetLinkCharFmts();
70 :
71 : protected:
72 : virtual sal_Bool StyleParsed( const CSS1Selector *pSelector,
73 : SfxItemSet& rItemSet,
74 : SvxCSS1PropertyInfo& rPropInfo );
75 :
76 : using CSS1Parser::ParseStyleSheet;
77 :
78 : public:
79 : SwCSS1Parser( SwDoc *pDoc, sal_uInt32 aFHeight[7], const String& rBaseURL, sal_Bool bNewDoc );
80 : virtual ~SwCSS1Parser();
81 :
82 : virtual sal_Bool ParseStyleSheet( const String& rIn );
83 :
84 : // Die Font-Hoehe fuer eine bestimmte Font-Groesse (0-6) ermitteln
85 : virtual sal_uInt32 GetFontHeight( sal_uInt16 nSize ) const;
86 :
87 : // Die aktuelle Font-Liste holen (auch 0 ist erlaubt)
88 : virtual const FontList *GetFontList() const;
89 :
90 : // das Zeichen-Format zu einem Token und einer ggf leeren Klasse
91 : // ermitteln
92 : SwCharFmt* GetChrFmt( sal_uInt16 nToken, const String& rClass ) const;
93 :
94 : // eine TextFmtColl zu einer Pool-Id ermitteln
95 : SwTxtFmtColl *GetTxtFmtColl( sal_uInt16 nTxtColl, const String& rClass );
96 :
97 : // This methods do the same as the one of SwDoc, but change the
98 : // encoding if required.
99 : SwTxtFmtColl *GetTxtCollFromPool( sal_uInt16 nPoolId ) const;
100 : SwCharFmt *GetCharFmtFromPool( sal_uInt16 nPoolId ) const;
101 :
102 : // Die linke oder rechte Seiten-Vorlage holen. In Dokumenten mit nur
103 : // einer Vorlage gibt es nur eine rechtee Seite.
104 : // Ansonsten ist die rechte Seite die HTML-Poolvorlage und die linke
105 : // eine Benutzter-Vorlage, die on-demand angelegt wird, wenn
106 : // bCreate gesetzt ist.
107 : SwPageDesc* GetMasterPageDesc();
108 : inline const SwPageDesc* GetFirstPageDesc( sal_Bool bCreate=sal_False );
109 : inline const SwPageDesc* GetRightPageDesc( sal_Bool bCreate=sal_False );
110 : inline const SwPageDesc* GetLeftPageDesc( sal_Bool bCreate=sal_False );
111 :
112 : // Attribute an der HTML-Seitenvorlage setzen (gesetzte Attribute
113 : // werden aus dem Item-Set geloescht ). Wird fuer's BODY-Tag
114 : // aufgerufen.
115 : void SetPageDescAttrs( const SvxBrushItem *pBrush,
116 : SfxItemSet *pItemSet=0 );
117 :
118 : void ChgPageDesc( const SwPageDesc *pPageDesc,
119 : const SwPageDesc& rNewPageDesc );
120 :
121 : // Wird fuer @page aufgerufen.
122 : void SetPageDescAttrs( const SwPageDesc *pPageDesc, SfxItemSet& rItemSet,
123 : const SvxCSS1PropertyInfo& rPropInfo );
124 :
125 : // Fuellen eines DropCap-Attributs
126 : void FillDropCap( SwFmtDrop& rDrop, SfxItemSet& rItemSet,
127 : const String *pName=0 );
128 :
129 : sal_Bool SetFmtBreak( SfxItemSet& rItemSet,
130 : const SvxCSS1PropertyInfo& rPropInfo );
131 :
132 :
133 : static void AddClassName( String& rFmtName, const String& rClass );
134 :
135 : static inline void AddFirstLetterExt( String& rFmtName );
136 :
137 : static sal_Bool MayBePositioned( const SvxCSS1PropertyInfo& rPropInfo,
138 : sal_Bool bAutoWidth=sal_False );
139 :
140 : static sal_uInt16 GetScriptFromClass( String& rClass,
141 : sal_Bool bSubClassOnly = sal_True );
142 :
143 0 : sal_Bool IsBodyBGColorSet() const { return bBodyBGColorSet; }
144 0 : sal_Bool IsBodyBackgroundSet() const { return bBodyBackgroundSet; }
145 0 : sal_Bool IsBodyTextSet() const { return bBodyTextSet; }
146 0 : sal_Bool IsBodyLinkSet() const { return bBodyLinkSet; }
147 0 : sal_Bool IsBodyVLinkSet() const { return bBodyVLinkSet; }
148 :
149 1 : sal_Bool IsSetFirstPageDesc() const { return bSetFirstPageDesc; }
150 1 : sal_Bool IsSetRightPageDesc() const { return bSetRightPageDesc; }
151 :
152 0 : void SetBodyBGColorSet() { bBodyBGColorSet = sal_True; }
153 0 : void SetBodyBackgroundSet() { bBodyBackgroundSet = sal_True; }
154 0 : void SetBodyTextSet() { bBodyTextSet = sal_True; }
155 0 : void SetBodyLinkSet() { bBodyLinkSet = sal_True; }
156 0 : void SetBodyVLinkSet() { bBodyVLinkSet = sal_True; }
157 :
158 : const SvxBrushItem& GetPageDescBackground() 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 );
166 : };
167 :
168 :
169 0 : inline void SwCSS1Parser::AddFirstLetterExt( String& rFmtName )
170 : {
171 0 : rFmtName.AppendAscii( ".FL", 3 ); // first letter
172 0 : }
173 :
174 0 : inline const SwPageDesc* SwCSS1Parser::GetFirstPageDesc( sal_Bool bCreate )
175 : {
176 0 : return GetPageDesc( RES_POOLPAGE_FIRST, bCreate );
177 : }
178 :
179 0 : inline const SwPageDesc* SwCSS1Parser::GetRightPageDesc( sal_Bool bCreate )
180 : {
181 0 : return GetPageDesc( RES_POOLPAGE_RIGHT, bCreate );
182 : }
183 :
184 0 : inline const SwPageDesc* SwCSS1Parser::GetLeftPageDesc( sal_Bool bCreate )
185 : {
186 0 : return GetPageDesc( RES_POOLPAGE_LEFT, bCreate );
187 : }
188 :
189 1 : inline void SwCSS1Parser::SetTHTagStyles()
190 : {
191 1 : if( !bTableHeaderTxtCollSet )
192 1 : SetTableTxtColl( sal_True );
193 1 : }
194 :
195 1 : inline void SwCSS1Parser::SetTDTagStyles()
196 : {
197 1 : if( !bTableTxtCollSet )
198 1 : SetTableTxtColl( sal_False );
199 1 : }
200 :
201 :
202 1 : inline void SwCSS1Parser::SetATagStyles()
203 : {
204 1 : if( !bLinkCharFmtsSet )
205 1 : SetLinkCharFmts();
206 1 : }
207 :
208 1 : inline void SwCSS1Parser::SetDelayedStyles()
209 : {
210 1 : SetTHTagStyles();
211 1 : SetTDTagStyles();
212 1 : SetATagStyles();
213 1 : }
214 :
215 :
216 : #endif
217 :
218 :
219 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|