Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <stdlib.h>
30 : : #include <hintids.hxx>
31 : : #include <comphelper/string.hxx>
32 : : #include <svl/urihelper.hxx>
33 : : #include <rtl/tencinfo.h>
34 : : #include <vcl/wrkwin.hxx>
35 : : #include <sfx2/linkmgr.hxx>
36 : :
37 : : #include <svtools/htmlcfg.hxx>
38 : : #include <vcl/svapp.hxx>
39 : : #include <i18npool/mslangid.hxx>
40 : : #include <sfx2/frmhtmlw.hxx>
41 : : #include <svx/xoutbmp.hxx>
42 : : #include <svx/htmlmode.hxx>
43 : : #include <editeng/lrspitem.hxx>
44 : : #include <editeng/colritem.hxx>
45 : : #include <editeng/brshitem.hxx>
46 : : #include <editeng/fontitem.hxx>
47 : : #include <editeng/scripttypeitem.hxx>
48 : : #include <editeng/langitem.hxx>
49 : : #include <svl/stritem.hxx>
50 : : #include <editeng/frmdiritem.hxx>
51 : :
52 : : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
53 : : #include <com/sun/star/document/XDocumentProperties.hpp>
54 : : #include <com/sun/star/form/XFormsSupplier.hpp>
55 : : #include <com/sun/star/form/XForm.hpp>
56 : : #include <com/sun/star/form/XImageProducerSupplier.hpp>
57 : : #include <com/sun/star/form/XFormController.hpp>
58 : : #include <com/sun/star/container/XContainer.hpp>
59 : : #include <com/sun/star/container/XIndexContainer.hpp>
60 : : #include <com/sun/star/container/XSet.hpp>
61 : : #include <fmthdft.hxx>
62 : : #include <fmtfld.hxx>
63 : : #include <fmtpdsc.hxx>
64 : : #include <txatbase.hxx>
65 : : #include <frmatr.hxx>
66 : : #include <charfmt.hxx>
67 : : #include <docary.hxx>
68 : : #include <pam.hxx>
69 : : #include <doc.hxx>
70 : : #include <ndtxt.hxx>
71 : : #include <mdiexp.hxx> // ...Percent()
72 : : #include <fltini.hxx>
73 : : #include <viewopt.hxx>
74 : : #include <IMark.hxx> // fuer SwBookmark ...
75 : : #include <poolfmt.hxx>
76 : : #include <pagedesc.hxx>
77 : : #include <section.hxx>
78 : : #include <swtable.hxx>
79 : : #include <fldbas.hxx>
80 : : #include <fmtclds.hxx>
81 : : #include <docsh.hxx>
82 : : #include <wrthtml.hxx>
83 : : #include <htmlnum.hxx>
84 : : #include <htmlfly.hxx>
85 : : #include <swmodule.hxx>
86 : : #include <statstr.hrc> // ResId fuer Statusleiste
87 : : #include <swerror.h>
88 : : #include <rtl/strbuf.hxx>
89 : :
90 : : #define MAX_INDENT_LEVEL 20
91 : :
92 : : #if defined(UNX)
93 : : const sal_Char SwHTMLWriter::sNewLine = '\012';
94 : : #else
95 : : const sal_Char SwHTMLWriter::sNewLine[] = "\015\012";
96 : : #endif
97 : :
98 : : static sal_Char sIndentTabs[MAX_INDENT_LEVEL+2] =
99 : : "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
100 : :
101 [ + - ][ + - ]: 22 : SwHTMLWriter::SwHTMLWriter( const String& rBaseURL )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + # #
# # ]
102 : : {
103 [ + - ]: 2 : SetBaseURL( rBaseURL );
104 : 2 : bFirstLine = sal_True;
105 : 2 : nBkmkTabPos = -1;
106 : 2 : pDfltColor = 0;
107 : 2 : nImgMapCnt = 1;
108 : 2 : pStartNdIdx = 0;
109 : 2 : pTemplate = 0;
110 [ + - ]: 2 : pNumRuleInfo = new SwHTMLNumRuleInfo;
111 : 2 : pNextNumRuleInfo = 0;
112 : 2 : pFootEndNotes = 0;
113 : 2 : pFmtFtn = 0;
114 : 2 : eDestEnc = RTL_TEXTENCODING_MS_1252;
115 : 2 : nDirection = FRMDIR_HORI_LEFT_TOP;
116 [ # # # # ]: 2 : }
117 : :
118 : :
119 [ + - ][ + - ]: 22 : SwHTMLWriter::~SwHTMLWriter()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
120 : : {
121 : 2 : delete pNumRuleInfo;
122 [ + - ][ + + ]: 26 : }
[ - + ]
123 : :
124 : 2 : sal_uLong SwHTMLWriter::WriteStream()
125 : : {
126 : : // neue Konfiguration setzen
127 [ + - ]: 2 : SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
128 : :
129 : : // die Fontgroessen 1-7
130 [ + - ]: 2 : aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
131 [ + - ]: 2 : aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
132 [ + - ]: 2 : aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
133 [ + - ]: 2 : aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
134 [ + - ]: 2 : aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
135 [ + - ]: 2 : aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
136 [ + - ]: 2 : aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
137 : :
138 : : // ueberhaupt Styles ausgeben
139 : : // (dann auch obere und untere Absatz-Abstaende)
140 [ + - ]: 2 : nExportMode = rHtmlOptions.GetExportMode();
141 [ + - ]: 2 : nHTMLMode = GetHtmlMode(0);
142 [ + - ][ + - ]: 2 : if( HTML_CFG_WRITER==nExportMode ||
143 : : HTML_CFG_NS40==nExportMode )
144 : 2 : nHTMLMode |= HTMLMODE_BLOCK_SPACER;
145 : :
146 [ + - ][ - + ]: 2 : if( HTML_CFG_WRITER==nExportMode || HTML_CFG_MSIE==nExportMode )
147 : 0 : nHTMLMode |= (HTMLMODE_FLOAT_FRAME | HTMLMODE_LSPACE_IN_NUMBUL);
148 : :
149 [ - + ]: 2 : if( HTML_CFG_MSIE==nExportMode )
150 : 0 : nHTMLMode |= HTMLMODE_NBSP_IN_TABLES;
151 : :
152 [ + - ][ - + ]: 2 : if( HTML_CFG_WRITER==nExportMode || HTML_CFG_NS40==nExportMode ||
[ # # ]
153 : : HTML_CFG_MSIE==nExportMode )
154 : 2 : nHTMLMode |= HTMLMODE_ABS_POS_FLY|HTMLMODE_ABS_POS_DRAW;
155 : :
156 [ - + ]: 2 : if( HTML_CFG_WRITER==nExportMode )
157 : 0 : nHTMLMode |= HTMLMODE_FLY_MARGINS;
158 : :
159 [ + - ]: 2 : if( HTML_CFG_NS40==nExportMode )
160 : 2 : nHTMLMode |= HTMLMODE_BORDER_NONE;
161 : :
162 : 2 : nHTMLMode |= HTMLMODE_FONT_GENERIC;
163 : :
164 [ + - ]: 2 : if( HTML_CFG_NS40==nExportMode )
165 : 2 : nHTMLMode |= HTMLMODE_NO_CONTROL_CENTERING;
166 : :
167 : : bCfgOutStyles = IsHTMLMode(HTMLMODE_SOME_STYLES |
168 : 2 : HTMLMODE_FULL_STYLES);
169 : 2 : bCfgNetscape4 = (HTML_CFG_NS40==nExportMode);
170 : :
171 [ + - ]: 2 : if( IsHTMLMode(HTMLMODE_SOME_STYLES | HTMLMODE_FULL_STYLES) )
172 : 2 : nHTMLMode |= HTMLMODE_PRINT_EXT;
173 : :
174 : 2 : const sal_Char *pHelpHack = getenv( "HelpEx" );
175 [ - + ]: 2 : if( pHelpHack )
176 : : {
177 : 0 : rtl::OString aTmp(pHelpHack);
178 [ # # ]: 0 : if (aTmp.equalsIgnoreAsciiCase("Hilfe"))
179 : 0 : nHTMLMode |= HTMLMODE_NO_BR_AT_PAREND;
180 : : }
181 : :
182 [ + - ][ + - ]: 2 : eCSS1Unit = (FieldUnit)SW_MOD()->GetMetric( pDoc->get(IDocumentSettingAccess::HTML_MODE) );
[ + - ]
183 : :
184 : 2 : sal_Bool bWriteUTF8 = bWriteClipboardDoc;
185 : : eDestEnc = bWriteUTF8 ? RTL_TEXTENCODING_UTF8
186 [ + - ][ + - ]: 2 : : rHtmlOptions.GetTextEncoding();
187 : : const sal_Char *pCharSet =
188 [ + - ]: 2 : rtl_getBestMimeCharsetFromTextEncoding( eDestEnc );
189 [ + - ]: 2 : eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
190 : :
191 : : // Nur noch fuer den MS-IE ziehen wir den Export von Styles vor.
192 : 2 : bCfgPreferStyles = HTML_CFG_MSIE==nExportMode;
193 : :
194 [ + - ]: 2 : bCfgStarBasic = rHtmlOptions.IsStarBasic();
195 : :
196 : 2 : bCfgFormFeed = !IsHTMLMode(HTMLMODE_PRINT_EXT);
197 [ + - ]: 2 : bCfgCpyLinkedGrfs = rHtmlOptions.IsSaveGraphicsLocal();
198 : :
199 : : // die HTML-Vorlage holen
200 : 2 : sal_Bool bOldHTMLMode = sal_False;
201 : 2 : sal_uInt16 nOldTxtFmtCollCnt = 0, nOldCharFmtCnt = 0;
202 : :
203 : : OSL_ENSURE( !pTemplate, "Wo kommt denn die HTML-Vorlage hier her?" );
204 [ + - ]: 2 : pTemplate = ((HTMLReader*)ReadHTML)->GetTemplateDoc();
205 [ + - ]: 2 : if( pTemplate )
206 : : {
207 [ + - ]: 2 : pTemplate->acquire();
208 [ + - ]: 2 : bOldHTMLMode = pTemplate->get(IDocumentSettingAccess::HTML_MODE);
209 [ + - ]: 2 : pTemplate->set(IDocumentSettingAccess::HTML_MODE, true);
210 : :
211 : 2 : nOldTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->size();
212 : 2 : nOldCharFmtCnt = pTemplate->GetCharFmts()->size();
213 : : }
214 : :
215 [ + - ]: 2 : if( bShowProgress )
216 [ + - ]: 2 : ::StartProgress( STR_STATSTR_W4WWRITE, 0, pDoc->GetNodes().Count(),
217 [ + - ]: 4 : pDoc->GetDocShell());
218 : :
219 : 2 : pDfltColor = 0;
220 : 2 : pFootEndNotes = 0;
221 : 2 : pFmtFtn = 0;
222 : 2 : bOutTable = bOutHeader = bOutFooter = bOutFlyFrame = sal_False;
223 : 2 : pxFormComps = 0;
224 : 2 : nFormCntrlCnt = 0;
225 : 2 : bPreserveForm = sal_False;
226 : 2 : bClearLeft = bClearRight = sal_False;
227 : 2 : bLFPossible = sal_False;
228 : :
229 : 2 : nLeftMargin = nDfltLeftMargin = nDfltRightMargin = 0;
230 : 2 : nDfltTopMargin = nDfltBottomMargin = 0;
231 : 2 : nFirstLineIndent = nDfltFirstLineIndent = 0;
232 : 2 : bPoolCollTextModified = sal_False;
233 : 2 : bFirstCSS1Property = bFirstCSS1Rule = sal_False;
234 : 2 : bCSS1IgnoreFirstPageDesc = sal_False;
235 : 2 : nIndentLvl = 0;
236 : 2 : nWhishLineLen = 70;
237 : 2 : nLastLFPos = 0;
238 : 2 : nDefListLvl = 0;
239 : 6 : nDefListMargin = ((pTemplate && !bCfgOutStyles) ? pTemplate : pDoc)
240 [ + - ][ - + ]: 2 : ->GetTxtCollFromPool( RES_POOLCOLL_HTML_DD, false )
[ + - ][ - + ]
[ + - ][ - + ]
[ + - ]
241 [ + - ]: 2 : ->GetLRSpace().GetTxtLeft();
242 : 2 : nHeaderFooterSpace = 0;
243 : 2 : nTxtAttrsToIgnore = 0;
244 : 2 : nCSS1OutMode = 0;
245 : : sal_uInt16 nScript = SvtLanguageOptions::GetScriptTypeOfLanguage(
246 [ + - ][ + - ]: 2 : static_cast< LanguageType >( GetAppLanguage() ) );
247 [ - - + ]: 2 : switch( nScript )
248 : : {
249 : : case SCRIPTTYPE_ASIAN:
250 : 0 : nCSS1Script = CSS1_OUTMODE_CJK;
251 : 0 : break;
252 : : case SCRIPTTYPE_COMPLEX:
253 : 0 : nCSS1Script = CSS1_OUTMODE_CTL;
254 : 0 : break;
255 : : default:
256 : 2 : nCSS1Script = CSS1_OUTMODE_WESTERN;
257 : 2 : break;
258 : : }
259 : : eLang = ((const SvxLanguageItem&)pDoc
260 [ + - ]: 2 : ->GetDefault(GetLangWhichIdFromScript(nCSS1Script))).GetLanguage();
261 : :
262 : 2 : nFootNote = nEndNote = 0;
263 : :
264 : 2 : nWarn = 0;
265 : 2 : GetNumInfo().Clear();
266 : 2 : pNextNumRuleInfo = 0;
267 : :
268 : 2 : rtl::OString aStartTags;
269 : :
270 : : // Tabellen und Bereiche am Doc.-Anfang beachten
271 : : {
272 [ + - ]: 2 : SwTableNode * pTNd = pCurPam->GetNode()->FindTableNode();
273 [ - + ][ # # ]: 2 : if( pTNd && bWriteAll )
274 : : {
275 : : // mit dem Tabellen-Node anfangen !!
276 [ # # ]: 0 : pCurPam->GetPoint()->nNode = *pTNd;
277 : :
278 [ # # ]: 0 : if( bWriteOnlyFirstTable )
279 [ # # ]: 0 : pCurPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
280 : : }
281 : :
282 : : // erster Node (der einen Seitenumbruch enthalten darf)
283 [ + - ][ + - ]: 2 : pStartNdIdx = new SwNodeIndex( pCurPam->GetPoint()->nNode );
284 : :
285 [ + - ]: 2 : SwSectionNode * pSNd = pCurPam->GetNode()->FindSectionNode();
286 [ - + ]: 2 : while( pSNd )
287 : : {
288 [ # # ]: 0 : if( bWriteAll )
289 : : {
290 : : // mit dem Section-Node anfangen !!
291 [ # # ]: 0 : pCurPam->GetPoint()->nNode = *pSNd;
292 : : }
293 : : else
294 : : {
295 : : OSL_ENSURE( FILE_LINK_SECTION != pSNd->GetSection().GetType(),
296 : : "Export gelinkter Bereiche am Dok-Anfang ist nicht implemntiert" );
297 : :
298 : : // nur das Tag fuer die Section merken
299 : : rtl::OString aName = HTMLOutFuncs::ConvertStringToHTML(
300 : 0 : pSNd->GetSection().GetSectionName(), eDestEnc,
301 [ # # ]: 0 : &aNonConvertableCharacters );
302 : :
303 : 0 : rtl::OStringBuffer sOut;
304 [ # # ][ # # ]: 0 : sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division)
305 [ # # ][ # # ]: 0 : .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_id)
306 [ # # ][ # # ]: 0 : .append("=\"").append(aName).append('\"').append('>')
[ # # ][ # # ]
307 [ # # ]: 0 : .append(aStartTags);
308 : 0 : aStartTags = sOut.makeStringAndClear();
309 : : }
310 : : // FindSectionNode() an einem SectionNode liefert den selben!
311 [ # # ]: 0 : pSNd = pSNd->StartOfSectionNode()->FindSectionNode();
312 : : }
313 : : }
314 : :
315 : :
316 : : // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
317 : : // das gesamte Dokument geschrieben wird
318 : 2 : pHTMLPosFlyFrms = 0;
319 [ + - ]: 2 : CollectFlyFrms();
320 : 2 : nLastParaToken = 0;
321 [ + - ]: 2 : GetControls();
322 [ + - ]: 2 : CollectLinkTargets();
323 : :
324 : 2 : sal_uInt16 nHeaderAttrs = 0;
325 [ + - ]: 2 : pCurrPageDesc = MakeHeader( nHeaderAttrs );
326 : :
327 : 2 : bLFPossible = sal_True;
328 : :
329 : : // Formulare, die nur HiddenControls enthalten ausgeben.
330 [ + - ]: 2 : OutHiddenForms();
331 : :
332 [ - + ]: 2 : if( !aStartTags.isEmpty() )
333 [ # # ][ # # ]: 0 : Strm() << aStartTags.getStr();
334 : :
335 : : const SfxPoolItem *pItem;
336 : 2 : const SfxItemSet& rPageItemSet = pCurrPageDesc->GetMaster().GetAttrSet();
337 [ + - ][ - + ]: 4 : if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
[ # # ][ # # ]
[ - + ][ + - ]
338 [ + - ]: 2 : (!pDoc->get(IDocumentSettingAccess::HTML_MODE) &&
339 [ # # ]: 0 : !pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) &&
340 [ # # ]: 0 : SFX_ITEM_SET == rPageItemSet.GetItemState( RES_HEADER, sal_True, &pItem) )
341 : : {
342 : : const SwFrmFmt *pHeaderFmt =
343 : 0 : ((const SwFmtHeader *)pItem)->GetHeaderFmt();
344 [ # # ]: 0 : if( pHeaderFmt )
345 [ # # ]: 0 : OutHTML_HeaderFooter( *this, *pHeaderFmt, sal_True );
346 : : }
347 : :
348 : 2 : nTxtAttrsToIgnore = nHeaderAttrs;
349 [ + - ]: 2 : Out_SwDoc( pOrigPam );
350 : 2 : nTxtAttrsToIgnore = 0;
351 : :
352 [ - + ][ # # ]: 2 : if( pxFormComps && pxFormComps->is() )
[ - + ]
353 [ # # ]: 0 : OutForm( sal_False, *pxFormComps );
354 : :
355 [ - + ]: 2 : if( pFootEndNotes )
356 [ # # ]: 0 : OutFootEndNotes();
357 : :
358 [ + - ][ + - ]: 4 : if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
[ - + ][ # # ]
[ # # ][ - + ]
359 [ + - ][ # # ]: 2 : (!pDoc->get(IDocumentSettingAccess::HTML_MODE) && !pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) &&
360 [ # # ]: 0 : SFX_ITEM_SET == rPageItemSet.GetItemState( RES_FOOTER, sal_True, &pItem) )
361 : : {
362 : : const SwFrmFmt *pFooterFmt =
363 : 0 : ((const SwFmtFooter *)pItem)->GetFooterFmt();
364 [ # # ]: 0 : if( pFooterFmt )
365 [ # # ]: 0 : OutHTML_HeaderFooter( *this, *pFooterFmt, sal_False );
366 : : }
367 : :
368 [ + - ]: 2 : if( bLFPossible )
369 [ + - ]: 2 : OutNewLine();
370 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_body, sal_False );
371 [ + - ]: 2 : OutNewLine();
372 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html, sal_False );
373 : :
374 : : // loesche die Tabelle mit den freifliegenden Rahmen
375 : : sal_uInt16 i;
376 : : OSL_ENSURE( !pHTMLPosFlyFrms, "Wurden nicht alle Rahmen ausgegeben" );
377 [ - + ]: 2 : if( pHTMLPosFlyFrms )
378 : : {
379 [ # # ]: 0 : pHTMLPosFlyFrms->DeleteAndDestroyAll();
380 [ # # ]: 0 : delete pHTMLPosFlyFrms;
381 : 0 : pHTMLPosFlyFrms = 0;
382 : : }
383 : :
384 [ + - ]: 2 : aHTMLControls.DeleteAndDestroyAll();
385 : :
386 [ - + ]: 2 : if( !aChrFmtInfos.empty() )
387 [ # # ]: 0 : aChrFmtInfos.clear();
388 : :
389 [ + - ]: 2 : if( !aTxtCollInfos.empty() )
390 [ + - ]: 2 : aTxtCollInfos.clear();
391 : :
392 [ - + ]: 2 : if(!aImgMapNames.empty())
393 : 0 : aImgMapNames.clear();
394 : :
395 : 2 : aImplicitMarks.clear();
396 : :
397 [ + - ]: 2 : aOutlineMarks.clear();
398 : :
399 : 2 : aOutlineMarkPoss.clear();
400 : :
401 : 2 : aNumRuleNames.clear();
402 : :
403 : 2 : aScriptParaStyles.clear();
404 : 2 : aScriptTextStyles.clear();
405 : :
406 : 2 : delete pDfltColor;
407 : 2 : pDfltColor = 0;
408 : :
409 [ + - ][ + - ]: 2 : delete pStartNdIdx;
410 : 2 : pStartNdIdx = 0;
411 : :
412 [ - + ]: 2 : delete pxFormComps;
413 : 2 : pxFormComps = 0;
414 : :
415 : : OSL_ENSURE( !pFootEndNotes,
416 : : "SwHTMLWriter::Write: Ftns nicht durch OutFootEndNotes geloescht" );
417 : :
418 : 2 : pCurrPageDesc = 0;
419 : :
420 [ + - ]: 2 : ClearNextNumInfo();
421 : :
422 [ + + ]: 22 : for( i=0; i<MAXLEVEL; i++ )
423 [ + - ]: 20 : aBulletGrfs[i].Erase();
424 : :
425 [ + - ]: 2 : aNonConvertableCharacters.Erase();
426 : :
427 [ + - ]: 2 : if( bShowProgress )
428 [ + - ]: 2 : ::EndProgress( pDoc->GetDocShell() );
429 : :
430 [ + - ]: 2 : if( pTemplate )
431 : : {
432 : : // Waehrend des Exports angelegte Zeichen- und Abastzvorlagen
433 : : // loeschen
434 : 2 : sal_uInt16 nTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->size();
435 [ + + ]: 4 : while( nTxtFmtCollCnt > nOldTxtFmtCollCnt )
436 [ + - ]: 2 : pTemplate->DelTxtFmtColl( --nTxtFmtCollCnt );
437 : : OSL_ENSURE( pTemplate->GetTxtFmtColls()->size() == nOldTxtFmtCollCnt,
438 : : "falsche Anzahl TxtFmtColls geloescht" );
439 : :
440 : 2 : sal_uInt16 nCharFmtCnt = pTemplate->GetCharFmts()->size();
441 [ + + ]: 10 : while( nCharFmtCnt > nOldCharFmtCnt )
442 [ + - ]: 8 : pTemplate->DelCharFmt( --nCharFmtCnt );
443 : : OSL_ENSURE( pTemplate->GetCharFmts()->size() == nOldCharFmtCnt,
444 : : "falsche Anzahl CharFmts geloescht" );
445 : :
446 : : // HTML-Modus wieder restaurieren
447 [ + - ]: 2 : pTemplate->set(IDocumentSettingAccess::HTML_MODE, bOldHTMLMode);
448 : :
449 [ + - ][ - + ]: 2 : if( 0 == pTemplate->release() )
450 [ # # ][ # # ]: 0 : delete pTemplate;
451 : :
452 : 2 : pTemplate = 0;
453 : : }
454 : :
455 : 2 : return nWarn;
456 : : }
457 : :
458 : 0 : const SwFmtCol *lcl_html_GetFmtCol( const SwHTMLWriter& rHTMLWrt,
459 : : const SwSection& rSection,
460 : : const SwSectionFmt& rFmt )
461 : : {
462 : 0 : const SwFmtCol *pCol = 0;
463 : :
464 : : const SfxPoolItem* pItem;
465 [ # # # # ]: 0 : if( rHTMLWrt.IsHTMLMode( HTMLMODE_FRM_COLUMNS ) &&
[ # # ][ # # ]
[ # # ]
466 : 0 : FILE_LINK_SECTION != rSection.GetType() &&
467 [ # # ]: 0 : SFX_ITEM_SET == rFmt.GetAttrSet().GetItemState(RES_COL,sal_False,&pItem) &&
468 [ # # ]: 0 : ((const SwFmtCol *)pItem)->GetNumCols() > 1 )
469 : : {
470 : 0 : pCol = (const SwFmtCol *)pItem;
471 : : }
472 : :
473 : 0 : return pCol;
474 : : }
475 : :
476 : 0 : sal_Bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
477 : : {
478 : 0 : sal_Bool bRet = sal_False;
479 : : const SwSectionNode *pSectNd =
480 : 0 : rHTMLWrt.pDoc->GetNodes()[nIndex]->GetSectionNode();
481 [ # # ]: 0 : if( pSectNd )
482 : : {
483 : 0 : const SwSection& rSection = pSectNd->GetSection();
484 : 0 : const SwSectionFmt *pFmt = rSection.GetFmt();
485 [ # # ][ # # ]: 0 : if( pFmt && lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt ) )
[ # # ]
486 : 0 : bRet = sal_True;
487 : : }
488 : :
489 : 0 : return bRet;
490 : : }
491 : :
492 : 0 : sal_Bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
493 : : {
494 : 0 : sal_Bool bRet = sal_False;
495 : 0 : const SwEndNode *pEndNd = rHTMLWrt.pDoc->GetNodes()[nIndex]->GetEndNode();
496 [ # # ]: 0 : if( pEndNd )
497 : : bRet = lcl_html_IsMultiColStart( rHTMLWrt,
498 : 0 : pEndNd->StartOfSectionIndex() );
499 : :
500 : 0 : return bRet;
501 : : }
502 : :
503 : :
504 : 0 : void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
505 : : const SwSection& rSection,
506 : : const SwSectionFmt& rFmt,
507 : : const SwFmtCol *pCol,
508 : : sal_Bool bContinued=sal_False )
509 : : {
510 : : OSL_ENSURE( pCol || !bContinued, "Continuation of DIV" );
511 : :
512 [ # # ]: 0 : if( rHTMLWrt.bLFPossible )
513 [ # # ]: 0 : rHTMLWrt.OutNewLine();
514 : :
515 [ # # ]: 0 : const sal_Char *pTag = pCol ? OOO_STRING_SVTOOLS_HTML_multicol : OOO_STRING_SVTOOLS_HTML_division;
516 : :
517 : 0 : rtl::OStringBuffer sOut;
518 [ # # ][ # # ]: 0 : sOut.append('<').append(pTag);
519 : :
520 : 0 : const String& rName = rSection.GetSectionName();
521 [ # # ][ # # ]: 0 : if( rName.Len() && !bContinued )
[ # # ]
522 : : {
523 [ # # ][ # # ]: 0 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_id).
524 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\""));
525 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr();
526 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
527 [ # # ]: 0 : sOut.append('\"');
528 : : }
529 : :
530 [ # # ]: 0 : sal_uInt16 nDir = rHTMLWrt.GetHTMLDirection( rFmt.GetAttrSet() );
531 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr();
532 [ # # ]: 0 : rHTMLWrt.OutDirection( nDir );
533 : :
534 [ # # ]: 0 : if( FILE_LINK_SECTION == rSection.GetType() )
535 : : {
536 [ # # ][ # # ]: 0 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_href).
537 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\""));
538 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr();
539 : :
540 [ # # ]: 0 : const String& aFName = rSection.GetLinkFileName();
541 [ # # ]: 0 : String aURL( aFName.GetToken(0,sfx2::cTokenSeperator) );
542 [ # # ]: 0 : String aFilter( aFName.GetToken(1,sfx2::cTokenSeperator) );
543 [ # # ]: 0 : String aSection( aFName.GetToken(2,sfx2::cTokenSeperator) );
544 : :
545 [ # # ][ # # ]: 0 : String aEncURL( URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aURL ) );
[ # # ][ # # ]
546 : 0 : sal_Unicode cDelim = 255U;
547 : : sal_Bool bURLContainsDelim =
548 [ # # ]: 0 : (STRING_NOTFOUND != aEncURL.Search( cDelim ) );
549 : :
550 [ # # ]: 0 : HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aEncURL,
551 : : rHTMLWrt.eDestEnc,
552 [ # # ]: 0 : &rHTMLWrt.aNonConvertableCharacters );
553 : 0 : const sal_Char *pDelim = "ÿ";
554 [ # # ][ # # ]: 0 : if( aFilter.Len() || aSection.Len() || bURLContainsDelim )
[ # # ][ # # ]
555 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << pDelim;
556 [ # # ]: 0 : if( aFilter.Len() )
557 [ # # ]: 0 : HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter,
558 [ # # ]: 0 : rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
559 [ # # ][ # # ]: 0 : if( aSection.Len() || bURLContainsDelim )
[ # # ]
560 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << pDelim;
561 [ # # ]: 0 : if( aSection.Len() )
562 : : {
563 [ # # ]: 0 : xub_StrLen nPos = aSection.Search( '%' );
564 [ # # ]: 0 : while( STRING_NOTFOUND != nPos )
565 : : {
566 [ # # ]: 0 : aSection.Erase( nPos, 1 );
567 [ # # ]: 0 : aSection.InsertAscii( "%25", nPos );
568 [ # # ]: 0 : nPos = aSection.Search( '%', nPos+3 );
569 : : }
570 [ # # ]: 0 : nPos = aSection.Search( cDelim );
571 [ # # ]: 0 : while( STRING_NOTFOUND != nPos )
572 : : {
573 [ # # ]: 0 : aSection.Erase( nPos, 1 );
574 [ # # ]: 0 : aSection.InsertAscii( "%FF", nPos );
575 [ # # ]: 0 : nPos = aSection.Search( cDelim, nPos+3 );
576 : : }
577 [ # # ]: 0 : HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection,
578 [ # # ]: 0 : rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
579 : : }
580 [ # # ][ # # ]: 0 : sOut.append('\"');
[ # # ][ # # ]
[ # # ]
581 : : }
582 [ # # ]: 0 : else if( pCol )
583 : : {
584 [ # # ][ # # ]: 0 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
585 [ # # ][ # # ]: 0 : append('=').append(static_cast<sal_Int32>(pCol->GetNumCols()));
[ # # ]
586 : :
587 : : // minumum gutter width
588 [ # # ]: 0 : sal_uInt16 nGutter = pCol->GetGutterWidth( sal_True );
589 [ # # ]: 0 : if( nGutter!=USHRT_MAX )
590 : : {
591 [ # # ][ # # ]: 0 : if( nGutter && Application::GetDefaultDevice() )
[ # # ][ # # ]
592 : : {
593 : : nGutter = (sal_uInt16)Application::GetDefaultDevice()
594 : : ->LogicToPixel( Size(nGutter,0),
595 [ # # ][ # # ]: 0 : MapMode(MAP_TWIP) ).Width();
[ # # ][ # # ]
596 : : }
597 [ # # ][ # # ]: 0 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_gutter).
598 [ # # ][ # # ]: 0 : append('=').append(static_cast<sal_Int32>(nGutter));
599 : : }
600 : : }
601 : :
602 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << sOut.makeStringAndClear().getStr();
603 [ # # ]: 0 : if( rHTMLWrt.IsHTMLMode( rHTMLWrt.bCfgOutStyles ) )
604 [ # # ]: 0 : rHTMLWrt.OutCSS1_SectionFmtOptions( rFmt );
605 : :
606 [ # # ][ # # ]: 0 : rHTMLWrt.Strm() << '>';
607 : :
608 : 0 : rHTMLWrt.bLFPossible = sal_True;
609 [ # # ][ # # ]: 0 : if( rName.Len() && !bContinued )
[ # # ]
610 [ # # ]: 0 : rHTMLWrt.OutImplicitMark( rName, pMarkToRegion );
611 : :
612 : 0 : rHTMLWrt.IncIndentLevel();
613 : 0 : }
614 : :
615 : 0 : void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt,
616 : : const SwFmtCol *pCol )
617 : : {
618 [ # # ]: 0 : const sal_Char *pTag = pCol ? OOO_STRING_SVTOOLS_HTML_multicol : OOO_STRING_SVTOOLS_HTML_division;
619 : :
620 : 0 : rHTMLWrt.DecIndentLevel();
621 [ # # ]: 0 : if( rHTMLWrt.bLFPossible )
622 : 0 : rHTMLWrt.OutNewLine();
623 : 0 : HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), pTag, sal_False );
624 : 0 : rHTMLWrt.bLFPossible = sal_True;
625 : 0 : }
626 : :
627 : 0 : static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
628 : : {
629 : 0 : SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
630 : :
631 : : // End <PRE> and any <DL>, because a definition list's level may
632 : : // change inside the section.
633 : 0 : rHTMLWrt.ChangeParaToken( 0 );
634 : 0 : rHTMLWrt.OutAndSetDefList( 0 );
635 : :
636 : 0 : const SwSection& rSection = rSectNd.GetSection();
637 : 0 : const SwSectionFmt *pFmt = rSection.GetFmt();
638 : : OSL_ENSURE( pFmt, "Section without a format?" );
639 : :
640 : 0 : sal_Bool bStartTag = sal_True;
641 : 0 : sal_Bool bEndTag = sal_True;
642 : 0 : const SwSectionFmt *pSurrFmt = 0;
643 : 0 : const SwSectionNode *pSurrSectNd = 0;
644 : 0 : const SwSection *pSurrSection = 0;
645 : 0 : const SwFmtCol *pSurrCol = 0;
646 : :
647 : 0 : sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
648 : 0 : sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
649 : 0 : const SwFmtCol *pCol = lcl_html_GetFmtCol( rHTMLWrt, rSection, *pFmt );
650 [ # # ]: 0 : if( pCol )
651 : : {
652 : : // If the next node is a columned section node, too, don't export
653 : : // an empty section.
654 [ # # ]: 0 : if( lcl_html_IsMultiColStart( rHTMLWrt, nSectSttIdx+1 ) )
655 : 0 : bStartTag = sal_False;
656 : :
657 : : // The same applies if the section end with another columned section.
658 [ # # ]: 0 : if( lcl_html_IsMultiColEnd( rHTMLWrt, nSectEndIdx-1 ) )
659 : 0 : bEndTag = sal_False;
660 : :
661 : : //.is there a columned section arround this one?
662 : 0 : const SwStartNode *pSttNd = rSectNd.StartOfSectionNode();
663 [ # # ]: 0 : if( pSttNd )
664 : : {
665 : 0 : pSurrSectNd = pSttNd->FindSectionNode();
666 [ # # ]: 0 : if( pSurrSectNd )
667 : : {
668 : 0 : const SwStartNode *pBoxSttNd = pSttNd->FindTableBoxStartNode();
669 [ # # ]: 0 : if( !pBoxSttNd ||
[ # # # # ]
670 : 0 : pBoxSttNd->GetIndex() < pSurrSectNd->GetIndex() )
671 : : {
672 : 0 : pSurrSection = &pSurrSectNd->GetSection();
673 : 0 : pSurrFmt = pSurrSection->GetFmt();
674 [ # # ]: 0 : if( pSurrFmt )
675 : : pSurrCol = lcl_html_GetFmtCol( rHTMLWrt, *pSurrSection,
676 : 0 : *pSurrFmt );
677 : : }
678 : : }
679 : : }
680 : : }
681 : :
682 : : // The surrounding section must be closed before the current one is
683 : : // opended, except that it start immediatly before the current one or
684 : : // another end immediately before the current one
685 [ # # ]: 0 : if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
[ # # # # ]
[ # # ]
686 : 0 : !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
687 : 0 : lcl_html_OutSectionEndTag( rHTMLWrt, pSurrCol );
688 : :
689 [ # # ]: 0 : if( bStartTag )
690 : 0 : lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFmt, pCol );
691 : :
692 : : {
693 : : HTMLSaveData aSaveData( rHTMLWrt,
694 : 0 : rHTMLWrt.pCurPam->GetPoint()->nNode.GetIndex()+1,
695 : : rSectNd.EndOfSectionIndex(),
696 [ # # ]: 0 : sal_False, pFmt );
697 [ # # ][ # # ]: 0 : rHTMLWrt.Out_SwDoc( rHTMLWrt.pCurPam );
698 : : }
699 : :
700 : 0 : rHTMLWrt.pCurPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
701 : :
702 [ # # ]: 0 : if( bEndTag )
703 : 0 : lcl_html_OutSectionEndTag( rHTMLWrt, pCol );
704 : :
705 : : // The surrounding section must be started again, except that it ends
706 : : // immeditaly behind the current one.
707 [ # # # # : 0 : if( pSurrCol &&
# # ][ # # ]
708 : 0 : pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > 1 &&
709 : 0 : !lcl_html_IsMultiColStart( rHTMLWrt, nSectEndIdx+1 ) )
710 : : lcl_html_OutSectionStartTag( rHTMLWrt, *pSurrSection, *pSurrFmt,
711 : 0 : pSurrCol, sal_True );
712 : :
713 : 0 : return rWrt;
714 : : }
715 : :
716 : 2 : void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
717 : : {
718 : 2 : sal_Bool bSaveWriteAll = bWriteAll; // sichern
719 : :
720 : : // suche die naechste text::Bookmark-Position aus der text::Bookmark-Tabelle
721 [ + - ]: 2 : nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
722 : :
723 : : // gebe alle Bereiche des Pams in das HTML-File aus.
724 [ - + ]: 2 : do {
725 : 2 : bWriteAll = bSaveWriteAll;
726 : 2 : bFirstLine = sal_True;
727 : :
728 : : // suche den ersten am Pam-auszugebenen FlyFrame
729 : : // fehlt noch:
730 : :
731 [ + + + - : 8 : while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() ||
+ - ][ + - ]
732 : 2 : (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() &&
733 : 2 : pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
734 : : {
735 : 4 : SwNode * pNd = pCurPam->GetNode();
736 : :
737 : : OSL_ENSURE( !(pNd->IsGrfNode() || pNd->IsOLENode()),
738 : : "Grf- oder OLE-Node hier unerwartet" );
739 [ + + ]: 4 : if( pNd->IsTxtNode() )
740 : : {
741 : 2 : SwTxtNode* pTxtNd = pNd->GetTxtNode();
742 : :
743 [ - + ]: 2 : if( !bFirstLine )
744 [ # # ]: 0 : pCurPam->GetPoint()->nContent.Assign( pTxtNd, 0 );
745 : :
746 : 2 : OutHTML_SwTxtNode( *this, *pTxtNd );
747 : : }
748 [ - + ]: 2 : else if( pNd->IsTableNode() )
749 : : {
750 : 0 : OutHTML_SwTblNode( *this, *pNd->GetTableNode(), 0 );
751 [ # # ]: 0 : nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
752 : : }
753 [ - + ]: 2 : else if( pNd->IsSectionNode() )
754 : : {
755 : 0 : OutHTML_Section( *this, *pNd->GetSectionNode() );
756 [ # # ]: 0 : nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
757 : : }
758 [ + - ]: 2 : else if( pNd == &pDoc->GetNodes().GetEndOfContent() )
759 : 2 : break;
760 : :
761 : 2 : pCurPam->GetPoint()->nNode++; // Bewegen
762 : 2 : sal_uInt32 nPos = pCurPam->GetPoint()->nNode.GetIndex();
763 : :
764 [ + - ]: 2 : if( bShowProgress )
765 : 2 : ::SetProgressState( nPos, pDoc->GetDocShell() ); // Wie weit ?
766 : :
767 : : /* sollen nur die Selectierten Bereiche gesichert werden, so
768 : : * duerfen nur die vollstaendigen Nodes gespeichert werde,
769 : : * d.H. der 1. und n. Node teilweise, der 2. bis n-1. Node
770 : : * vollstaendig. (vollstaendig heisst mit allen Formaten! )
771 : : */
772 : : bWriteAll = bSaveWriteAll ||
773 [ - + ][ # # ]: 2 : nPos != pCurPam->GetMark()->nNode.GetIndex();
774 : 2 : bFirstLine = sal_False;
775 : 2 : bOutFooter = sal_False; // Nach einem Node keine Fusszeile mehr
776 : : }
777 : :
778 : 2 : ChangeParaToken( 0 ); // MIB 8.7.97: Machen wir jetzt hier und nicht
779 : : // beim Aufrufer
780 : 2 : OutAndSetDefList( 0 );
781 : :
782 : 2 : } while( CopyNextPam( &pPam ) ); // bis alle PaM's bearbeitet
783 : :
784 : 2 : bWriteAll = bSaveWriteAll; // wieder auf alten Wert zurueck
785 : 2 : }
786 : :
787 : :
788 : : // schreibe die StyleTabelle, algemeine Angaben,Header/Footer/Footnotes
789 : 6 : static void OutBodyColor( const sal_Char *pTag, const SwFmt *pFmt,
790 : : SwHTMLWriter& rHWrt )
791 : : {
792 : 6 : const SwFmt *pRefFmt = 0;
793 : :
794 [ + - ]: 6 : if( rHWrt.pTemplate )
795 : 6 : pRefFmt = SwHTMLWriter::GetTemplateFmt( pFmt->GetPoolFmtId(),
796 [ + - ][ + - ]: 12 : rHWrt.pTemplate );
797 : :
798 : 6 : const SvxColorItem *pColorItem = 0;
799 : :
800 : 6 : const SfxItemSet& rItemSet = pFmt->GetAttrSet();
801 : 6 : const SfxPoolItem *pRefItem = 0, *pItem = 0;
802 : : sal_Bool bItemSet = SFX_ITEM_SET == rItemSet.GetItemState( RES_CHRATR_COLOR,
803 [ + - ]: 6 : sal_True, &pItem);
804 : : sal_Bool bRefItemSet = pRefFmt &&
805 : 6 : SFX_ITEM_SET == pRefFmt->GetAttrSet().GetItemState( RES_CHRATR_COLOR,
806 [ + - + - ]: 12 : sal_True, &pRefItem);
[ + + ]
807 [ + + ]: 6 : if( bItemSet )
808 : : {
809 : : // wenn das Item nur in der Vorlage des aktuellen Doks gesetzt
810 : : // ist oder einen anderen Wert hat, als in der HTML-Vorlage,
811 : : // wird es gesetzt
812 : 4 : const SvxColorItem *pCItem = (const SvxColorItem*)pItem;
813 : :
814 [ - + ]: 4 : if( !bRefItemSet )
815 : : {
816 : 0 : pColorItem = pCItem;
817 : : }
818 : : else
819 : : {
820 : 4 : Color aColor( pCItem->GetValue() );
821 [ - + ]: 4 : if( COL_AUTO == aColor.GetColor() )
822 : 0 : aColor.SetColor( COL_BLACK );
823 : :
824 : 4 : Color aRefColor( ((const SvxColorItem*)pRefItem)->GetValue() );
825 [ - + ]: 4 : if( COL_AUTO == aRefColor.GetColor() )
826 : 0 : aRefColor.SetColor( COL_BLACK );
827 : :
828 [ + - ][ - + ]: 4 : if( !aColor.IsRGBEqual( aRefColor ) )
829 : 4 : pColorItem = pCItem;
830 : : }
831 : : }
832 [ - + ]: 2 : else if( bRefItemSet )
833 : : {
834 : : // Das Item war in der HTML-Vorlage noch gesetzt, also geben wir
835 : : // das Default aus
836 : 0 : pColorItem = (const SvxColorItem*)&rItemSet.GetPool()
837 [ # # ]: 0 : ->GetDefaultItem( RES_CHRATR_COLOR );
838 : : }
839 : :
840 [ - + ]: 6 : if( pColorItem )
841 : : {
842 : 0 : rtl::OStringBuffer sOut;
843 [ # # ][ # # ]: 0 : sOut.append(' ').append(pTag).append('=');
[ # # ]
844 [ # # ][ # # ]: 0 : rHWrt.Strm() << sOut.makeStringAndClear().getStr();
845 : 0 : Color aColor( pColorItem->GetValue() );
846 [ # # ]: 0 : if( COL_AUTO == aColor.GetColor() )
847 : 0 : aColor.SetColor( COL_BLACK );
848 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_Color( rHWrt.Strm(), aColor, rHWrt.eDestEnc );
849 [ # # ]: 0 : if( RES_POOLCOLL_STANDARD==pFmt->GetPoolFmtId() )
850 [ # # ]: 0 : rHWrt.pDfltColor = new Color( aColor );
851 : : }
852 : 6 : }
853 : :
854 : 2 : sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
855 : : {
856 : 2 : sal_uLong nIdx = pCurPam->GetPoint()->nNode.GetIndex();
857 : 2 : sal_uLong nEndIdx = pCurPam->GetMark()->nNode.GetIndex();
858 : :
859 : 2 : SwTxtNode *pTxtNd = 0;
860 [ + - - + ]: 4 : while( nIdx<=nEndIdx &&
[ - + ]
861 : 2 : 0==(pTxtNd=pDoc->GetNodes()[nIdx]->GetTxtNode()) )
862 : 0 : nIdx++;
863 : :
864 : : OSL_ENSURE( pTxtNd, "Kein Text-Node gefunden" );
865 [ + - ][ + - ]: 2 : if( !pTxtNd || !pTxtNd->HasHints() )
[ + - ]
866 : 2 : return 0;
867 : :
868 : 0 : sal_uInt16 nAttrs = 0;
869 : 0 : sal_uInt16 nCntAttr = pTxtNd->GetSwpHints().Count();
870 : 0 : xub_StrLen nOldPos = 0;
871 [ # # ]: 0 : for( sal_uInt16 i=0; i<nCntAttr; i++ )
872 : : {
873 : 0 : const SwTxtAttr *pHt = pTxtNd->GetSwpHints()[i];
874 [ # # ]: 0 : if( !pHt->GetEnd() )
875 : : {
876 : 0 : xub_StrLen nPos = *pHt->GetStart();
877 [ # # ][ # # ]: 0 : if( nPos-nOldPos > 1 || RES_TXTATR_FIELD != pHt->Which() )
[ # # ]
878 : 0 : break;
879 : :
880 : 0 : sal_uInt16 nFldWhich = ((const SwFmtFld&)pHt->GetAttr()).GetFld()
881 : 0 : ->GetTyp()->Which();
882 [ # # ][ # # ]: 0 : if( RES_POSTITFLD!=nFldWhich &&
883 : : RES_SCRIPTFLD!=nFldWhich )
884 : 0 : break;
885 : :
886 : 0 : OutNewLine();
887 : 0 : OutHTML_SwFmtFld( *this, pHt->GetAttr() );
888 : 0 : nOldPos = nPos;
889 : 0 : nAttrs++;
890 : : }
891 : : }
892 : :
893 : 2 : return nAttrs;
894 : : }
895 : :
896 : 2 : const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
897 : : {
898 : 2 : rtl::OStringBuffer sOut;
899 [ + - ][ + - ]: 2 : sOut.append(OOO_STRING_SVTOOLS_HTML_doctype).append(' ')
900 [ + - ]: 2 : .append(OOO_STRING_SVTOOLS_HTML_doctype40);
901 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() );
902 : :
903 : : // baue den Vorspann
904 [ + - ]: 2 : OutNewLine();
905 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html );
906 : :
907 [ + - ]: 2 : OutNewLine();
908 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_head );
909 : :
910 : 2 : IncIndentLevel(); // Inhalt von <HEAD> einruecken
911 : :
912 : : // DokumentInfo
913 [ + - ]: 2 : rtl::OString sIndent = GetIndentString();
914 : : using namespace ::com::sun::star;
915 : 2 : uno::Reference<document::XDocumentProperties> xDocProps;
916 : 2 : SwDocShell *pDocShell(pDoc->GetDocShell());
917 [ + - ]: 2 : if (pDocShell)
918 : : {
919 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
920 [ + - ][ + - ]: 2 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
921 [ + - ][ + - ]: 2 : xDocProps.set(xDPS->getDocumentProperties());
[ + - ]
922 : : }
923 : :
924 : : // xDocProps may be null here (when copying)
925 [ + - ]: 2 : SfxFrameHTMLWriter::Out_DocInfo( Strm(), GetBaseURL(), xDocProps,
926 : : sIndent.getStr(), eDestEnc,
927 [ + - ]: 4 : &aNonConvertableCharacters );
928 : :
929 : : // Kommentare und Meta-Tags des ersten Absatzes
930 [ + - ]: 2 : rHeaderAttrs = OutHeaderAttrs();
931 : :
932 [ + - ]: 2 : OutFootEndNoteInfo();
933 : :
934 : 2 : const SwPageDesc *pPageDesc = 0;
935 : :
936 : : // In Nicht-HTML-Dokumenten wird die erste gesetzte Seitenvorlage
937 : : // exportiert und wenn keine gesetzt ist die Standard-Vorlage
938 : 2 : sal_uLong nNodeIdx = pCurPam->GetPoint()->nNode.GetIndex();
939 : :
940 [ + - ][ + - ]: 2 : while( nNodeIdx < pDoc->GetNodes().Count() )
941 : : {
942 [ + - ][ + - ]: 2 : SwNode *pNd = pDoc->GetNodes()[ nNodeIdx ];
943 [ + - ]: 2 : if( pNd->IsCntntNode() )
944 : : {
945 : : pPageDesc = ((const SwFmtPageDesc &)pNd->GetCntntNode()
946 [ + - ]: 2 : ->GetAttr(RES_PAGEDESC)).GetPageDesc();
947 : 2 : break;
948 : : }
949 [ # # ]: 0 : else if( pNd->IsTableNode() )
950 : : {
951 : 0 : pPageDesc = pNd->GetTableNode()->GetTable().GetFrmFmt()
952 [ # # ]: 0 : ->GetPageDesc().GetPageDesc();
953 : 0 : break;
954 : : }
955 : :
956 : 0 : nNodeIdx++;
957 : : }
958 : :
959 [ - + ]: 2 : if( !pPageDesc )
960 [ # # ]: 0 : pPageDesc = &pDoc->GetPageDesc( 0 );
961 : :
962 : : // und nun ... das Style-Sheet!!!
963 [ + - ]: 2 : if( bCfgOutStyles )
964 : : {
965 [ + - ]: 2 : OutStyleSheet( *pPageDesc );
966 : : }
967 : :
968 : : // und nun ... das BASIC und JavaScript!
969 [ + - ]: 2 : if( pDoc->GetDocShell() ) // nur mit DocShell ist Basic moeglich
970 [ + - ]: 2 : OutBasic();
971 : :
972 : 2 : DecIndentLevel(); // Inhalt von <HEAD> einruecken
973 [ + - ]: 2 : OutNewLine();
974 [ + - ][ + - ]: 2 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_head, sal_False );
975 : :
976 : : // der Body wird nicht eingerueckt, weil sonst alles eingerueckt waere!
977 [ + - ]: 2 : OutNewLine();
978 [ + - ][ + - ]: 2 : sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_body);
979 [ + - ][ + - ]: 2 : Strm() << sOut.makeStringAndClear().getStr();
980 : :
981 : : // language
982 [ + - ]: 2 : OutLanguage( eLang );
983 : :
984 : : // Textfarbe ausgeben, wenn sie an der Standard-Vorlage gesetzt ist
985 : : // und sich geaendert hat.
986 : : OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_text,
987 [ + - ]: 2 : pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false ),
988 [ + - ]: 2 : *this );
989 : :
990 : : // Farben fuer (un)besuchte Links
991 : : OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_link,
992 [ + - ]: 2 : pDoc->GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL ),
993 [ + - ]: 2 : *this );
994 : : OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_vlink,
995 [ + - ]: 2 : pDoc->GetCharFmtFromPool( RES_POOLCHR_INET_VISIT ),
996 [ + - ]: 2 : *this );
997 : :
998 : 2 : const SfxItemSet& rItemSet = pPageDesc->GetMaster().GetAttrSet();
999 : :
1000 [ + - ]: 2 : String aEmbGrfName;
1001 [ + - ]: 2 : OutBackground( rItemSet, aEmbGrfName, sal_True );
1002 : :
1003 [ + - ]: 2 : nDirection = GetHTMLDirection( rItemSet );
1004 [ + - ]: 2 : OutDirection( nDirection );
1005 : :
1006 [ + - ]: 2 : if( bCfgOutStyles )
1007 [ + - ][ + - ]: 2 : OutCSS1_BodyTagStyleOpt( *this, rItemSet, aEmbGrfName );
[ + - ]
1008 : :
1009 : : // Events anhaengen
1010 [ + - ]: 2 : if( pDoc->GetDocShell() ) // nur mit DocShell ist Basic moeglich
1011 [ + - ]: 2 : OutBasicBodyEvents();
1012 : :
1013 [ + - ][ + - ]: 2 : Strm() << '>';
1014 : :
1015 [ + - ]: 2 : return pPageDesc;
1016 : : }
1017 : :
1018 : 0 : void SwHTMLWriter::OutAnchor( const String& rName )
1019 : : {
1020 : 0 : rtl::OStringBuffer sOut;
1021 [ # # ][ # # ]: 0 : sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_anchor).append(' ')
[ # # ]
1022 [ # # ][ # # ]: 0 : .append(OOO_STRING_SVTOOLS_HTML_O_name).append("=\"");
1023 [ # # ][ # # ]: 0 : Strm() << sOut.makeStringAndClear().getStr();
1024 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_String( Strm(), rName, eDestEnc, &aNonConvertableCharacters ) << "\">";
[ # # ]
1025 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_anchor, sal_False );
1026 : 0 : }
1027 : :
1028 : 2 : void SwHTMLWriter::OutBookmarks()
1029 : : {
1030 : : // hole das aktuelle Bookmark
1031 : 2 : const ::sw::mark::IMark* pBookmark = NULL;
1032 : 2 : IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
1033 [ - + ]: 2 : if(nBkmkTabPos != -1)
1034 [ # # ][ # # ]: 0 : pBookmark = (pMarkAccess->getMarksBegin() + nBkmkTabPos)->get();
1035 : : // Ausgabe aller Bookmarks in diesem Absatz. Die Content-Position
1036 : : // wird vorerst nicht beruecksichtigt!
1037 : 2 : sal_uInt32 nNode = pCurPam->GetPoint()->nNode.GetIndex();
1038 [ - + # # ]: 2 : while( nBkmkTabPos != -1 &&
[ - + ]
1039 : 0 : pBookmark->GetMarkPos().nNode.GetIndex() == nNode )
1040 : : {
1041 : : // Der Bereich derBookmark wird erstam ignoriert, da er von uns
1042 : : // auch nicht eingelesen wird.
1043 : :
1044 : : // erst die SWG spezifischen Daten:
1045 [ # # ][ # # ]: 0 : if(dynamic_cast< const ::sw::mark::IBookmark* >(pBookmark) && !pBookmark->GetName().isEmpty() )
[ # # ][ # # ]
1046 [ # # ]: 0 : OutAnchor( pBookmark->GetName() );
1047 : :
1048 [ # # ]: 0 : if( ++nBkmkTabPos >= pMarkAccess->getMarksCount() )
1049 : 0 : nBkmkTabPos = -1;
1050 : : else
1051 [ # # ][ # # ]: 0 : pBookmark = (pMarkAccess->getMarksBegin() + nBkmkTabPos)->get();
1052 : : }
1053 : :
1054 : : sal_uInt32 nPos;
1055 [ - + # # ]: 2 : for( nPos = 0; nPos < aOutlineMarkPoss.size() &&
[ - + ]
1056 : 0 : aOutlineMarkPoss[nPos] < nNode; nPos++ )
1057 : : ;
1058 : :
1059 [ - + ][ # # ]: 2 : while( nPos < aOutlineMarkPoss.size() && aOutlineMarkPoss[nPos] == nNode )
[ - + ]
1060 : : {
1061 [ # # ][ # # ]: 0 : String sMark( aOutlineMarks[nPos] );
1062 [ # # ]: 0 : sMark.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5
1063 [ # # ]: 0 : OutAnchor( sMark );
1064 [ # # ][ # # ]: 0 : aOutlineMarkPoss.erase( aOutlineMarkPoss.begin()+nPos );
1065 [ # # ][ # # ]: 0 : aOutlineMarks.erase( aOutlineMarks.begin() + nPos );
[ # # ]
1066 [ # # ]: 0 : }
1067 : 2 : }
1068 : :
1069 : 0 : void SwHTMLWriter::OutImplicitMark( const String& rMark,
1070 : : const sal_Char *pMarkType )
1071 : : {
1072 [ # # ][ # # ]: 0 : if( rMark.Len() && !aImplicitMarks.empty() )
[ # # ]
1073 : : {
1074 [ # # ]: 0 : String sMark( rMark );
1075 [ # # ]: 0 : sMark.Append( cMarkSeperator );
1076 [ # # ]: 0 : sMark.AppendAscii( pMarkType );
1077 [ # # ][ # # ]: 0 : if( 0 != aImplicitMarks.erase( sMark ) )
1078 : : {
1079 [ # # ]: 0 : sMark.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5
1080 [ # # ]: 0 : OutAnchor( sMark );
1081 [ # # ]: 0 : }
1082 : : }
1083 : 0 : }
1084 : :
1085 : 0 : void SwHTMLWriter::OutHyperlinkHRefValue( const String& rURL )
1086 : : {
1087 [ # # ]: 0 : String sURL( rURL );
1088 [ # # ]: 0 : xub_StrLen nPos = sURL.SearchBackward( cMarkSeperator );
1089 [ # # ]: 0 : if( STRING_NOTFOUND != nPos )
1090 : : {
1091 [ # # ][ # # ]: 0 : String sCmp(comphelper::string::remove(sURL.Copy(nPos+1), ' '));
[ # # ][ # # ]
1092 [ # # ]: 0 : if( sCmp.Len() )
1093 : : {
1094 [ # # ]: 0 : sCmp.ToLowerAscii();
1095 [ # # ][ # # ]: 0 : if( sCmp.EqualsAscii( pMarkToRegion ) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1096 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToFrame ) ||
1097 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToGraphic ) ||
1098 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToOLE ) ||
1099 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToTable ) ||
1100 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToOutline ) ||
1101 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToText ) )
1102 : : {
1103 [ # # ]: 0 : sURL.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5
1104 : : }
1105 [ # # ]: 0 : }
1106 : : }
1107 : :
1108 [ # # ][ # # ]: 0 : sURL = URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), sURL);
[ # # ][ # # ]
1109 [ # # ]: 0 : HTMLOutFuncs::Out_String( Strm(), sURL, eDestEnc,
1110 [ # # ][ # # ]: 0 : &aNonConvertableCharacters );
1111 : 0 : }
1112 : :
1113 : 0 : void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem,
1114 : : String& rEmbGrfNm, sal_Bool bGraphic )
1115 : : {
1116 : 0 : const Color &rBackColor = pBrushItem->GetColor();
1117 : : /// check, if background color is not "no fill"/"auto fill", instead of
1118 : : /// only checking, if transparency is not set.
1119 [ # # ]: 0 : if( rBackColor.GetColor() != COL_TRANSPARENT )
1120 : : {
1121 : 0 : rtl::OStringBuffer sOut;
1122 [ # # ][ # # ]: 0 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append('=');
[ # # ]
1123 [ # # ][ # # ]: 0 : Strm() << sOut.makeStringAndClear().getStr();
1124 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_Color( Strm(), rBackColor, eDestEnc);
1125 : : }
1126 : :
1127 [ # # ]: 0 : if( !bGraphic )
1128 : 0 : return;
1129 : :
1130 : 0 : const String *pLink = pBrushItem->GetGraphicLink();
1131 : :
1132 : : // embeddete Grafik -> WriteEmbedded schreiben
1133 [ # # ]: 0 : if( !pLink )
1134 : : {
1135 : 0 : const Graphic* pGrf = pBrushItem->GetGraphic();
1136 [ # # ]: 0 : if( pGrf )
1137 : : {
1138 : : // Grafik als (JPG-)File speichern
1139 : 0 : const String* pTempFileName = GetOrigFileName();
1140 [ # # ]: 0 : if(pTempFileName)
1141 : 0 : rEmbGrfNm = *pTempFileName;
1142 : : sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, rEmbGrfNm,
1143 : : rtl::OUString("JPG"),
1144 [ # # ][ # # ]: 0 : XOUTBMP_USE_NATIVE_IF_POSSIBLE );
[ # # ]
1145 [ # # ]: 0 : if( !nErr ) // fehlerhaft, da ist nichts auszugeben
1146 : : {
1147 : : rEmbGrfNm = URIHelper::SmartRel2Abs(
1148 : 0 : INetURLObject( GetBaseURL() ), rEmbGrfNm,
1149 [ # # # # ]: 0 : URIHelper::GetMaybeFileHdl() );
[ # # ][ # # ]
[ # # ][ # # ]
1150 : 0 : pLink = &rEmbGrfNm;
1151 : : }
1152 : : else
1153 : : {
1154 : 0 : nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
1155 : : }
1156 : : }
1157 : : }
1158 : : else
1159 : : {
1160 : 0 : rEmbGrfNm = *pLink;
1161 [ # # ]: 0 : if( bCfgCpyLinkedGrfs )
1162 : : {
1163 : 0 : CopyLocalFileToINet( rEmbGrfNm );
1164 : 0 : pLink = &rEmbGrfNm;
1165 : : }
1166 : : }
1167 : :
1168 [ # # ]: 0 : if( pLink )
1169 : : {
1170 [ # # ][ # # ]: 0 : String s( URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), *pLink));
[ # # ][ # # ]
1171 [ # # ][ # # ]: 0 : Strm() << " " OOO_STRING_SVTOOLS_HTML_O_background "=\"";
1172 [ # # ][ # # ]: 0 : HTMLOutFuncs::Out_String( Strm(), s, eDestEnc, &aNonConvertableCharacters ) << '\"';
[ # # ][ # # ]
1173 : : }
1174 : : }
1175 : :
1176 : 2 : void SwHTMLWriter::OutBackground( const SfxItemSet& rItemSet,
1177 : : String& rEmbGrfNm, sal_Bool bGraphic )
1178 : : {
1179 : : const SfxPoolItem* pItem;
1180 [ - + ]: 2 : if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BACKGROUND, sal_False,
1181 [ + - ]: 2 : &pItem ))
1182 : : {
1183 [ # # ]: 0 : OutBackground( ((const SvxBrushItem*)pItem), rEmbGrfNm, bGraphic );
1184 : : }
1185 : 2 : }
1186 : :
1187 : 6 : sal_uInt16 SwHTMLWriter::GetLangWhichIdFromScript( sal_uInt16 nScript )
1188 : : {
1189 : : sal_uInt16 nWhichId;
1190 [ - - + ]: 6 : switch( nScript )
1191 : : {
1192 : : case CSS1_OUTMODE_CJK:
1193 : 0 : nWhichId = RES_CHRATR_CJK_LANGUAGE;
1194 : 0 : break;
1195 : : case CSS1_OUTMODE_CTL:
1196 : 0 : nWhichId = RES_CHRATR_CJK_LANGUAGE;
1197 : 0 : break;
1198 : : default:
1199 : 6 : nWhichId = RES_CHRATR_LANGUAGE;
1200 : 6 : break;
1201 : : }
1202 : 6 : return nWhichId;
1203 : : }
1204 : :
1205 : 2 : void SwHTMLWriter::OutLanguage( LanguageType nLang )
1206 : : {
1207 [ + - ]: 2 : if( LANGUAGE_DONTKNOW != nLang )
1208 : : {
1209 : 2 : rtl::OStringBuffer sOut;
1210 [ + - ][ + - ]: 2 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_lang)
1211 [ + - ]: 2 : .append("=\"");
1212 [ + - ][ + - ]: 2 : Strm() << sOut.makeStringAndClear().getStr();
1213 [ + - ]: 2 : HTMLOutFuncs::Out_String( Strm(), MsLangId::convertLanguageToIsoString(nLang),
1214 [ + - ][ + - ]: 4 : eDestEnc, &aNonConvertableCharacters ) << '"';
[ + - ][ + - ]
[ + - ]
1215 : : }
1216 : 2 : }
1217 : :
1218 : 2 : sal_uInt16 SwHTMLWriter::GetHTMLDirection( const SfxItemSet& rItemSet ) const
1219 : : {
1220 : : return GetHTMLDirection(
1221 : 2 : static_cast < const SvxFrameDirectionItem& >( rItemSet.Get( RES_FRAMEDIR ) )
1222 : 2 : .GetValue() );
1223 : : }
1224 : :
1225 : 4 : sal_uInt16 SwHTMLWriter::GetHTMLDirection( sal_uInt16 nDir ) const
1226 : : {
1227 [ - - + + ]: 4 : switch( nDir )
1228 : : {
1229 : : case FRMDIR_VERT_TOP_LEFT:
1230 : 0 : nDir = FRMDIR_HORI_LEFT_TOP;
1231 : 0 : break;
1232 : : case FRMDIR_VERT_TOP_RIGHT:
1233 : 0 : nDir = FRMDIR_HORI_RIGHT_TOP;
1234 : 0 : break;
1235 : : case FRMDIR_ENVIRONMENT:
1236 : 2 : nDir = nDirection;
1237 : : }
1238 : :
1239 : 4 : return nDir;
1240 : : }
1241 : :
1242 : 2 : void SwHTMLWriter::OutDirection( sal_uInt16 nDir )
1243 : : {
1244 : 2 : const sal_Char *pValue = 0;
1245 [ + - - ]: 2 : switch( nDir )
1246 : : {
1247 : : case FRMDIR_HORI_LEFT_TOP:
1248 : : case FRMDIR_VERT_TOP_LEFT:
1249 : 2 : pValue = "LTR";
1250 : 2 : break;
1251 : : case FRMDIR_HORI_RIGHT_TOP:
1252 : : case FRMDIR_VERT_TOP_RIGHT:
1253 : 0 : pValue = "RTL";
1254 : 0 : break;
1255 : : }
1256 [ + - ]: 2 : if( pValue != 0 )
1257 : : {
1258 : 2 : rtl::OStringBuffer sOut;
1259 [ + - ][ + - ]: 2 : sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_dir)
1260 [ + - ][ + - ]: 2 : .append("=\"").append(pValue).append('\"');
[ + - ]
1261 [ + - ][ + - ]: 2 : Strm() << sOut.makeStringAndClear().getStr();
1262 : : }
1263 : 2 : }
1264 : :
1265 : 2 : rtl::OString SwHTMLWriter::GetIndentString(sal_uInt16 nIncLvl)
1266 : : {
1267 : 2 : rtl::OString sRet;
1268 : :
1269 : : // etwas umstaendlich, aber wir haben nur einen Indent-String!
1270 : 2 : sal_uInt16 nLevel = nIndentLvl + nIncLvl;
1271 : :
1272 [ + - ][ + - ]: 2 : if( nLevel && nLevel <= MAX_INDENT_LEVEL)
1273 : : {
1274 : 2 : sIndentTabs[nLevel] = 0;
1275 : 2 : sRet = sIndentTabs;
1276 : 2 : sIndentTabs[nLevel] = '\t';
1277 : : }
1278 : :
1279 : 2 : return sRet;
1280 : : }
1281 : :
1282 : 16 : void SwHTMLWriter::OutNewLine( sal_Bool bCheck )
1283 : : {
1284 [ + + ][ + - ]: 16 : if( !bCheck || (Strm().Tell()-nLastLFPos) > nIndentLvl )
[ + - ]
1285 : : {
1286 : 16 : Strm() << sNewLine;
1287 : 16 : nLastLFPos = Strm().Tell();
1288 : : }
1289 : :
1290 [ - + ][ # # ]: 16 : if( nIndentLvl && nIndentLvl <= MAX_INDENT_LEVEL)
1291 : : {
1292 : 0 : sIndentTabs[nIndentLvl] = 0;
1293 : 0 : Strm() << sIndentTabs;
1294 : 0 : sIndentTabs[nIndentLvl] = '\t';
1295 : : }
1296 : 16 : }
1297 : :
1298 : 0 : sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
1299 : : {
1300 : 0 : sal_uInt16 nSize = 1;
1301 [ # # ]: 0 : for( sal_uInt16 i=6; i>0; i-- )
1302 : : {
1303 [ # # ]: 0 : if( nHeight > (aFontHeights[i] + aFontHeights[i-1])/2 )
1304 : : {
1305 : 0 : nSize = i+1;
1306 : 0 : break;
1307 : : }
1308 : : }
1309 : :
1310 : 0 : return nSize;
1311 : : }
1312 : :
1313 : : // Struktur speichert die aktuellen Daten des Writers zwischen, um
1314 : : // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
1315 : 0 : HTMLSaveData::HTMLSaveData( SwHTMLWriter& rWriter, sal_uLong nStt,
1316 : : sal_uLong nEnd, sal_Bool bSaveNum,
1317 : : const SwFrmFmt *pFrmFmt ) :
1318 : : rWrt( rWriter ),
1319 : : pOldPam( rWrt.pCurPam ),
1320 : 0 : pOldEnd( rWrt.GetEndPaM() ),
1321 : : pOldNumRuleInfo( 0 ),
1322 : : pOldNextNumRuleInfo( 0 ),
1323 : : nOldDefListLvl( rWrt.nDefListLvl ),
1324 : : nOldDirection( rWrt.nDirection ),
1325 : : bOldOutHeader( rWrt.bOutHeader ),
1326 : : bOldOutFooter( rWrt.bOutFooter ),
1327 : 0 : bOldOutFlyFrame( rWrt.bOutFlyFrame )
1328 : : {
1329 : 0 : bOldWriteAll = rWrt.bWriteAll;
1330 : :
1331 : 0 : rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd );
1332 : :
1333 : : // Tabelle in Sonderbereichen erkennen
1334 [ # # ]: 0 : if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() )
1335 : : {
1336 : 0 : const SwNode *pNd = rWrt.pDoc->GetNodes()[ nStt ];
1337 [ # # ][ # # ]: 0 : if( pNd->IsTableNode() || pNd->IsSectionNode() )
[ # # ]
1338 : 0 : rWrt.pCurPam->GetMark()->nNode = nStt;
1339 : : }
1340 : :
1341 : 0 : rWrt.SetEndPaM( rWrt.pCurPam );
1342 : 0 : rWrt.pCurPam->Exchange( );
1343 : 0 : rWrt.bWriteAll = sal_True;
1344 : 0 : rWrt.nDefListLvl = 0;
1345 : 0 : rWrt.bOutHeader = rWrt.bOutFooter = sal_False;
1346 : :
1347 : : // Ggf. die aktuelle Numerierungs-Info merken, damit sie wieder
1348 : : // neu aufgenommen werden kann. Nur dann belibt auch die Numerierungs-
1349 : : // Info des nachsten Absatz gueltig.
1350 [ # # ]: 0 : if( bSaveNum )
1351 : : {
1352 : 0 : pOldNumRuleInfo = new SwHTMLNumRuleInfo( rWrt.GetNumInfo() );
1353 : 0 : pOldNextNumRuleInfo = rWrt.GetNextNumInfo();
1354 : 0 : rWrt.SetNextNumInfo( 0 );
1355 : : }
1356 : : else
1357 : : {
1358 : 0 : rWrt.ClearNextNumInfo();
1359 : : }
1360 : :
1361 : : // Die Numerierung wird in jedem Fall unterbrochen.
1362 : 0 : rWrt.GetNumInfo().Clear();
1363 : :
1364 [ # # ]: 0 : if( pFrmFmt )
1365 : 0 : rWrt.nDirection = rWrt.GetHTMLDirection( pFrmFmt->GetAttrSet() );
1366 : 0 : }
1367 : :
1368 : :
1369 : 0 : HTMLSaveData::~HTMLSaveData()
1370 : : {
1371 [ # # ]: 0 : delete rWrt.pCurPam; // Pam wieder loeschen
1372 : :
1373 : 0 : rWrt.pCurPam = pOldPam;
1374 : 0 : rWrt.SetEndPaM( pOldEnd );
1375 : 0 : rWrt.bWriteAll = bOldWriteAll;
1376 [ # # ]: 0 : rWrt.nBkmkTabPos = bOldWriteAll ? rWrt.FindPos_Bkmk( *pOldPam->GetPoint() ) : -1;
1377 : 0 : rWrt.nLastParaToken = 0;
1378 : 0 : rWrt.nDefListLvl = nOldDefListLvl;
1379 : 0 : rWrt.nDirection = nOldDirection;
1380 : 0 : rWrt.bOutHeader = bOldOutHeader;
1381 : 0 : rWrt.bOutFooter = bOldOutFooter;
1382 : 0 : rWrt.bOutFlyFrame = bOldOutFlyFrame;
1383 : :
1384 : : // Ggf. die Numerierung von vor der Section fortsetzen. Die Numerierung
1385 : : // des naecshten Absatz wird in jedem Fall ungueltig.
1386 [ # # ]: 0 : if( pOldNumRuleInfo )
1387 : : {
1388 : 0 : rWrt.GetNumInfo().Set( *pOldNumRuleInfo );
1389 : 0 : delete pOldNumRuleInfo;
1390 : 0 : rWrt.SetNextNumInfo( pOldNextNumRuleInfo );
1391 : : }
1392 : : else
1393 : : {
1394 : 0 : rWrt.GetNumInfo().Clear();
1395 : 0 : rWrt.ClearNextNumInfo();
1396 : : }
1397 : 0 : }
1398 : :
1399 : :
1400 : 2 : void GetHTMLWriter( const String&, const String& rBaseURL, WriterRef& xRet )
1401 : : {
1402 [ + - ]: 2 : xRet = new SwHTMLWriter( rBaseURL );
1403 : 2 : }
1404 : :
1405 : :
1406 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|