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 16 : bool operator<( const HTMLControl& rCtrl ) const
200 : {
201 16 : return nNdIdx < rCtrl.nNdIdx;
202 : }
203 : };
204 :
205 24 : class HTMLControls : public o3tl::sorted_vector<HTMLControl*, o3tl::less_ptr_to<HTMLControl> > {
206 : public:
207 : // will free any items still in the vector
208 24 : ~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 570 : SwHTMLFmtInfo( const SwFmt *pF ) :
234 : pFmt( pF ),
235 : pRefFmt(0),
236 : pItemSet( 0 ),
237 : nLeftMargin( 0 ),
238 : nRightMargin( 0 ),
239 : nFirstLineIndent(0),
240 : nTopMargin( 0 ),
241 : nBottomMargin( 0 ),
242 570 : bScriptDependent(false)
243 570 : {}
244 :
245 : // Konstruktor zum Erstellen der Format-Info
246 : SwHTMLFmtInfo( const SwFmt *pFmt, SwDoc *pDoc, SwDoc *pTemlate,
247 : bool bOutStyles, LanguageType eDfltLang=LANGUAGE_DONTKNOW,
248 : sal_uInt16 nScript=CSS1_OUTMODE_ANY_SCRIPT,
249 : bool bHardDrop=false );
250 : ~SwHTMLFmtInfo();
251 :
252 : friend bool operator==( const SwHTMLFmtInfo& rInfo1,
253 : const SwHTMLFmtInfo& rInfo2 )
254 : {
255 : return (sal_IntPtr)rInfo1.pFmt == (sal_IntPtr)rInfo2.pFmt;
256 : }
257 :
258 1608 : friend bool operator<( const SwHTMLFmtInfo& rInfo1,
259 : const SwHTMLFmtInfo& rInfo2 )
260 : {
261 1608 : return (sal_IntPtr)rInfo1.pFmt < (sal_IntPtr)rInfo2.pFmt;
262 : }
263 :
264 : };
265 :
266 : typedef boost::ptr_set<SwHTMLFmtInfo> SwHTMLFmtInfos;
267 :
268 : class IDocumentStylePoolAccess;
269 :
270 : class SwHTMLWriter : public Writer
271 : {
272 : SwHTMLPosFlyFrms *pHTMLPosFlyFrms;
273 : SwHTMLNumRuleInfo *pNumRuleInfo;// aktuelle Numerierung
274 : SwHTMLNumRuleInfo *pNextNumRuleInfo;
275 : sal_uInt32 nHTMLMode; // Beschreibung der Export-Konfiguration
276 :
277 : FieldUnit eCSS1Unit;
278 :
279 : sal_uInt16 OutHeaderAttrs();
280 : const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
281 : void GetControls();
282 :
283 : void AddLinkTarget( const OUString& rURL );
284 : void CollectLinkTargets();
285 :
286 : protected:
287 : sal_uLong WriteStream() SAL_OVERRIDE;
288 : void SetupFilterOptions(SfxMedium& rMedium) SAL_OVERRIDE;
289 :
290 : public:
291 : std::vector<OUString> aImgMapNames; // geschriebene Image Maps
292 : std::set<OUString> aImplicitMarks;// implizite Stprungmarken
293 : std::set<OUString> aNumRuleNames;// Names of exported num rules
294 : std::set<OUString> aScriptParaStyles;// script dependent para styles
295 : std::set<OUString> aScriptTextStyles;// script dependent text styles
296 : std::vector<OUString> aOutlineMarks;
297 : std::vector<sal_uInt32> aOutlineMarkPoss;
298 : HTMLControls aHTMLControls; // die zu schreibenden Forms
299 : SwHTMLFmtInfos aChrFmtInfos;
300 : SwHTMLFmtInfos aTxtCollInfos;
301 : INetFmts aINetFmts; // die "offenen" INet-Attribute
302 : SwHTMLTxtFtns *pFootEndNotes;
303 :
304 : OUString aCSS1Selector; // der Selektor eines Styles
305 : OUString aNonConvertableCharacters;
306 : OUString aBulletGrfs[MAXLEVEL]; // die Grafiken fuer Listen
307 :
308 : css::uno::Reference<css::container::XIndexContainer>* pxFormComps; // die aktuelle Form
309 :
310 : SwDoc *pTemplate; // die HTML-Vorlage
311 : Color *pDfltColor; // default Farbe
312 : SwNodeIndex *pStartNdIdx; // Index des ersten Absatz
313 : const SwPageDesc *pCurrPageDesc;// Die aktuelle Seiten-Vorlage
314 : const SwFmtFtn *pFmtFtn;
315 :
316 : sal_uInt32 aFontHeights[7]; // die Font-Hoehen 1-7
317 :
318 : sal_uInt32 nWarn; // Result-Code fuer Warnungen
319 : sal_uInt32 nLastLFPos; // letzte Position eines LF
320 :
321 : sal_uInt16 nLastParaToken; // fuers Absaetze zusammenhalten
322 : sal_Int32 nBkmkTabPos; // akt. Position in der Bookmark-Tabelle
323 : sal_uInt16 nImgMapCnt; // zum eindeutig
324 : sal_uInt16 nFormCntrlCnt;
325 : sal_uInt16 nEndNote;
326 : sal_uInt16 nFootNote;
327 : sal_Int32 nLeftMargin; // linker Einzug (z.B. aus Listen)
328 : sal_Int32 nDfltLeftMargin; // die dafaults, der nicht geschrieben
329 : sal_Int32 nDfltRightMargin; // werden muessen (aus der Vorlage)
330 : short nFirstLineIndent; // Erstzeilen-Einzug (aus Listen)
331 : short nDfltFirstLineIndent; // nicht zu schreibender default
332 : sal_uInt16 nDfltTopMargin; // die defaults, der nicht geschrieben
333 : sal_uInt16 nDfltBottomMargin; // werden muessen (aus der Vorlage)
334 : sal_uInt16 nIndentLvl; // wie weit ist eingerueckt?
335 : sal_Int32 nWhishLineLen; // wie lang darf eine Zeile werden?
336 : sal_uInt16 nDefListLvl; // welcher DL-Level existiert gerade
337 : sal_Int32 nDefListMargin; // Wie weit wird in DL eingerueckt
338 : sal_uInt16 nHeaderFooterSpace;
339 : sal_uInt16 nTxtAttrsToIgnore;
340 : sal_uInt16 nExportMode;
341 : sal_uInt16 nCSS1OutMode;
342 : sal_uInt16 nCSS1Script; // contains default script (that's the one
343 : // that is not contained in class names)
344 : sal_uInt16 nDirection; // the current direction
345 :
346 : rtl_TextEncoding eDestEnc;
347 : LanguageType eLang;
348 :
349 : // Beschreibung der Export-Konfiguration
350 : // 0
351 : bool bCfgOutStyles : 1; // Styles exportieren
352 : bool bCfgPreferStyles : 1; // Styles herkoemmlichen Tags vorziehen
353 : bool bCfgFormFeed : 1; // Form-Feeds exportieren
354 : bool bCfgStarBasic : 1; // StarBasic exportieren
355 : bool bCfgCpyLinkedGrfs : 1;
356 :
357 : // Beschreibung dessen, was exportiert wird
358 :
359 : bool bFirstLine : 1; // wird die 1. Zeile ausgegeben ?
360 : bool bTagOn : 1; // Tag an oder aus/Attr-Start oder -Ende
361 :
362 : // Die folgenden beiden Flags geben an, wir Attribute exportiert werden:
363 : // bTxtAttr bOutOpts
364 : // 0 0 Style-Sheets
365 : // 1 0 Hints: Jedes Attribut wird als eignes Tag
366 : // geschrieben und es gibt ein End-Tag
367 : // 0 1 (Absatz-)Attribute: Das Attribut wird als Option
368 : // eines bereits geschrieben Tags exportiert. Es
369 : // gibt kein End-Tag.
370 : bool bTxtAttr : 1;
371 : // 8
372 : bool bOutOpts : 1;
373 :
374 : bool bOutTable : 1; // wird der Tabelleninhalt geschrieben?
375 : bool bOutHeader : 1;
376 : bool bOutFooter : 1;
377 : bool bOutFlyFrame : 1;
378 :
379 : // Flags fuer Style-Export
380 :
381 : bool bFirstCSS1Rule : 1; // wurde schon eine Property ausgegeben
382 : bool bFirstCSS1Property : 1; // wurde schon eine Property ausgegeben
383 : bool bPoolCollTextModified : 1; // die Textkoerper-Vorlage wurde
384 : // modifiziert.
385 : // 16
386 : bool bCSS1IgnoreFirstPageDesc : 1;
387 :
388 : // was muss/kann/darf nicht ausgegeben werden?
389 :
390 : bool bNoAlign : 1; // HTML-Tag erlaubt kein ALIGN=...
391 : bool bClearLeft : 1; // <BR CLEAR=LEFT> am Absatz-Ende ausg.
392 : bool bClearRight : 1; // <BR CLEAR=RIGHT> am Absatz-Ende ausg.
393 : bool bLFPossible : 1; // ein Zeilenumbruch darf eingef. werden
394 :
395 : // sonstiges
396 :
397 : bool bPreserveForm : 1; // die aktuelle Form beibehalten
398 :
399 : bool bCfgNetscape4 : 1; // Netscape4 Hacks
400 :
401 : bool mbSkipImages : 1;
402 : /// If HTML header and footer should be written as well, or just the content itself.
403 : bool mbSkipHeaderFooter : 1;
404 :
405 : // 23
406 :
407 : SwHTMLWriter( const OUString& rBaseURL );
408 : virtual ~SwHTMLWriter();
409 :
410 : void Out_SwDoc( SwPaM* ); // schreibe den makierten Bereich
411 :
412 : // gebe alle an in aktuellen Ansatz stehenden Bookmarks aus
413 : void OutAnchor( const OUString& rName );
414 : void OutBookmarks();
415 : void OutPointFieldmarks( const SwPosition& rPos );
416 : void OutImplicitMark( const OUString& rMark, const sal_Char *pMarkType );
417 :
418 : OUString convertHyperlinkHRefValue(const OUString& rURL);
419 :
420 : void OutHyperlinkHRefValue( const OUString& rURL );
421 :
422 : // gebe die evt. an der akt. Position stehenden FlyFrame aus.
423 : bool OutFlyFrm( sal_uLong nNdIdx, sal_Int32 nCntntIdx,
424 : sal_uInt8 nPos, HTMLOutContext *pContext = 0 );
425 : void OutFrmFmt( sal_uInt8 nType, const SwFrmFmt& rFmt,
426 : const SdrObject *pSdrObj );
427 :
428 : void OutForm( bool bTagOn=true, const SwStartNode *pStNd=0 );
429 : void OutHiddenForms();
430 : void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
431 :
432 : void OutForm( bool bOn, const css::uno::Reference<css::container::XIndexContainer>& rFormComps );
433 : void OutHiddenControls( const css::uno::Reference<css::container::XIndexContainer>& rFormComps,
434 : const css::uno::Reference<css::beans::XPropertySet>& rPropSet );
435 : bool HasControls() const;
436 :
437 : void OutFootEndNoteInfo();
438 : void OutFootEndNotes();
439 : OUString GetFootEndNoteSym( const SwFmtFtn& rFmtFtn );
440 : void OutFootEndNoteSym( const SwFmtFtn& rFmtFtn, const OUString& rNum,
441 : sal_uInt16 nScript );
442 :
443 : void OutBasic();
444 :
445 : void OutAndSetDefList( sal_uInt16 nNewLvl );
446 :
447 : void OutStyleSheet( const SwPageDesc& rPageDesc, bool bUsed=true );
448 :
449 : inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
450 : const sal_Char *pVal );
451 : inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
452 : const OString& rVal );
453 : inline void OutCSS1_Property( const sal_Char *pProp, const OUString& rVal );
454 : void OutCSS1_Property( const sal_Char *pProp, const sal_Char *pVal,
455 : const OUString *pSVal );
456 : void OutCSS1_UnitProperty( const sal_Char *pProp, long nVal );
457 : void OutCSS1_PixelProperty( const sal_Char *pProp, long nVal, bool bVert );
458 : void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true );
459 :
460 : // BODY-Tag-Events aus der SFX-Konfigaurion
461 : void OutBasicBodyEvents();
462 :
463 : // BACKGROUND/BGCOLOR-Option
464 : void OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic );
465 : void OutBackground( const SfxItemSet& rItemSet, bool bGraphic );
466 :
467 : void OutLanguage( LanguageType eLang );
468 : sal_uInt16 GetHTMLDirection( sal_uInt16 nDir ) const;
469 : sal_uInt16 GetHTMLDirection( const SfxItemSet& rItemSet ) const;
470 : void OutDirection( sal_uInt16 nDir );
471 : OString convertDirection(sal_uInt16 nDirection);
472 :
473 : // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE-Optionen des aktuellen
474 : // Frame-Formats ausgeben und ggf. ein <BR CLEAR=...> vorne an
475 : // rEndTags anhaengen
476 : OString OutFrmFmtOptions( const SwFrmFmt& rFrmFmt, const OUString& rAltTxt,
477 : sal_uInt32 nFrmOpts, const OString& rEndTags = OString() );
478 :
479 : void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrmFmt& rFrmFmt, const OUString& rAltTxt, sal_uInt32 nFrmOpts);
480 :
481 : void OutCSS1_TableFrmFmtOptions( const SwFrmFmt& rFrmFmt );
482 : void OutCSS1_TableCellBorderHack(const SwFrmFmt& rFrmFmt);
483 : void OutCSS1_SectionFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtCol *pCol );
484 : void OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, sal_uInt32 nFrmOpts,
485 : const SdrObject *pSdrObj=0,
486 : const SfxItemSet *pItemSet=0 );
487 : void OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt );
488 :
489 : void ChangeParaToken( sal_uInt16 nNew );
490 :
491 672 : void IncIndentLevel()
492 : {
493 672 : nIndentLvl++;
494 672 : }
495 672 : void DecIndentLevel()
496 : {
497 672 : if ( nIndentLvl ) nIndentLvl--;
498 672 : }
499 : OString GetIndentString(sal_uInt16 nIncLvl = 0);
500 :
501 628 : sal_Int32 GetLineLen()
502 : {
503 628 : return (sal_Int32)(Strm().Tell()-nLastLFPos);
504 : }
505 : void OutNewLine( bool bCheck=false );
506 :
507 : // fuer HTMLSaveData
508 522 : SwPaM* GetEndPaM() { return pOrigPam; }
509 1044 : void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; }
510 :
511 : sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert ) const;
512 :
513 : sal_uInt16 GuessFrmType( const SwFrmFmt& rFrmFmt,
514 : const SdrObject*& rpStrObj );
515 : sal_uInt16 GuessOLENodeFrmType( const SwNode& rNd );
516 :
517 : void CollectFlyFrms();
518 :
519 : sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
520 :
521 : // Die aktuelle Numerierungs-Information holen.
522 2160 : SwHTMLNumRuleInfo& GetNumInfo() { return *pNumRuleInfo; }
523 :
524 : // Die Numerierungs-Information des naechsten Absatz holen. Sie
525 : // muss noch nicht vorhanden sein!
526 1094 : SwHTMLNumRuleInfo *GetNextNumInfo() { return pNextNumRuleInfo; }
527 :
528 : // Die Numerierungs-Information des naechsten Absatz setzen.
529 1044 : void SetNextNumInfo( SwHTMLNumRuleInfo *pNxt ) { pNextNumRuleInfo=pNxt; }
530 :
531 : // Die Numerierungs-Information des naeschten Absatz fuellen.
532 : void FillNextNumInfo();
533 :
534 : // Die Numerierungs-Information des naeschten Absatz loeschen.
535 : void ClearNextNumInfo();
536 :
537 : static const SdrObject* GetHTMLControl( const SwDrawFrmFmt& rFmt );
538 : static const SdrObject* GetMarqueeTextObj( const SwDrawFrmFmt& rFmt );
539 : static sal_uInt16 GetCSS1Selector( const SwFmt *pFmt, OString& rToken,
540 : OUString& rClass, sal_uInt16& rRefPoolId,
541 : OUString *pPseudo=0 );
542 :
543 : static const SwFmt *GetTemplateFmt( sal_uInt16 nPoolId, IDocumentStylePoolAccess* /*SwDoc*/ pTemplate );
544 : static const SwFmt *GetParentFmt( const SwFmt& rFmt, sal_uInt16 nDeep );
545 :
546 : static void SubtractItemSet( SfxItemSet& rItemSet,
547 : const SfxItemSet& rRefItemSet,
548 : bool bSetDefaults,
549 : bool bClearSame = true,
550 : const SfxItemSet *pRefScriptItemSet=0 );
551 : static bool HasScriptDependentItems( const SfxItemSet& rItemSet,
552 : bool bCheckDropCap );
553 :
554 : static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
555 : const SdrObject *pObj,
556 : bool bSetDefaults );
557 :
558 : static sal_uInt16 GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId );
559 :
560 570 : sal_uInt32 GetHTMLMode() const
561 : {
562 570 : return nHTMLMode;
563 : }
564 662 : bool IsHTMLMode( sal_uInt32 nMode ) const
565 : {
566 662 : return (nHTMLMode & nMode) != 0;
567 : }
568 :
569 : inline bool IsCSS1Source( sal_uInt16 n ) const;
570 : inline bool IsCSS1Script( sal_uInt16 n ) const;
571 :
572 : static const sal_Char *GetNumFormat( sal_uInt16 nFmt );
573 : static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
574 : sal_Unicode cQuote, bool bGeneric );
575 : static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
576 : static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
577 :
578 20 : FieldUnit GetCSS1Unit() const { return eCSS1Unit; }
579 : };
580 :
581 4106 : inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
582 : {
583 4106 : return n == (nCSS1OutMode & CSS1_OUTMODE_SOURCE);
584 : }
585 :
586 864 : inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
587 : {
588 864 : sal_uInt16 nScript = (nCSS1OutMode & CSS1_OUTMODE_SCRIPT);
589 864 : return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
590 : }
591 :
592 54 : inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
593 : const sal_Char *pVal )
594 : {
595 54 : OutCSS1_Property( pProp, pVal, 0 );
596 54 : }
597 :
598 2886 : inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
599 : const OString& rVal )
600 : {
601 2886 : OutCSS1_Property( pProp, rVal.getStr(), 0 );
602 2886 : }
603 :
604 84 : inline void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
605 : const OUString& rVal )
606 : {
607 84 : OutCSS1_Property( pProp, 0, &rVal );
608 84 : }
609 :
610 : // Struktur speichert die aktuellen Daten des Writers zwischen, um
611 : // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
612 : // Mit den beiden USHORTs im CTOR wird ein neuer PaM erzeugt und auf
613 : // die Position im Dokument gesetzt.
614 : // Im Destructor werden alle Daten wieder restauriert und der angelegte
615 : // Pam wieder geloescht.
616 :
617 : struct HTMLSaveData
618 : {
619 : SwHTMLWriter& rWrt;
620 : SwPaM* pOldPam, *pOldEnd;
621 : SwHTMLNumRuleInfo *pOldNumRuleInfo; // Owner = this
622 : SwHTMLNumRuleInfo *pOldNextNumRuleInfo; // Owner = HTML-Writer
623 : sal_uInt16 nOldDefListLvl;
624 : sal_uInt16 nOldDirection;
625 : bool bOldWriteAll : 1;
626 : bool bOldOutHeader : 1;
627 : bool bOldOutFooter : 1;
628 : bool bOldOutFlyFrame : 1;
629 : const SwFlyFrmFmt* pOldFlyFmt;
630 :
631 : HTMLSaveData( SwHTMLWriter&, sal_uLong nStt, sal_uLong nEnd,
632 : bool bSaveNum=true,
633 : const SwFrmFmt *pFrmFmt=0 );
634 : ~HTMLSaveData();
635 : };
636 :
637 : // einige Funktions-Deklarationen
638 : Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFmt,
639 : bool bInCntnr );
640 : Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFmt,
641 : bool bInCntnr );
642 :
643 : Writer& OutHTML_SwTxtNode( Writer&, const SwCntntNode& );
644 : Writer& OutHTML_SwTblNode( Writer& , SwTableNode &, const SwFrmFmt *,
645 : const OUString* pCaption=0, bool bTopCaption=false );
646 :
647 : Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt, const SwDrawFrmFmt& rFmt,
648 : const SdrObject& rSdrObj, bool bInCntnr );
649 : Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt, const SwDrawFrmFmt& rFmt,
650 : const SdrObject& rSdrObj );
651 :
652 : Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrmFmt& rFrmFmt,
653 : bool bHeader );
654 :
655 : Writer& OutHTML_Image( Writer&, const SwFrmFmt& rFmt,
656 : Graphic& rGraphic, const OUString& rAlternateTxt,
657 : const Size& rRealSize, sal_uInt32 nFrmOpts,
658 : const sal_Char *pMarkType = 0,
659 : const ImageMap *pGenImgMap = 0 );
660 :
661 : Writer& OutHTML_BulletImage( Writer& rWrt, const sal_Char *pTag,
662 : const SvxBrushItem* pBrush );
663 :
664 : Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt );
665 : Writer& OutHTML_SwFmtFtn( Writer& rWrt, const SfxPoolItem& rHt );
666 : Writer& OutHTML_INetFmt( Writer&, const SwFmtINetFmt& rINetFmt, bool bOn );
667 :
668 : Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
669 : Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
670 :
671 : Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
672 : Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
673 :
674 : Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
675 : Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
676 : sal_uInt8 nLevel );
677 :
678 : Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
679 : const SwHTMLNumRuleInfo& rInfo );
680 : Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
681 : const SwHTMLNumRuleInfo& rNextInfo );
682 :
683 : Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
684 :
685 : #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
686 :
687 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|