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 : #ifndef INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
20 : #define INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
21 :
22 : #include <boost/ptr_container/ptr_vector.hpp>
23 : #include <boost/ptr_container/ptr_set.hpp>
24 : #include <vector>
25 :
26 : #include <com/sun/star/container/XIndexContainer.hpp>
27 : #include <com/sun/star/form/XForm.hpp>
28 : #include <vcl/field.hxx>
29 : #include <i18nlangtag/lang.h>
30 : #include <tools/stream.hxx>
31 : #include <o3tl/sorted_vector.hxx>
32 :
33 : #include "shellio.hxx"
34 : #include "wrt_fn.hxx"
35 :
36 : // einige Forward Deklarationen
37 : class Color;
38 : class SwFrmFmt;
39 : class SwFlyFrmFmt;
40 : class SwDrawFrmFmt;
41 : class SwFmtINetFmt;
42 : class SwFmtVertOrient;
43 : class SwFmtFtn;
44 : class SwStartNode;
45 : class SwTableNode;
46 : class SwPageDesc;
47 : class SwNodeIndex;
48 : class ImageMap;
49 : class SwNumRule;
50 : class SdrObject;
51 : class SvxBrushItem;
52 : class SvxFontItem;
53 : class SwHTMLNumRuleInfo;
54 : class SwHTMLPosFlyFrms;
55 : class SwTxtFtn;
56 :
57 : typedef std::vector<SwTxtFtn*> SwHTMLTxtFtns;
58 :
59 : extern SwAttrFnTab aHTMLAttrFnTab;
60 :
61 : #define HTML_PARSPACE (MM50)
62 :
63 : // Flags fuer die Ausgabe von Rahmen aller Art
64 : // BORDER geht nur bei OutHTML_Image
65 : // ANYSIZE gibt an, ob auch VAR_SIZE und MIN_SIZE angaben exportiert werden
66 : // ABSSIZE gibt an, ob Abstand und Umrandung ignoriert werden sollen
67 : const sal_uInt32 HTML_FRMOPT_ALIGN = 1<<0;
68 : const sal_uInt32 HTML_FRMOPT_S_ALIGN = 1<<1;
69 :
70 : const sal_uInt32 HTML_FRMOPT_WIDTH = 1<<2;
71 : const sal_uInt32 HTML_FRMOPT_HEIGHT = 1<<3;
72 : const sal_uInt32 HTML_FRMOPT_SIZE = HTML_FRMOPT_WIDTH|HTML_FRMOPT_HEIGHT;
73 : const sal_uInt32 HTML_FRMOPT_S_WIDTH = 1<<4;
74 : const sal_uInt32 HTML_FRMOPT_S_HEIGHT = 1<<5;
75 : const sal_uInt32 HTML_FRMOPT_S_SIZE = HTML_FRMOPT_S_WIDTH|HTML_FRMOPT_S_HEIGHT;
76 : const sal_uInt32 HTML_FRMOPT_ANYSIZE = 1<<6;
77 : const sal_uInt32 HTML_FRMOPT_ABSSIZE = 1<<7;
78 : const sal_uInt32 HTML_FRMOPT_MARGINSIZE = 1<<8;
79 :
80 : const sal_uInt32 HTML_FRMOPT_SPACE = 1<<9;
81 : const sal_uInt32 HTML_FRMOPT_S_SPACE = 1<<10;
82 :
83 : const sal_uInt32 HTML_FRMOPT_BORDER = 1<<11;
84 : const sal_uInt32 HTML_FRMOPT_S_BORDER = 1<<12;
85 : const sal_uInt32 HTML_FRMOPT_S_NOBORDER = 1<<13;
86 :
87 : const sal_uInt32 HTML_FRMOPT_S_BACKGROUND = 1<<14;
88 :
89 : const sal_uInt32 HTML_FRMOPT_NAME = 1<<15;
90 : const sal_uInt32 HTML_FRMOPT_ALT = 1<<16;
91 : const sal_uInt32 HTML_FRMOPT_BRCLEAR = 1<<17;
92 : const sal_uInt32 HTML_FRMOPT_S_PIXSIZE = 1<<18;
93 : const sal_uInt32 HTML_FRMOPT_ID = 1<<19;
94 : const sal_uInt32 HTML_FRMOPT_DIR = 1<<20;
95 :
96 : const sal_uInt32 HTML_FRMOPTS_GENIMG_ALL =
97 : HTML_FRMOPT_ALT |
98 : HTML_FRMOPT_SIZE |
99 : HTML_FRMOPT_ABSSIZE |
100 : HTML_FRMOPT_NAME;
101 : const sal_uInt32 HTML_FRMOPTS_GENIMG_CNTNR = HTML_FRMOPTS_GENIMG_ALL;
102 : const sal_uInt32 HTML_FRMOPTS_GENIMG =
103 : HTML_FRMOPTS_GENIMG_ALL |
104 : HTML_FRMOPT_ALIGN |
105 : HTML_FRMOPT_SPACE |
106 : HTML_FRMOPT_BRCLEAR;
107 :
108 : #define HTMLMODE_BLOCK_SPACER 0x00010000
109 : #define HTMLMODE_FLOAT_FRAME 0x00020000
110 : #define HTMLMODE_VERT_SPACER 0x00040000
111 : #define HTMLMODE_NBSP_IN_TABLES 0x00080000
112 : #define HTMLMODE_LSPACE_IN_NUMBUL 0x00100000
113 : #define HTMLMODE_NO_BR_AT_PAREND 0x00200000
114 : #define HTMLMODE_PRINT_EXT 0x00400000
115 : #define HTMLMODE_ABS_POS_FLY 0x00800000
116 : #define HTMLMODE_ABS_POS_DRAW 0x01000000
117 : #define HTMLMODE_FLY_MARGINS 0x02000000
118 : #define HTMLMODE_BORDER_NONE 0x04000000
119 : #define HTMLMODE_FONT_GENERIC 0x08000000
120 : #define HTMLMODE_FRSTLINE_IN_NUMBUL 0x10000000
121 : #define HTMLMODE_NO_CONTROL_CENTERING 0x20000000
122 :
123 : #define HTML_DLCOLL_DD 0x4000
124 : #define HTML_DLCOLL_DT 0x8000
125 :
126 : #define CSS1_FMT_ISTAG (USHRT_MAX)
127 : #define CSS1_FMT_CMPREF (USHRT_MAX-1)
128 : #define CSS1_FMT_SPECIAL (USHRT_MAX-1)
129 :
130 : // Die folgenden Flags bestimmen nur, welche Descriptoren, Tags, Optionen etc.
131 : // ausgegeben werden ...
132 : // bit 0,1,2
133 : #define CSS1_OUTMODE_SPAN_NO_ON 0x0000U
134 : #define CSS1_OUTMODE_SPAN_TAG_ON 0x0001U
135 : #define CSS1_OUTMODE_STYLE_OPT_ON 0x0002U
136 : #define CSS1_OUTMODE_RULE_ON 0x0003U
137 : #define CSS1_OUTMODE_SPAN_TAG1_ON 0x0004U
138 : #define CSS1_OUTMODE_ANY_ON 0x0007U
139 :
140 : // bit 3,4,5
141 : #define CSS1_OUTMODE_SPAN_NO_OFF 0x0000U
142 : #define CSS1_OUTMODE_SPAN_TAG_OFF ((sal_uInt16)(0x0001U << 3))
143 : #define CSS1_OUTMODE_STYLE_OPT_OFF ((sal_uInt16)(0x0002U << 3))
144 : #define CSS1_OUTMODE_RULE_OFF ((sal_uInt16)(0x0003U << 3))
145 : #define CSS1_OUTMODE_SPAN_TAG1_OFF ((sal_uInt16)(0x0004U << 3))
146 : #define CSS1_OUTMODE_ANY_OFF ((sal_uInt16)(0x0007U << 3))
147 :
148 : #define CSS1_OUTMODE_ONOFF(a) (CSS1_OUTMODE_##a##_ON|CSS1_OUTMODE_##a##_OFF)
149 : #define CSS1_OUTMODE_SPAN_TAG CSS1_OUTMODE_ONOFF(SPAN_TAG)
150 : #define CSS1_OUTMODE_STYLE_OPT CSS1_OUTMODE_ONOFF(STYLE_OPT)
151 : #define CSS1_OUTMODE_RULE CSS1_OUTMODE_ONOFF(RULE)
152 : #define CSS1_OUTMODE_SPAN_TAG1 CSS1_OUTMODE_ONOFF(TAG1)
153 :
154 : // Die folgenden Flags legen fest, was ausgegeben wird
155 : // bit 6,7,8,9
156 : #define CSS1_OUTMODE_TEMPLATE 0x0000U
157 : #define CSS1_OUTMODE_BODY ((sal_uInt16)(0x0001U << 6))
158 : #define CSS1_OUTMODE_PARA ((sal_uInt16)(0x0002U << 6))
159 : #define CSS1_OUTMODE_HINT ((sal_uInt16)(0x0003U << 6))
160 : #define CSS1_OUTMODE_FRAME ((sal_uInt16)(0x0004U << 6))
161 : #define CSS1_OUTMODE_TABLE ((sal_uInt16)(0x0005U << 6))
162 : #define CSS1_OUTMODE_TABLEBOX ((sal_uInt16)(0x0006U << 6))
163 : #define CSS1_OUTMODE_DROPCAP ((sal_uInt16)(0x0007U << 6))
164 : #define CSS1_OUTMODE_SECTION ((sal_uInt16)(0x0008U << 6))
165 : #define CSS1_OUTMODE_SOURCE ((sal_uInt16)(0x000fU << 6))
166 :
167 : // bit 10
168 : #define CSS1_OUTMODE_ENCODE ((sal_uInt16)(0x0001U << 10))
169 :
170 : // bit 11,12,13
171 : // don't care about script
172 : #define CSS1_OUTMODE_ANY_SCRIPT 0x0000U
173 : // no cjk or ctl items
174 : #define CSS1_OUTMODE_WESTERN ((sal_uInt16)(0x0001U << 11))
175 : // no western or ctl items
176 : #define CSS1_OUTMODE_CJK ((sal_uInt16)(0x0002U << 11))
177 : // no western or cjk items
178 : #define CSS1_OUTMODE_CTL ((sal_uInt16)(0x0003U << 11))
179 : // no western, cjk or ctl items
180 : #define CSS1_OUTMODE_NO_SCRIPT ((sal_uInt16)(0x0004U << 11))
181 : #define CSS1_OUTMODE_SCRIPT ((sal_uInt16)(0x0007U << 11))
182 :
183 : // der HTML-Writer
184 : struct HTMLControl
185 : {
186 : // die Form, zu der das Control gehoert
187 : css::uno::Reference<css::container::XIndexContainer> xFormComps;
188 : sal_uLong nNdIdx; // der Node, in dem es verankert ist
189 : sal_Int32 nCount; // wie viele Controls sind in dem Node
190 :
191 : HTMLControl( const css::uno::Reference<css::container::XIndexContainer>& rForm, sal_uInt32 nIdx );
192 : ~HTMLControl();
193 :
194 : // operatoren fuer das Sort-Array
195 : bool operator==( const HTMLControl& rCtrl ) const
196 : {
197 : return nNdIdx == rCtrl.nNdIdx;
198 : }
199 0 : bool operator<( const HTMLControl& rCtrl ) const
200 : {
201 0 : return nNdIdx < rCtrl.nNdIdx;
202 : }
203 : };
204 :
205 0 : class HTMLControls : public o3tl::sorted_vector<HTMLControl*, o3tl::less_ptr_to<HTMLControl> > {
206 : public:
207 : // will free any items still in the vector
208 0 : ~HTMLControls() { DeleteAndDestroyAll(); }
209 : };
210 :
211 : typedef std::vector<SwFmtINetFmt*> INetFmts;
212 :
213 : struct SwHTMLFmtInfo
214 : {
215 : const SwFmt *pFmt; // das Format selbst
216 : const SwFmt *pRefFmt; // das Vergleichs-Format
217 :
218 : OString aToken; // das auszugebende Token
219 : OUString aClass; // die auszugebende Klasse
220 :
221 : SfxItemSet *pItemSet; // der auszugebende Attribut-Set
222 :
223 : sal_Int32 nLeftMargin; // ein par default-Werte fuer
224 : sal_Int32 nRightMargin; // Absatz-Vorlagen
225 : short nFirstLineIndent;
226 :
227 : sal_uInt16 nTopMargin;
228 : sal_uInt16 nBottomMargin;
229 :
230 : bool bScriptDependent;
231 :
232 : // Konstruktor fuer einen Dummy zum Suchen
233 0 : SwHTMLFmtInfo( const SwFmt *pF ) :
234 : pFmt( pF ),
235 : pRefFmt(0),
236 : pItemSet( 0 ),
237 : nFirstLineIndent(0),
238 0 : bScriptDependent(false)
239 0 : {}
240 :
241 : // Konstruktor zum Erstellen der Format-Info
242 : SwHTMLFmtInfo( const SwFmt *pFmt, SwDoc *pDoc, SwDoc *pTemlate,
243 : sal_Bool bOutStyles, LanguageType eDfltLang=LANGUAGE_DONTKNOW,
244 : sal_uInt16 nScript=CSS1_OUTMODE_ANY_SCRIPT,
245 : sal_Bool bHardDrop=sal_False );
246 : ~SwHTMLFmtInfo();
247 :
248 : friend bool operator==( const SwHTMLFmtInfo& rInfo1,
249 : const SwHTMLFmtInfo& rInfo2 )
250 : {
251 : return (sal_IntPtr)rInfo1.pFmt == (sal_IntPtr)rInfo2.pFmt;
252 : }
253 :
254 0 : friend bool operator<( const SwHTMLFmtInfo& rInfo1,
255 : const SwHTMLFmtInfo& rInfo2 )
256 : {
257 0 : return (sal_IntPtr)rInfo1.pFmt < (sal_IntPtr)rInfo2.pFmt;
258 : }
259 :
260 : };
261 :
262 : typedef boost::ptr_set<SwHTMLFmtInfo> SwHTMLFmtInfos;
263 :
264 : class IDocumentStylePoolAccess;
265 :
266 : class SwHTMLWriter : public Writer
267 : {
268 : SwHTMLPosFlyFrms *pHTMLPosFlyFrms;
269 : SwHTMLNumRuleInfo *pNumRuleInfo;// aktuelle Numerierung
270 : SwHTMLNumRuleInfo *pNextNumRuleInfo;
271 : sal_uInt32 nHTMLMode; // Beschreibung der Export-Konfiguration
272 :
273 : FieldUnit eCSS1Unit;
274 :
275 : sal_uInt16 OutHeaderAttrs();
276 : const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
277 : void GetControls();
278 :
279 : void AddLinkTarget( const OUString& rURL );
280 : void CollectLinkTargets();
281 :
282 : protected:
283 : sal_uLong WriteStream() SAL_OVERRIDE;
284 : void SetupFilterOptions(SfxMedium& rMedium) SAL_OVERRIDE;
285 :
286 : public:
287 : std::vector<OUString> aImgMapNames; // geschriebene Image Maps
288 : std::set<OUString> aImplicitMarks;// implizite Stprungmarken
289 : std::set<OUString> aNumRuleNames;// Names of exported num rules
290 : std::set<OUString> aScriptParaStyles;// script dependent para styles
291 : std::set<OUString> aScriptTextStyles;// script dependent text styles
292 : std::vector<OUString> aOutlineMarks;
293 : std::vector<sal_uInt32> aOutlineMarkPoss;
294 : HTMLControls aHTMLControls; // die zu schreibenden ::com::sun::star::form::Forms
295 : SwHTMLFmtInfos aChrFmtInfos;
296 : SwHTMLFmtInfos aTxtCollInfos;
297 : INetFmts aINetFmts; // die "offenen" INet-Attribute
298 : SwHTMLTxtFtns *pFootEndNotes;
299 :
300 : OUString aCSS1Selector; // der Selektor eines Styles
301 : OUString aNonConvertableCharacters;
302 : OUString aBulletGrfs[MAXLEVEL]; // die Grafiken fuer Listen
303 :
304 : css::uno::Reference<css::container::XIndexContainer>* pxFormComps; // die aktuelle Form
305 :
306 : SwDoc *pTemplate; // die HTML-Vorlage
307 : Color *pDfltColor; // default Farbe
308 : SwNodeIndex *pStartNdIdx; // Index des ersten Absatz
309 : const SwPageDesc *pCurrPageDesc;// Die aktuelle Seiten-Vorlage
310 : const SwFmtFtn *pFmtFtn;
311 :
312 : sal_uInt32 aFontHeights[7]; // die Font-Hoehen 1-7
313 :
314 : sal_uInt32 nWarn; // Result-Code fuer Warnungen
315 : sal_uInt32 nLastLFPos; // letzte Position eines LF
316 :
317 : sal_uInt16 nLastParaToken; // fuers Absaetze zusammenhalten
318 : sal_Int32 nBkmkTabPos; // akt. Position in der Bookmark-Tabelle
319 : sal_uInt16 nImgMapCnt; // zum eindeutig
320 : sal_uInt16 nFormCntrlCnt;
321 : sal_uInt16 nEndNote;
322 : sal_uInt16 nFootNote;
323 : sal_Int32 nLeftMargin; // linker Einzug (z.B. aus Listen)
324 : sal_Int32 nDfltLeftMargin; // die dafaults, der nicht geschrieben
325 : sal_Int32 nDfltRightMargin; // werden muessen (aus der Vorlage)
326 : short nFirstLineIndent; // Erstzeilen-Einzug (aus Listen)
327 : short nDfltFirstLineIndent; // nicht zu schreibender default
328 : sal_uInt16 nDfltTopMargin; // die defaults, der nicht geschrieben
329 : sal_uInt16 nDfltBottomMargin; // werden muessen (aus der Vorlage)
330 : sal_uInt16 nIndentLvl; // wie weit ist eingerueckt?
331 : sal_Int32 nWhishLineLen; // wie lang darf eine Zeile werden?
332 : sal_uInt16 nDefListLvl; // welcher DL-Level existiert gerade
333 : sal_Int32 nDefListMargin; // Wie weit wird in DL eingerueckt
334 : sal_uInt16 nHeaderFooterSpace;
335 : sal_uInt16 nTxtAttrsToIgnore;
336 : sal_uInt16 nExportMode;
337 : sal_uInt16 nCSS1OutMode;
338 : sal_uInt16 nCSS1Script; // contains default script (that's the one
339 : // that is not contained in class names)
340 : sal_uInt16 nDirection; // the current direction
341 :
342 : rtl_TextEncoding eDestEnc;
343 : LanguageType eLang;
344 :
345 : // Beschreibung der Export-Konfiguration
346 : // 0
347 : sal_Bool bCfgOutStyles : 1; // Styles exportieren
348 : sal_Bool bCfgPreferStyles : 1; // Styles herkoemmlichen Tags vorziehen
349 : sal_Bool bCfgFormFeed : 1; // Form-Feeds exportieren
350 : sal_Bool bCfgStarBasic : 1; // StarBasic exportieren
351 : sal_Bool bCfgCpyLinkedGrfs : 1;
352 :
353 : // Beschreibung dessen, was exportiert wird
354 :
355 : sal_Bool bFirstLine : 1; // wird die 1. Zeile ausgegeben ?
356 : sal_Bool bTagOn : 1; // Tag an oder aus/Attr-Start oder -Ende
357 :
358 : // Die folgenden beiden Flags geben an, wir Attribute exportiert werden:
359 : // bTxtAttr bOutOpts
360 : // 0 0 Style-Sheets
361 : // 1 0 Hints: Jedes Attribut wird als eignes Tag
362 : // geschrieben und es gibt ein End-Tag
363 : // 0 1 (Absatz-)Attribute: Das Attribut wird als Option
364 : // eines bereits geschrieben Tags exportiert. Es
365 : // gibt kein End-Tag.
366 : sal_Bool bTxtAttr : 1;
367 : // 8
368 : sal_Bool bOutOpts : 1;
369 :
370 : sal_Bool bOutTable : 1; // wird der Tabelleninhalt geschrieben?
371 : sal_Bool bOutHeader : 1;
372 : sal_Bool bOutFooter : 1;
373 : sal_Bool bOutFlyFrame : 1;
374 :
375 : // Flags fuer Style-Export
376 :
377 : sal_Bool bFirstCSS1Rule : 1; // wurde schon eine Property ausgegeben
378 : sal_Bool bFirstCSS1Property : 1; // wurde schon eine Property ausgegeben
379 : sal_Bool bPoolCollTextModified : 1; // die Textkoerper-Vorlage wurde
380 : // modifiziert.
381 : // 16
382 : sal_Bool bCSS1IgnoreFirstPageDesc : 1;
383 :
384 : // was muss/kann/darf nicht ausgegeben werden?
385 :
386 : sal_Bool bNoAlign : 1; // HTML-Tag erlaubt kein ALIGN=...
387 : sal_Bool bClearLeft : 1; // <BR CLEAR=LEFT> am Absatz-Ende ausg.
388 : sal_Bool bClearRight : 1; // <BR CLEAR=RIGHT> am Absatz-Ende ausg.
389 : sal_Bool bLFPossible : 1; // ein Zeilenumbruch darf eingef. werden
390 :
391 : // sonstiges
392 :
393 : sal_Bool bPreserveForm : 1; // die aktuelle Form beibehalten
394 :
395 : sal_Bool bCfgNetscape4 : 1; // Netscape4 Hacks
396 :
397 : bool mbSkipImages : 1;
398 :
399 : // 23
400 :
401 : SwHTMLWriter( const OUString& rBaseURL );
402 : virtual ~SwHTMLWriter();
403 :
404 : void Out_SwDoc( SwPaM* ); // schreibe den makierten Bereich
405 :
406 : // gebe alle an in aktuellen Ansatz stehenden ::com::sun::star::text::Bookmarks aus
407 : void OutAnchor( const OUString& rName );
408 : void OutBookmarks();
409 : void OutImplicitMark( const OUString& rMark, const sal_Char *pMarkType );
410 : void OutHyperlinkHRefValue( const OUString& rURL );
411 :
412 : // gebe die evt. an der akt. Position stehenden FlyFrame aus.
413 : sal_Bool OutFlyFrm( sal_uLong nNdIdx, sal_Int32 nCntntIdx,
414 : sal_uInt8 nPos, HTMLOutContext *pContext = 0 );
415 : void OutFrmFmt( sal_uInt8 nType, const SwFrmFmt& rFmt,
416 : const SdrObject *pSdrObj );
417 :
418 : void OutForm( sal_Bool bTagOn=sal_True, const SwStartNode *pStNd=0 );
419 : void OutHiddenForms();
420 : void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
421 :
422 : void OutForm( sal_Bool bOn, const css::uno::Reference<css::container::XIndexContainer>& rFormComps );
423 : void OutHiddenControls( const css::uno::Reference<css::container::XIndexContainer>& rFormComps,
424 : const css::uno::Reference<css::beans::XPropertySet>& rPropSet );
425 : sal_Bool HasControls() const;
426 :
427 : void OutFootEndNoteInfo();
428 : void OutFootEndNotes();
429 : OUString GetFootEndNoteSym( const SwFmtFtn& rFmtFtn );
430 : void OutFootEndNoteSym( const SwFmtFtn& rFmtFtn, const OUString& rNum,
431 : sal_uInt16 nScript );
432 :
433 : void OutBasic();
434 :
435 : void OutAndSetDefList( sal_uInt16 nNewLvl );
436 :
437 : void OutStyleSheet( const SwPageDesc& rPageDesc, sal_Bool bUsed=sal_True );
438 :
439 : inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
440 : const sal_Char *pVal );
441 : inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
442 : const OString& rVal );
443 : inline void OutCSS1_Property( const sal_Char *pProp, const OUString& rVal );
444 : void OutCSS1_Property( const sal_Char *pProp, const sal_Char *pVal,
445 : const OUString *pSVal );
446 : void OutCSS1_UnitProperty( const sal_Char *pProp, long nVal );
447 : void OutCSS1_PixelProperty( const sal_Char *pProp, long nVal, sal_Bool bVert );
448 : void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, sal_Bool bDeep=sal_True );
449 :
450 : // BODY-Tag-Events aus der SFX-Konfigaurion
451 : void OutBasicBodyEvents();
452 :
453 : // BACKGROUND/BGCOLOR-Option
454 : void OutBackground( const SvxBrushItem *pBrushItem, sal_Bool bGraphic );
455 : void OutBackground( const SfxItemSet& rItemSet, sal_Bool bGraphic );
456 :
457 : void OutLanguage( LanguageType eLang );
458 : sal_uInt16 GetHTMLDirection( sal_uInt16 nDir ) const;
459 : sal_uInt16 GetHTMLDirection( const SfxItemSet& rItemSet ) const;
460 : void OutDirection( sal_uInt16 nDir );
461 :
462 : // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE-Optionen des aktuellen
463 : // Frame-Formats ausgeben und ggf. ein <BR CLEAR=...> vorne an
464 : // rEndTags anhaengen
465 : OString OutFrmFmtOptions( const SwFrmFmt& rFrmFmt, const OUString& rAltTxt,
466 : sal_uInt32 nFrmOpts, const OString& rEndTags = OString() );
467 : void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt );
468 : void OutCSS1_TableCellBorderHack(const SwFrmFmt& rFrmFmt);
469 : void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtCol *pCol );
470 : void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts,
471 : const SdrObject *pSdrObj=0,
472 : const SfxItemSet *pItemSet=0 );
473 : void OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt );
474 :
475 : void ChangeParaToken( sal_uInt16 nNew );
476 :
477 0 : void IncIndentLevel()
478 : {
479 0 : nIndentLvl++;
480 0 : }
481 0 : void DecIndentLevel()
482 : {
483 0 : if ( nIndentLvl ) nIndentLvl--;
484 0 : }
485 : OString GetIndentString(sal_uInt16 nIncLvl = 0);
486 :
487 0 : sal_Int32 GetLineLen()
488 : {
489 0 : return (sal_Int32)(Strm().Tell()-nLastLFPos);
490 : }
491 : void OutNewLine( sal_Bool bCheck=sal_False );
492 :
493 : // fuer HTMLSaveData
494 0 : SwPaM* GetEndPaM() { return pOrigPam; }
495 0 : void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; }
496 :
497 : sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert ) const;
498 :
499 : sal_uInt16 GuessFrmType( const SwFrmFmt& rFrmFmt,
500 : const SdrObject*& rpStrObj );
501 : sal_uInt16 GuessOLENodeFrmType( const SwNode& rNd );
502 :
503 : void CollectFlyFrms();
504 :
505 : sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
506 :
507 : // Die aktuelle Numerierungs-Information holen.
508 0 : SwHTMLNumRuleInfo& GetNumInfo() { return *pNumRuleInfo; }
509 :
510 : // Die Numerierungs-Information des naechsten Absatz holen. Sie
511 : // muss noch nicht vorhanden sein!
512 0 : SwHTMLNumRuleInfo *GetNextNumInfo() { return pNextNumRuleInfo; }
513 :
514 : // Die Numerierungs-Information des naechsten Absatz setzen.
515 0 : void SetNextNumInfo( SwHTMLNumRuleInfo *pNxt ) { pNextNumRuleInfo=pNxt; }
516 :
517 : // Die Numerierungs-Information des naeschten Absatz fuellen.
518 : void FillNextNumInfo();
519 :
520 : // Die Numerierungs-Information des naeschten Absatz loeschen.
521 : void ClearNextNumInfo();
522 :
523 : static const SdrObject* GetHTMLControl( const SwDrawFrmFmt& rFmt );
524 : static const SdrObject* GetMarqueeTextObj( const SwDrawFrmFmt& rFmt );
525 : static sal_uInt16 GetCSS1Selector( const SwFmt *pFmt, OString& rToken,
526 : OUString& rClass, sal_uInt16& rRefPoolId,
527 : OUString *pPseudo=0 );
528 :
529 : static const SwFmt *GetTemplateFmt( sal_uInt16 nPoolId, IDocumentStylePoolAccess* /*SwDoc*/ pTemplate );
530 : static const SwFmt *GetParentFmt( const SwFmt& rFmt, sal_uInt16 nDeep );
531 :
532 : static void SubtractItemSet( SfxItemSet& rItemSet,
533 : const SfxItemSet& rRefItemSet,
534 : sal_Bool bSetDefaults,
535 : sal_Bool bClearSame = sal_True,
536 : const SfxItemSet *pRefScriptItemSet=0 );
537 : static sal_Bool HasScriptDependentItems( const SfxItemSet& rItemSet,
538 : sal_Bool bCheckDropCap );
539 :
540 : static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
541 : const SdrObject *pObj,
542 : sal_Bool bSetDefaults );
543 :
544 : static sal_uInt16 GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId );
545 :
546 0 : sal_uInt32 GetHTMLMode() const
547 : {
548 0 : return nHTMLMode;
549 : }
550 0 : sal_Bool IsHTMLMode( sal_uInt32 nMode ) const
551 : {
552 0 : return (nHTMLMode & nMode) != 0;
553 : }
554 :
555 : inline bool IsCSS1Source( sal_uInt16 n ) const;
556 : inline bool IsCSS1Script( sal_uInt16 n ) const;
557 :
558 : static const sal_Char *GetNumFormat( sal_uInt16 nFmt );
559 : static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
560 : sal_Unicode cQuote, sal_Bool bGeneric );
561 : static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
562 : static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
563 :
564 0 : FieldUnit GetCSS1Unit() const { return eCSS1Unit; }
565 : };
566 :
567 0 : inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
568 : {
569 0 : return n == (nCSS1OutMode & CSS1_OUTMODE_SOURCE);
570 : }
571 :
572 0 : inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
573 : {
574 0 : sal_uInt16 nScript = (nCSS1OutMode & CSS1_OUTMODE_SCRIPT);
575 0 : return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
576 : }
577 :
578 0 : inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
579 : const sal_Char *pVal )
580 : {
581 0 : OutCSS1_Property( pProp, pVal, 0 );
582 0 : }
583 :
584 0 : inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
585 : const OString& rVal )
586 : {
587 0 : OutCSS1_Property( pProp, rVal.getStr(), 0 );
588 0 : }
589 :
590 0 : inline void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
591 : const OUString& rVal )
592 : {
593 0 : OutCSS1_Property( pProp, 0, &rVal );
594 0 : }
595 :
596 : // Struktur speichert die aktuellen Daten des Writers zwischen, um
597 : // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
598 : // Mit den beiden USHORTs im CTOR wird ein neuer PaM erzeugt und auf
599 : // die Position im Dokument gesetzt.
600 : // Im Destructor werden alle Daten wieder restauriert und der angelegte
601 : // Pam wieder geloescht.
602 :
603 : struct HTMLSaveData
604 : {
605 : SwHTMLWriter& rWrt;
606 : SwPaM* pOldPam, *pOldEnd;
607 : SwHTMLNumRuleInfo *pOldNumRuleInfo; // Owner = this
608 : SwHTMLNumRuleInfo *pOldNextNumRuleInfo; // Owner = HTML-Writer
609 : sal_uInt16 nOldDefListLvl;
610 : sal_uInt16 nOldDirection;
611 : sal_Bool bOldWriteAll : 1;
612 : sal_Bool bOldOutHeader : 1;
613 : sal_Bool bOldOutFooter : 1;
614 : sal_Bool bOldOutFlyFrame : 1;
615 : const SwFlyFrmFmt* pOldFlyFmt;
616 :
617 : HTMLSaveData( SwHTMLWriter&, sal_uLong nStt, sal_uLong nEnd,
618 : sal_Bool bSaveNum=sal_True,
619 : const SwFrmFmt *pFrmFmt=0 );
620 : ~HTMLSaveData();
621 : };
622 :
623 : // einige Funktions-Deklarationen
624 : Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFmt,
625 : sal_Bool bInCntnr );
626 : Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFmt,
627 : sal_Bool bInCntnr );
628 :
629 : Writer& OutHTML_SwTxtNode( Writer&, const SwCntntNode& );
630 : Writer& OutHTML_SwTblNode( Writer& , SwTableNode &, const SwFrmFmt *,
631 : const OUString* pCaption=0, sal_Bool bTopCaption=sal_False );
632 :
633 : Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt, const SwDrawFrmFmt& rFmt,
634 : const SdrObject& rSdrObj, sal_Bool bInCntnr );
635 : Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt, const SwDrawFrmFmt& rFmt,
636 : const SdrObject& rSdrObj );
637 :
638 : Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrmFmt& rFrmFmt,
639 : sal_Bool bHeader );
640 :
641 : Writer& OutHTML_Image( Writer&, const SwFrmFmt& rFmt,
642 : Graphic& rGraphic, const OUString& rAlternateTxt,
643 : const Size& rRealSize, sal_uInt32 nFrmOpts,
644 : const sal_Char *pMarkType = 0,
645 : const ImageMap *pGenImgMap = 0 );
646 :
647 : Writer& OutHTML_BulletImage( Writer& rWrt, const sal_Char *pTag,
648 : const SvxBrushItem* pBrush );
649 :
650 : Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt );
651 : Writer& OutHTML_SwFmtFtn( Writer& rWrt, const SfxPoolItem& rHt );
652 : Writer& OutHTML_INetFmt( Writer&, const SwFmtINetFmt& rINetFmt, sal_Bool bOn );
653 :
654 : Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
655 : Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
656 :
657 : Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
658 : Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
659 :
660 : Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
661 : Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
662 : sal_uInt8 nLevel );
663 :
664 : Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
665 : const SwHTMLNumRuleInfo& rInfo );
666 : Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
667 : const SwHTMLNumRuleInfo& rNextInfo );
668 :
669 : Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
670 :
671 : #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
672 :
673 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|