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