LibreOffice Module sw (master)  1
wrthtml.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <stdlib.h>
21 #include <hintids.hxx>
22 #include <comphelper/string.hxx>
23 #include <svl/urihelper.hxx>
24 #include <rtl/tencinfo.h>
25 #include <vcl/wrkwin.hxx>
26 #include <sfx2/linkmgr.hxx>
27 #include <sfx2/docfile.hxx>
28 
29 #include <svtools/htmlcfg.hxx>
30 #include <svtools/htmltokn.h>
31 #include <svtools/htmlkywd.hxx>
32 #include <vcl/svapp.hxx>
34 #include <sfx2/frmhtmlw.hxx>
35 #include <svx/xoutbmp.hxx>
37 #include <sfx2/htmlmode.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/colritem.hxx>
40 #include <editeng/brushitem.hxx>
41 #include <editeng/fontitem.hxx>
43 #include <editeng/langitem.hxx>
44 #include <svl/stritem.hxx>
45 #include <editeng/frmdiritem.hxx>
46 
47 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
48 #include <com/sun/star/document/XDocumentProperties.hpp>
49 #include <fmthdft.hxx>
50 #include <fmtfld.hxx>
51 #include <fmtpdsc.hxx>
52 #include <txatbase.hxx>
53 #include <frmatr.hxx>
54 #include <charfmt.hxx>
55 #include <docary.hxx>
56 #include <pam.hxx>
57 #include <doc.hxx>
58 #include <ndgrf.hxx>
59 #include <ndtxt.hxx>
60 #include <mdiexp.hxx>
61 #include <fltini.hxx>
62 #include <viewopt.hxx>
63 #include <IMark.hxx>
64 #include <poolfmt.hxx>
65 #include <pagedesc.hxx>
66 #include <section.hxx>
67 #include <swtable.hxx>
68 #include <fldbas.hxx>
69 #include <fmtclds.hxx>
70 #include <docsh.hxx>
71 #include "wrthtml.hxx"
72 #include "htmlnum.hxx"
73 #include "htmlfly.hxx"
74 #include <swmodule.hxx>
75 #include <strings.hrc>
76 #include <swerror.h>
77 #include <rtl/strbuf.hxx>
80 #include <IDocumentMarkAccess.hxx>
81 #include <xmloff/odffields.hxx>
82 #include <tools/urlobj.hxx>
83 #include <osl/file.hxx>
85 #include <unotools/tempfile.hxx>
86 
87 #define MAX_INDENT_LEVEL 20
88 
89 using namespace css;
90 
92  "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
93 
94 SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions )
95  : m_pNumRuleInfo(new SwHTMLNumRuleInfo)
96  , m_nHTMLMode(0)
97  , m_eCSS1Unit(FieldUnit::NONE)
98  , mxFormComps()
99  , m_pStartNdIdx(nullptr)
100  , m_pCurrPageDesc(nullptr)
101  , m_pFormatFootnote(nullptr)
102  , m_nWarn(0)
103  , m_nLastLFPos(0)
104  , m_nLastParaToken(HtmlTokenId::NONE)
105  , m_nBkmkTabPos(-1)
106  , m_nImgMapCnt(1)
107  , m_nFormCntrlCnt(0)
108  , m_nEndNote(0)
109  , m_nFootNote(0)
110  , m_nLeftMargin(0)
111  , m_nDfltLeftMargin(0)
112  , m_nDfltRightMargin(0)
113  , m_nFirstLineIndent(0)
114  , m_nDfltFirstLineIndent(0)
115  , m_nDfltTopMargin(0)
116  , m_nDfltBottomMargin(0)
117  , m_nIndentLvl(0)
118  , m_nWhishLineLen(0)
119  , m_nDefListLvl(0)
120  , m_nDefListMargin(0)
121  , m_nHeaderFooterSpace(0)
122  , m_nTextAttrsToIgnore(0)
123  , m_nExportMode(0)
124  , m_nCSS1OutMode(0)
125  , m_nCSS1Script(CSS1_OUTMODE_WESTERN)
126  , m_nDirection(SvxFrameDirection::Horizontal_LR_TB)
127  , m_eDestEnc(RTL_TEXTENCODING_MS_1252)
128  , m_eLang(LANGUAGE_DONTKNOW)
129  , m_bCfgOutStyles( false )
130  , m_bCfgPreferStyles( false )
131  , m_bCfgFormFeed( false )
132  , m_bCfgStarBasic( false )
133  , m_bCfgCpyLinkedGrfs( false )
134  , m_bFirstLine(true)
135  , m_bTagOn( false )
136  , m_bTextAttr( false )
137  , m_bOutOpts( false )
138  , m_bOutTable( false )
139  , m_bOutHeader( false )
140  , m_bOutFooter( false )
141  , m_bOutFlyFrame( false )
142  , m_bFirstCSS1Rule( false )
143  , m_bFirstCSS1Property( false )
144  , m_bCSS1IgnoreFirstPageDesc( false )
145  , m_bNoAlign( false )
146  , m_bClearLeft( false )
147  , m_bClearRight( false )
148  , m_bLFPossible( false )
149  , m_bPreserveForm( false )
150  , m_bCfgNetscape4( false )
151  , mbSkipImages(false)
152  , mbSkipHeaderFooter(false)
153  , mbEmbedImages(false)
154  , m_bCfgPrintLayout( false )
155  , m_bParaDotLeaders( false )
156 {
157  SetBaseURL(rBaseURL);
158 
159  if (rBaseURL.isEmpty())
160  {
161  // Paste: set base URL to a tempfile, so images are not lost.
162  mpTempBaseURL.reset(new utl::TempFile());
163  mpTempBaseURL->EnableKillingFile();
164  SetBaseURL(mpTempBaseURL->GetURL());
165  }
166 
167  SetupFilterOptions(rFilterOptions);
168 }
169 
171 {
172 }
173 
174 std::unique_ptr<SwHTMLNumRuleInfo> SwHTMLWriter::ReleaseNextNumInfo()
175 {
176  return std::move(m_pNextNumRuleInfo);
177 }
178 
180 {
181  const SfxItemSet* pSet = rMedium.GetItemSet();
182  if (pSet == nullptr)
183  return;
184 
185  const SfxPoolItem* pItem;
186  if (pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) != SfxItemState::SET)
187  return;
188 
189 
190  const OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
191  SetupFilterOptions(sFilterOptions);
192 }
193 
194 void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
195 {
196  if (rFilterOptions == "SkipImages")
197  {
198  mbSkipImages = true;
199  }
200  else if (rFilterOptions == "SkipHeaderFooter")
201  {
202  mbSkipHeaderFooter = true;
203  }
204  else if (rFilterOptions == "EmbedImages")
205  {
206  mbEmbedImages = true;
207  }
208 
209  const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(rFilterOptions);
210  const OUString aXhtmlNsKey("xhtmlns=");
211  for (const auto& rOption : aOptionSeq)
212  {
213  if (rOption == "XHTML")
214  mbXHTML = true;
215  else if (rOption.startsWith(aXhtmlNsKey))
216  {
217  maNamespace = rOption.copy(aXhtmlNsKey.getLength()).toUtf8();
218  if (maNamespace == "reqif-xhtml")
219  {
220  mbReqIF = true;
221  // XHTML is always just a fragment inside ReqIF.
222  mbSkipHeaderFooter = true;
223  }
224  // XHTML namespace implies XHTML.
225  mbXHTML = true;
226  }
227  }
228 }
229 
231 {
232  // Intercept paste output if requested.
233  char* pPasteEnv = getenv("SW_DEBUG_HTML_PASTE_TO");
234  std::unique_ptr<SvStream> pPasteStream;
235  SvStream* pOldPasteStream = nullptr;
236  if (pPasteEnv)
237  {
238  OUString aPasteStr;
239  if (osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(pPasteEnv), aPasteStr)
240  == osl::FileBase::E_None)
241  {
242  pPasteStream.reset(new SvFileStream(aPasteStr, StreamMode::WRITE));
243  pOldPasteStream = &Strm();
244  SetStream(pPasteStream.get());
245  }
246  }
247  comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
248 
249  SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
250 
251  // font heights 1-7
252  m_aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
253  m_aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
254  m_aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
255  m_aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
256  m_aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
257  m_aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
258  m_aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
259 
260  // output styles anyway
261  // (then also top and bottom paragraph spacing)
262  m_nExportMode = rHtmlOptions.GetExportMode();
263  m_nHTMLMode = GetHtmlMode(nullptr);
264 
267 
270 
273 
276 
279 
282 
284 
287 
290 
293 
295 
296  bool bWriteUTF8 = m_bWriteClipboardDoc;
297  m_eDestEnc = bWriteUTF8 ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding();
298  const sal_Char *pCharSet = rtl_getBestMimeCharsetFromTextEncoding( m_eDestEnc );
299  m_eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
300 
301  // Only for the MS-IE we favour the export of styles.
303 
304  m_bCfgStarBasic = rHtmlOptions.IsStarBasic();
305 
307  m_bCfgCpyLinkedGrfs = rHtmlOptions.IsSaveGraphicsLocal();
308 
309  m_bCfgPrintLayout = rHtmlOptions.IsPrintLayoutExtension();
310 
311  // get HTML template
312  bool bOldHTMLMode = false;
313  SwTextFormatColls::size_type nOldTextFormatCollCnt = 0;
314  SwCharFormats::size_type nOldCharFormatCnt = 0;
315 
316  OSL_ENSURE( !m_xTemplate.is(), "Where is the HTML template coming from?" );
317  m_xTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc(*m_pDoc);
318  if( m_xTemplate.is() )
319  {
320  bOldHTMLMode = m_xTemplate->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE);
321  m_xTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true);
322 
323  nOldTextFormatCollCnt = m_xTemplate->GetTextFormatColls()->size();
324  nOldCharFormatCnt = m_xTemplate->GetCharFormats()->size();
325  }
326 
327  if( m_bShowProgress )
328  ::StartProgress( STR_STATSTR_W4WWRITE, 0, m_pDoc->GetNodes().Count(),
329  m_pDoc->GetDocShell());
330 
331  m_xDfltColor.reset();
332  m_pFootEndNotes = nullptr;
333  m_pFormatFootnote = nullptr;
335  mxFormComps.clear();
336  m_nFormCntrlCnt = 0;
337  m_bPreserveForm = false;
338  m_bClearLeft = m_bClearRight = false;
339  m_bLFPossible = false;
340 
346  m_nIndentLvl = 0;
347  m_nWhishLineLen = 70;
348  m_nLastLFPos = 0;
349  m_nDefListLvl = 0;
350  m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : m_pDoc)
352  ->GetLRSpace().GetTextLeft();
355  m_nCSS1OutMode = 0;
357  switch( nScript )
358  {
359  case SvtScriptType::ASIAN:
361  break;
362  case SvtScriptType::COMPLEX:
364  break;
365  default:
367  break;
368  }
369  m_eLang = static_cast<const SvxLanguageItem&>(m_pDoc
371 
372  m_nFootNote = m_nEndNote = 0;
373 
375  GetNumInfo().Clear();
376  m_pNextNumRuleInfo = nullptr;
377 
378  OString aStartTags;
379 
380  // respect table and section at document beginning
381  {
382  SwTableNode * pTNd = m_pCurrentPam->GetNode().FindTableNode();
383  if( pTNd && m_bWriteAll )
384  {
385  // start with table node !!
386  m_pCurrentPam->GetPoint()->nNode = *pTNd;
387 
389  m_pCurrentPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
390  }
391 
392  // first node (with can contain a page break)
393  m_pStartNdIdx = new SwNodeIndex( m_pCurrentPam->GetPoint()->nNode );
394 
395  SwSectionNode * pSNd = m_pCurrentPam->GetNode().FindSectionNode();
396  while( pSNd )
397  {
398  if( m_bWriteAll )
399  {
400  // start with section node !!
401  m_pCurrentPam->GetPoint()->nNode = *pSNd;
402  }
403  else
404  {
405  OSL_ENSURE( FILE_LINK_SECTION != pSNd->GetSection().GetType(),
406  "Export linked areas at document beginning is not implemented" );
407 
408  // save only the tag of section
410  pSNd->GetSection().GetSectionName(), m_eDestEnc,
412 
413  OStringBuffer sOut;
414  sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division)
415  .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_id)
416  .append("=\"").append(aName).append('\"').append('>')
417  .append(aStartTags);
418  aStartTags = sOut.makeStringAndClear();
419  }
420  // FindSectionNode() on a SectionNode return the same!
421  pSNd = pSNd->StartOfSectionNode()->FindSectionNode();
422  }
423  }
424 
425  // create table of the floating frames, but only when the whole
426  // document is saved
427  m_pHTMLPosFlyFrames = nullptr;
429  m_nLastParaToken = HtmlTokenId::NONE;
430  GetControls();
432 
433  sal_uInt16 nHeaderAttrs = 0;
434  m_pCurrPageDesc = MakeHeader( nHeaderAttrs );
435 
436  m_bLFPossible = true;
437 
438  // output forms which contain only HiddenControls
439  OutHiddenForms();
440 
441  if( !aStartTags.isEmpty() )
442  Strm().WriteCharPtr( aStartTags.getStr() );
443 
444  const SfxPoolItem *pItem;
445  const SfxItemSet& rPageItemSet = m_pCurrPageDesc->GetMaster().GetAttrSet();
449  SfxItemState::SET == rPageItemSet.GetItemState( RES_HEADER, true, &pItem) )
450  {
451  const SwFrameFormat *pHeaderFormat =
452  static_cast<const SwFormatHeader *>(pItem)->GetHeaderFormat();
453  if( pHeaderFormat )
454  OutHTML_HeaderFooter( *this, *pHeaderFormat, true );
455  }
456 
457  m_nTextAttrsToIgnore = nHeaderAttrs;
460 
461  if( mxFormComps.is() )
462  OutForm( false, mxFormComps );
463 
464  if( m_pFootEndNotes )
465  OutFootEndNotes();
466 
469  SfxItemState::SET == rPageItemSet.GetItemState( RES_FOOTER, true, &pItem) )
470  {
471  const SwFrameFormat *pFooterFormat =
472  static_cast<const SwFormatFooter *>(pItem)->GetFooterFormat();
473  if( pFooterFormat )
474  OutHTML_HeaderFooter( *this, *pFooterFormat, false );
475  }
476 
477  if( m_bLFPossible )
478  OutNewLine();
479  if (!mbSkipHeaderFooter)
480  {
482  OutNewLine();
484  }
485  else if (mbReqIF)
486  // ReqIF: end xhtml.BlkStruct.class.
488 
489  // delete the table with floating frames
490  OSL_ENSURE( !m_pHTMLPosFlyFrames, "Were not all frames output?" );
491  m_pHTMLPosFlyFrames.reset();
492 
494 
495  m_CharFormatInfos.clear();
496  m_TextCollInfos.clear();
497  m_aImgMapNames.clear();
498  m_aImplicitMarks.clear();
499  m_aOutlineMarks.clear();
500  m_aOutlineMarkPoss.clear();
501  m_aNumRuleNames.clear();
502  m_aScriptParaStyles.clear();
503  m_aScriptTextStyles.clear();
504 
505  m_xDfltColor.reset();
506 
507  delete m_pStartNdIdx;
508  m_pStartNdIdx = nullptr;
509 
510  mxFormComps.clear();
511 
512  OSL_ENSURE( !m_pFootEndNotes,
513  "SwHTMLWriter::Write: Footnotes not deleted by OutFootEndNotes" );
514 
515  m_pCurrPageDesc = nullptr;
516 
518 
519  for(OUString & s : m_aBulletGrfs)
520  s.clear();
521 
523 
524  if( m_bShowProgress )
526 
527  if( m_xTemplate.is() )
528  {
529  // delete character and paragraph templates created during export
530  auto nTextFormatCollCnt = m_xTemplate->GetTextFormatColls()->size();
531  while( nTextFormatCollCnt > nOldTextFormatCollCnt )
532  m_xTemplate->DelTextFormatColl( --nTextFormatCollCnt );
533  OSL_ENSURE( m_xTemplate->GetTextFormatColls()->size() == nOldTextFormatCollCnt,
534  "wrong number of TextFormatColls deleted" );
535 
536  auto nCharFormatCnt = m_xTemplate->GetCharFormats()->size();
537  while( nCharFormatCnt > nOldCharFormatCnt )
538  m_xTemplate->DelCharFormat( --nCharFormatCnt );
539  OSL_ENSURE( m_xTemplate->GetCharFormats()->size() == nOldCharFormatCnt,
540  "wrong number of CharFormats deleted" );
541 
542  // restore HTML mode
543  m_xTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, bOldHTMLMode);
544 
545  m_xTemplate.clear();
546  }
547 
548  return m_nWarn;
549 }
550 
551 static const SwFormatCol *lcl_html_GetFormatCol( const SwSection& rSection,
552  const SwSectionFormat& rFormat )
553 {
554  const SwFormatCol *pCol = nullptr;
555 
556  const SfxPoolItem* pItem;
557  if( FILE_LINK_SECTION != rSection.GetType() &&
558  SfxItemState::SET == rFormat.GetAttrSet().GetItemState(RES_COL,false,&pItem) &&
559  static_cast<const SwFormatCol *>(pItem)->GetNumCols() > 1 )
560  {
561  pCol = static_cast<const SwFormatCol *>(pItem);
562  }
563 
564  return pCol;
565 }
566 
567 static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
568 {
569  bool bRet = false;
570  const SwSectionNode *pSectNd =
571  rHTMLWrt.m_pDoc->GetNodes()[nIndex]->GetSectionNode();
572  if( pSectNd )
573  {
574  const SwSection& rSection = pSectNd->GetSection();
575  const SwSectionFormat *pFormat = rSection.GetFormat();
576  if( pFormat && lcl_html_GetFormatCol( rSection, *pFormat ) )
577  bRet = true;
578  }
579 
580  return bRet;
581 }
582 
583 static bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
584 {
585  bool bRet = false;
586  const SwEndNode *pEndNd = rHTMLWrt.m_pDoc->GetNodes()[nIndex]->GetEndNode();
587  if( pEndNd )
588  bRet = lcl_html_IsMultiColStart( rHTMLWrt,
589  pEndNd->StartOfSectionIndex() );
590 
591  return bRet;
592 }
593 
595  const SwSection& rSection,
596  const SwSectionFormat& rFormat,
597  const SwFormatCol *pCol,
598  bool bContinued=false )
599 {
600  OSL_ENSURE( pCol || !bContinued, "Continuation of DIV" );
601 
602  if( rHTMLWrt.m_bLFPossible )
603  rHTMLWrt.OutNewLine();
604 
605  OStringBuffer sOut;
606  sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division);
607 
608  const OUString& rName = rSection.GetSectionName();
609  if( !rName.isEmpty() && !bContinued )
610  {
611  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_id "=\"");
612  rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
613  HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
614  sOut.append('\"');
615  }
616 
617  SvxFrameDirection nDir = rHTMLWrt.GetHTMLDirection( rFormat.GetAttrSet() );
618  rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
619  rHTMLWrt.OutDirection( nDir );
620 
621  if( FILE_LINK_SECTION == rSection.GetType() )
622  {
623  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_href "=\"");
624  rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
625 
626  const OUString& aFName = rSection.GetLinkFileName();
627  sal_Int32 nIdx{ 0 };
628  OUString aURL( aFName.getToken(0, sfx2::cTokenSeparator, nIdx) );
629  OUString aFilter( aFName.getToken(0, sfx2::cTokenSeparator, nIdx) );
630  OUString aSection( aFName.getToken(0, sfx2::cTokenSeparator, nIdx) );
631 
632  OUString aEncURL( URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aURL ) );
633  sal_Unicode cDelim = 255U;
634  bool bURLContainsDelim = (-1 != aEncURL.indexOf( cDelim ) );
635 
636  HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aEncURL,
637  rHTMLWrt.m_eDestEnc,
638  &rHTMLWrt.m_aNonConvertableCharacters );
639  const sal_Char* const pDelim = "&#255;";
640  if( !aFilter.isEmpty() || !aSection.isEmpty() || bURLContainsDelim )
641  rHTMLWrt.Strm().WriteCharPtr( pDelim );
642  if( !aFilter.isEmpty() )
643  HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
644  if( !aSection.isEmpty() || bURLContainsDelim )
645  rHTMLWrt.Strm().WriteCharPtr( pDelim );
646  if( !aSection.isEmpty() )
647  {
648  sal_Int32 nPos = aSection.indexOf( '%' );
649  while( nPos != -1 )
650  {
651  aSection = aSection.replaceAt(nPos, 1, "%25");
652  nPos = aSection.indexOf( '%', nPos+3 );
653  }
654  nPos = aSection.indexOf( cDelim );
655  while( nPos != -1 )
656  {
657  aSection = aSection.replaceAt(nPos, 1, "%FF" );
658  nPos = aSection.indexOf( cDelim, nPos+3 );
659  }
660  HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection,
661  rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
662  }
663  sOut.append('\"');
664  }
665  else if( pCol )
666  {
667  // minimum gutter width
668  sal_uInt16 nGutter = pCol->GetGutterWidth( true );
669  if( nGutter!=USHRT_MAX )
670  {
671  if( nGutter && Application::GetDefaultDevice() )
672  {
673  nGutter = static_cast<sal_uInt16>(Application::GetDefaultDevice()
674  ->LogicToPixel( Size(nGutter, 0), MapMode(MapUnit::MapTwip) ).Width());
675  }
676  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_gutter "=\"" + OString::number(nGutter) + "\"");
677  }
678  }
679 
680  rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
681  if( rHTMLWrt.IsHTMLMode( rHTMLWrt.m_bCfgOutStyles ? HTMLMODE_ON : 0 ) )
682  rHTMLWrt.OutCSS1_SectionFormatOptions( rFormat, pCol );
683 
684  rHTMLWrt.Strm().WriteChar( '>' );
685 
686  rHTMLWrt.m_bLFPossible = true;
687  if( !rName.isEmpty() && !bContinued )
688  rHTMLWrt.OutImplicitMark( rName, "region" );
689 
690  rHTMLWrt.IncIndentLevel();
691 }
692 
693 static void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt )
694 {
695  rHTMLWrt.DecIndentLevel();
696  if( rHTMLWrt.m_bLFPossible )
697  rHTMLWrt.OutNewLine();
699  rHTMLWrt.m_bLFPossible = true;
700 }
701 
702 static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
703 {
704  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
705 
706  // End <PRE> and any <DL>, because a definition list's level may
707  // change inside the section.
708  rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
709  rHTMLWrt.OutAndSetDefList( 0 );
710 
711  const SwSection& rSection = rSectNd.GetSection();
712  const SwSectionFormat *pFormat = rSection.GetFormat();
713  OSL_ENSURE( pFormat, "Section without a format?" );
714 
715  bool bStartTag = true;
716  bool bEndTag = true;
717  const SwSectionFormat *pSurrFormat = nullptr;
718  const SwSectionNode *pSurrSectNd = nullptr;
719  const SwSection *pSurrSection = nullptr;
720  const SwFormatCol *pSurrCol = nullptr;
721 
722  sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
723  sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
724  const SwFormatCol *pCol = lcl_html_GetFormatCol( rSection, *pFormat );
725  if( pCol )
726  {
727  // If the next node is a columned section node, too, don't export
728  // an empty section.
729  if( lcl_html_IsMultiColStart( rHTMLWrt, nSectSttIdx+1 ) )
730  bStartTag = false;
731 
732  // The same applies if the section end with another columned section.
733  if( lcl_html_IsMultiColEnd( rHTMLWrt, nSectEndIdx-1 ) )
734  bEndTag = false;
735 
736  // is there a columned section around this one?
737  const SwStartNode *pSttNd = rSectNd.StartOfSectionNode();
738  if( pSttNd )
739  {
740  pSurrSectNd = pSttNd->FindSectionNode();
741  if( pSurrSectNd )
742  {
743  const SwStartNode *pBoxSttNd = pSttNd->FindTableBoxStartNode();
744  if( !pBoxSttNd ||
745  pBoxSttNd->GetIndex() < pSurrSectNd->GetIndex() )
746  {
747  pSurrSection = &pSurrSectNd->GetSection();
748  pSurrFormat = pSurrSection->GetFormat();
749  if( pSurrFormat )
750  pSurrCol = lcl_html_GetFormatCol( *pSurrSection,
751  *pSurrFormat );
752  }
753  }
754  }
755  }
756 
757  // The surrounding section must be closed before the current one is
758  // opened, except that it start immediately before the current one or
759  // another end immediately before the current one
760  if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
761  !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
762  lcl_html_OutSectionEndTag( rHTMLWrt );
763 
764  if( bStartTag )
765  lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFormat, pCol );
766 
767  {
768  HTMLSaveData aSaveData( rHTMLWrt,
769  rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex()+1,
770  rSectNd.EndOfSectionIndex(),
771  false, pFormat );
772  rHTMLWrt.Out_SwDoc( rHTMLWrt.m_pCurrentPam.get() );
773  }
774 
775  rHTMLWrt.m_pCurrentPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
776 
777  if( bEndTag )
778  lcl_html_OutSectionEndTag( rHTMLWrt );
779 
780  // The surrounding section must be started again, except that it ends
781  // immediately behind the current one.
782  if( pSurrCol &&
783  pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > 1 &&
784  !lcl_html_IsMultiColStart( rHTMLWrt, nSectEndIdx+1 ) )
785  lcl_html_OutSectionStartTag( rHTMLWrt, *pSurrSection, *pSurrFormat,
786  pSurrCol, true );
787 
788  return rWrt;
789 }
790 
792 {
793  bool bSaveWriteAll = m_bWriteAll; // save
794 
795  // search next text::Bookmark position from text::Bookmark table
796  m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
797 
798  // output all areas of PaM's in the HTML file
799  do {
800  m_bWriteAll = bSaveWriteAll;
801  m_bFirstLine = true;
802 
803  // search for first on PaM created FlyFrame
804  // still missing:
805 
806  while( m_pCurrentPam->GetPoint()->nNode.GetIndex() < m_pCurrentPam->GetMark()->nNode.GetIndex() ||
807  (m_pCurrentPam->GetPoint()->nNode.GetIndex() == m_pCurrentPam->GetMark()->nNode.GetIndex() &&
808  m_pCurrentPam->GetPoint()->nContent.GetIndex() <= m_pCurrentPam->GetMark()->nContent.GetIndex()) )
809  {
810  SwNode& rNd = m_pCurrentPam->GetNode();
811 
812  OSL_ENSURE( !(rNd.IsGrfNode() || rNd.IsOLENode()),
813  "Unexpected Grf- or OLE-Node here" );
814  if( rNd.IsTextNode() )
815  {
816  SwTextNode* pTextNd = rNd.GetTextNode();
817 
818  if( !m_bFirstLine )
819  m_pCurrentPam->GetPoint()->nContent.Assign( pTextNd, 0 );
820 
821  OutHTML_SwTextNode( *this, *pTextNd );
822  }
823  else if( rNd.IsTableNode() )
824  {
825  OutHTML_SwTableNode( *this, *rNd.GetTableNode(), nullptr );
826  m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
827  }
828  else if( rNd.IsSectionNode() )
829  {
830  OutHTML_Section( *this, *rNd.GetSectionNode() );
831  m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : -1;
832  }
833  else if( &rNd == &m_pDoc->GetNodes().GetEndOfContent() )
834  break;
835 
836  ++m_pCurrentPam->GetPoint()->nNode; // move
837  sal_uInt32 nPos = m_pCurrentPam->GetPoint()->nNode.GetIndex();
838 
839  if( m_bShowProgress )
840  ::SetProgressState( nPos, m_pDoc->GetDocShell() ); // How far ?
841 
842  /* If only the selected area should be saved, so only the complete
843  * nodes should be saved, this means the first and n-th node
844  * partly, the 2nd till n-1 node complete. (complete means with
845  * all formats!)
846  */
847  m_bWriteAll = bSaveWriteAll ||
848  nPos != m_pCurrentPam->GetMark()->nNode.GetIndex();
849  m_bFirstLine = false;
850  m_bOutFooter = false; // after one node no footer anymore
851  }
852 
853  ChangeParaToken( HtmlTokenId::NONE ); // MIB 8.7.97: We're doing it here and not at the caller
854  OutAndSetDefList( 0 );
855 
856  } while( CopyNextPam( &pPam ) ); // until all PaM's processed
857 
858  m_bWriteAll = bSaveWriteAll; // reset to old values
859 }
860 
861 // write the StyleTable, general data, header/footer/footnotes
862 static void OutBodyColor( const sal_Char* pTag, const SwFormat *pFormat,
863  SwHTMLWriter& rHWrt )
864 {
865  const SwFormat *pRefFormat = nullptr;
866 
867  if( rHWrt.m_xTemplate.is() )
868  pRefFormat = SwHTMLWriter::GetTemplateFormat( pFormat->GetPoolFormatId(),
869  &rHWrt.m_xTemplate->getIDocumentStylePoolAccess() );
870 
871  const SvxColorItem *pColorItem = nullptr;
872 
873  const SfxItemSet& rItemSet = pFormat->GetAttrSet();
874  const SfxPoolItem *pRefItem = nullptr, *pItem = nullptr;
875  bool bItemSet = SfxItemState::SET == rItemSet.GetItemState( RES_CHRATR_COLOR,
876  true, &pItem);
877  bool bRefItemSet = pRefFormat &&
878  SfxItemState::SET == pRefFormat->GetAttrSet().GetItemState( RES_CHRATR_COLOR,
879  true, &pRefItem);
880  if( bItemSet )
881  {
882  // only when the item is set in the template of the current document
883  // or has a different value as the in HTML template, it will be set
884  const SvxColorItem *pCItem = static_cast<const SvxColorItem*>(pItem);
885 
886  if( !bRefItemSet )
887  {
888  pColorItem = pCItem;
889  }
890  else
891  {
892  Color aColor( pCItem->GetValue() );
893  if( COL_AUTO == aColor )
894  aColor = COL_BLACK;
895 
896  Color aRefColor( static_cast<const SvxColorItem*>(pRefItem)->GetValue() );
897  if( COL_AUTO == aRefColor )
898  aRefColor = COL_BLACK;
899 
900  if( !aColor.IsRGBEqual( aRefColor ) )
901  pColorItem = pCItem;
902  }
903  }
904  else if( bRefItemSet )
905  {
906  // The item was still set in the HTML template so we output the default
907  pColorItem = &rItemSet.GetPool()->GetDefaultItem( RES_CHRATR_COLOR );
908  }
909 
910  if( pColorItem )
911  {
912  OStringBuffer sOut;
913  sOut.append(" " + OString(pTag) + "=");
914  rHWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
915  Color aColor( pColorItem->GetValue() );
916  if( COL_AUTO == aColor )
917  aColor = COL_BLACK;
918  HTMLOutFuncs::Out_Color( rHWrt.Strm(), aColor );
919  if( RES_POOLCOLL_STANDARD==pFormat->GetPoolFormatId() )
920  rHWrt.m_xDfltColor = aColor;
921  }
922 }
923 
925 {
926  sal_uLong nIdx = m_pCurrentPam->GetPoint()->nNode.GetIndex();
927  sal_uLong nEndIdx = m_pCurrentPam->GetMark()->nNode.GetIndex();
928 
929  SwTextNode *pTextNd = nullptr;
930  while( nIdx<=nEndIdx &&
931  nullptr==(pTextNd=m_pDoc->GetNodes()[nIdx]->GetTextNode()) )
932  nIdx++;
933 
934  OSL_ENSURE( pTextNd, "No Text-Node found" );
935  if( !pTextNd || !pTextNd->HasHints() )
936  return 0;
937 
938  sal_uInt16 nAttrs = 0;
939  const size_t nCntAttr = pTextNd->GetSwpHints().Count();
940  sal_Int32 nOldPos = 0;
941  for( size_t i=0; i<nCntAttr; ++i )
942  {
943  const SwTextAttr *pHt = pTextNd->GetSwpHints().Get(i);
944  if( !pHt->End() )
945  {
946  sal_Int32 nPos = pHt->GetStart();
947  if( nPos-nOldPos > 1
948  || ( pHt->Which() != RES_TXTATR_FIELD
949  && pHt->Which() != RES_TXTATR_ANNOTATION ) )
950  break;
951 
952  const SwFieldIds nFieldWhich =
953  static_cast<const SwFormatField&>(pHt->GetAttr()).GetField()->GetTyp()->Which();
954  if( SwFieldIds::Postit!=nFieldWhich &&
955  SwFieldIds::Script!=nFieldWhich )
956  break;
957 
958  OutNewLine();
959  OutHTML_SwFormatField( *this, pHt->GetAttr() );
960  nOldPos = nPos;
961  OSL_ENSURE( nAttrs<SAL_MAX_UINT16, "Too many attributes" );
962  nAttrs++;
963  }
964  }
965 
966  return nAttrs;
967 }
968 
969 const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
970 {
971  OStringBuffer sOut;
972  if (!mbSkipHeaderFooter)
973  {
974  if (mbXHTML)
976  else
978  HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() ); // No GetNamespace() here.
979 
980  // build prelude
981  OutNewLine();
983 
984  OutNewLine();
986 
987  IncIndentLevel(); // indent content of <HEAD>
988 
989  // DocumentInfo
990  OString sIndent = GetIndentString();
991 
992  uno::Reference<document::XDocumentProperties> xDocProps;
993  SwDocShell *pDocShell(m_pDoc->GetDocShell());
994  if (pDocShell)
995  {
996  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
997  pDocShell->GetModel(), uno::UNO_QUERY_THROW);
998  xDocProps.set(xDPS->getDocumentProperties());
999  }
1000 
1001  // xDocProps may be null here (when copying)
1003  sIndent.getStr(), m_eDestEnc,
1005 
1006  // comments and meta-tags of first paragraph
1007  rHeaderAttrs = OutHeaderAttrs();
1008 
1010  }
1011 
1012  const SwPageDesc *pPageDesc = nullptr;
1013 
1014  // In none HTML documents the first set template will be exported
1015  // and if none is set the default template
1016  sal_uLong nNodeIdx = m_pCurrentPam->GetPoint()->nNode.GetIndex();
1017 
1018  while( nNodeIdx < m_pDoc->GetNodes().Count() )
1019  {
1020  SwNode *pNd = m_pDoc->GetNodes()[ nNodeIdx ];
1021  if( pNd->IsContentNode() )
1022  {
1023  pPageDesc = static_cast<const SwFormatPageDesc &>(pNd->GetContentNode()
1024  ->GetAttr(RES_PAGEDESC)).GetPageDesc();
1025  break;
1026  }
1027  else if( pNd->IsTableNode() )
1028  {
1029  pPageDesc = pNd->GetTableNode()->GetTable().GetFrameFormat()
1030  ->GetPageDesc().GetPageDesc();
1031  break;
1032  }
1033 
1034  nNodeIdx++;
1035  }
1036 
1037  if( !pPageDesc )
1038  pPageDesc = &m_pDoc->GetPageDesc( 0 );
1039 
1040  if (!mbSkipHeaderFooter)
1041  {
1042  // and now ... the style sheet!!!
1043  if( m_bCfgOutStyles )
1044  {
1045  OutStyleSheet( *pPageDesc );
1046  }
1047 
1048  // and now ... the BASIC and JavaScript!
1049  if( m_pDoc->GetDocShell() ) // only with DocShell BASIC is possible
1050  OutBasic();
1051 
1052  DecIndentLevel(); // indent content of <HEAD>
1053  OutNewLine();
1055 
1056  // the body won't be indented, because then everything would be indented!
1057  OutNewLine();
1058  sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_body);
1059  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1060 
1061  // language
1062  OutLanguage( m_eLang );
1063 
1064  // output text colour, when it was set in the default template or was changed
1067  *this );
1068 
1069  // colour of (un)visited links
1072  *this );
1075  *this );
1076 
1077  const SfxItemSet& rItemSet = pPageDesc->GetMaster().GetAttrSet();
1078 
1079  // fdo#86857 page styles now contain the XATTR_*, not RES_BACKGROUND
1080  std::shared_ptr<SvxBrushItem> const aBrushItem(getSvxBrushItemFromSourceSet(rItemSet, RES_BACKGROUND));
1081  OutBackground(aBrushItem.get(), true);
1082 
1083  m_nDirection = GetHTMLDirection( rItemSet );
1084  OutDirection( m_nDirection );
1085 
1086  if( m_bCfgOutStyles )
1087  {
1088  OutCSS1_BodyTagStyleOpt( *this, rItemSet );
1089  }
1090  // append events
1091  if( m_pDoc->GetDocShell() ) // only with DocShell BASIC is possible
1093 
1094  Strm().WriteChar( '>' );
1095  }
1096  else if (mbReqIF)
1097  // ReqIF: start xhtml.BlkStruct.class.
1099 
1100  return pPageDesc;
1101 }
1102 
1103 void SwHTMLWriter::OutAnchor( const OUString& rName )
1104 {
1105  OStringBuffer sOut;
1106  sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor " ");
1107  if (!mbXHTML)
1108  {
1109  sOut.append(OOO_STRING_SVTOOLS_HTML_O_name "=\"");
1110  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1112  }
1113  else
1114  {
1115  // XHTML wants 'id' instead of 'name', also the value can't contain
1116  // spaces.
1117  sOut.append(OOO_STRING_SVTOOLS_HTML_O_id "=\"");
1118  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1119  HTMLOutFuncs::Out_String( Strm(), rName.replace(' ', '_'), m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
1120  }
1122 }
1123 
1125 {
1126  // fetch current bookmark
1127  const ::sw::mark::IMark* pBookmark = nullptr;
1128  IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess();
1129  if(m_nBkmkTabPos != -1)
1130  pBookmark = pMarkAccess->getAllMarksBegin()[m_nBkmkTabPos];
1131  // Output all bookmarks in this paragraph. The content position
1132  // for the moment isn't considered!
1133  sal_uInt32 nNode = m_pCurrentPam->GetPoint()->nNode.GetIndex();
1134  while( m_nBkmkTabPos != -1
1135  && pBookmark->GetMarkPos().nNode.GetIndex() == nNode )
1136  {
1137  // The area of bookmarks is first ignored, because it's not read.
1138 
1139  // first the SWG specific data:
1140  if ( dynamic_cast< const ::sw::mark::IBookmark* >(pBookmark) && !pBookmark->GetName().isEmpty() )
1141  {
1142  OutAnchor( pBookmark->GetName() );
1143  }
1144 
1145  if( ++m_nBkmkTabPos >= pMarkAccess->getAllMarksCount() )
1146  m_nBkmkTabPos = -1;
1147  else
1148  pBookmark = pMarkAccess->getAllMarksBegin()[m_nBkmkTabPos];
1149  }
1150 
1151  decltype(m_aOutlineMarkPoss)::size_type nPos;
1152  for( nPos = 0; nPos < m_aOutlineMarkPoss.size() &&
1153  m_aOutlineMarkPoss[nPos] < nNode; nPos++ )
1154  ;
1155 
1156  while( nPos < m_aOutlineMarkPoss.size() && m_aOutlineMarkPoss[nPos] == nNode )
1157  {
1158  OUString sMark( m_aOutlineMarks[nPos] );
1159  OutAnchor( sMark.replace('?', '_') ); // '?' causes problems in IE/Netscape 5
1160  m_aOutlineMarkPoss.erase( m_aOutlineMarkPoss.begin()+nPos );
1161  m_aOutlineMarks.erase( m_aOutlineMarks.begin() + nPos );
1162  }
1163 }
1164 
1166 {
1167  // "point" fieldmarks that occupy single character space, as opposed to
1168  // range fieldmarks that are associated with start and end points.
1169 
1170  const IDocumentMarkAccess* pMarkAccess = m_pDoc->getIDocumentMarkAccess();
1171  if (!pMarkAccess)
1172  return;
1173 
1174  const sw::mark::IFieldmark* pMark = pMarkAccess->getFieldmarkFor(rPos);
1175  if (!pMark)
1176  return;
1177 
1178  if (pMark->GetFieldname() == ODF_FORMCHECKBOX)
1179  {
1180  const sw::mark::ICheckboxFieldmark* pCheckBox =
1181  dynamic_cast<const sw::mark::ICheckboxFieldmark*>(pMark);
1182 
1183  if (pCheckBox)
1184  {
1185  OString aOut("<");
1187  aOut += " ";
1189  aOut += "=\"";
1191  aOut += "\"";
1192 
1193  if (pCheckBox->IsChecked())
1194  {
1195  aOut += " ";
1197  aOut += "=\"";
1199  aOut += "\"";
1200  }
1201 
1202  aOut += "/>";
1203  Strm().WriteCharPtr(aOut.getStr());
1204  }
1205  }
1206 
1207  // TODO : Handle other single-point fieldmark types here (if any).
1208 }
1209 
1210 void SwHTMLWriter::OutImplicitMark( const OUString& rMark,
1211  const sal_Char *pMarkType )
1212 {
1213  if( !rMark.isEmpty() && !m_aImplicitMarks.empty() )
1214  {
1215  OUString sMark(rMark + OUStringLiteral1(cMarkSeparator) + OUString::createFromAscii(pMarkType));
1216  if( 0 != m_aImplicitMarks.erase( sMark ) )
1217  {
1218  OutAnchor(sMark.replace('?', '_')); // '?' causes problems in IE/Netscape 5
1219  }
1220  }
1221 }
1222 
1223 OUString SwHTMLWriter::convertHyperlinkHRefValue(const OUString& rURL)
1224 {
1225  OUString sURL(rURL);
1226  sal_Int32 nPos = sURL.lastIndexOf(cMarkSeparator);
1227  if (nPos != -1)
1228  {
1229  OUString sCompare = sURL.copy(nPos + 1).replaceAll(" ", "");
1230  if (!sCompare.isEmpty())
1231  {
1232  sCompare = sCompare.toAsciiLowerCase();
1233  if( sCompare == "region" || sCompare == "frame" ||
1234  sCompare == "graphic" || sCompare == "ole" ||
1235  sCompare == "table" || sCompare == "outline" ||
1236  sCompare == "text" )
1237  {
1238  sURL = sURL.replace( '?', '_' ); // '?' causes problems in IE/Netscape 5
1239  }
1240  }
1241  }
1242  else if (!sURL.isEmpty() && sURL[0] != '#')
1243  {
1244  // Link is not started from "#", so looks like external link. Encode this URL.
1245  INetURLObject aURL(sURL);
1247  }
1249 }
1250 
1251 void SwHTMLWriter::OutHyperlinkHRefValue( const OUString& rURL )
1252 {
1253  OUString sURL = convertHyperlinkHRefValue(rURL);
1255 }
1256 
1257 void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic )
1258 {
1259  const Color &rBackColor = pBrushItem->GetColor();
1262  if( rBackColor != COL_TRANSPARENT )
1263  {
1264  OStringBuffer sOut;
1265  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append('=');
1266  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1267  HTMLOutFuncs::Out_Color( Strm(), rBackColor);
1268  }
1269 
1270  if( !bGraphic )
1271  return;
1272 
1273  OUString aGraphicInBase64;
1274  const Graphic* pGrf = pBrushItem->GetGraphic();
1275  OUString GraphicURL = pBrushItem->GetGraphicLink();
1276  if( mbEmbedImages || GraphicURL.isEmpty())
1277  {
1278  if( pGrf )
1279  {
1280  if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
1281  {
1283  }
1287  }
1288  }
1289  else
1290  {
1291  if( m_bCfgCpyLinkedGrfs )
1292  {
1293  CopyLocalFileToINet( GraphicURL );
1294  }
1295  OUString s( URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), GraphicURL));
1298  Strm().WriteCharPtr("\"");
1299 
1300  }
1301 }
1302 
1303 void SwHTMLWriter::OutBackground( const SfxItemSet& rItemSet, bool bGraphic )
1304 {
1305  const SfxPoolItem* pItem;
1306  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
1307  &pItem ))
1308  {
1309  OutBackground( static_cast<const SvxBrushItem*>(pItem), bGraphic );
1310  }
1311 }
1312 
1313 sal_uInt16 SwHTMLWriter::GetLangWhichIdFromScript( sal_uInt16 nScript )
1314 {
1315  sal_uInt16 nWhichId;
1316  switch( nScript )
1317  {
1318  case CSS1_OUTMODE_CJK:
1319  nWhichId = RES_CHRATR_CJK_LANGUAGE;
1320  break;
1321  case CSS1_OUTMODE_CTL:
1322  nWhichId = RES_CHRATR_CJK_LANGUAGE;
1323  break;
1324  default:
1325  nWhichId = RES_CHRATR_LANGUAGE;
1326  break;
1327  }
1328  return nWhichId;
1329 }
1330 
1332 {
1333  // ReqIF mode: consumers would ignore language anyway.
1334  if (LANGUAGE_DONTKNOW != nLang && !mbReqIF)
1335  {
1336  OStringBuffer sOut;
1337  sOut.append(' ');
1338  if (mbXHTML)
1339  sOut.append(OOO_STRING_SVTOOLS_XHTML_O_lang);
1340  else
1341  sOut.append(OOO_STRING_SVTOOLS_HTML_O_lang);
1342  sOut.append("=\"");
1343  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1346  }
1347 }
1348 
1350 {
1351  return GetHTMLDirection( rItemSet.Get( RES_FRAMEDIR ).GetValue() );
1352 }
1353 
1355 {
1356  switch( nDir )
1357  {
1358  case SvxFrameDirection::Vertical_LR_TB:
1359  nDir = SvxFrameDirection::Horizontal_LR_TB;
1360  break;
1361  case SvxFrameDirection::Vertical_RL_TB:
1362  nDir = SvxFrameDirection::Horizontal_RL_TB;
1363  break;
1364  case SvxFrameDirection::Environment:
1365  nDir = m_nDirection;
1366  break;
1367  default: break;
1368  }
1369 
1370  return nDir;
1371 }
1372 
1374 {
1375  OString sConverted = convertDirection(nDir);
1376  if (!sConverted.isEmpty())
1377  {
1378  OStringBuffer sOut;
1379  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_dir)
1380  .append("=\"").append(sConverted).append('\"');
1381  Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
1382  }
1383 }
1384 
1386 {
1387  OString sConverted;
1388  switch (nDir)
1389  {
1390  case SvxFrameDirection::Horizontal_LR_TB:
1391  case SvxFrameDirection::Vertical_LR_TB:
1392  sConverted = "ltr";
1393  break;
1394  case SvxFrameDirection::Horizontal_RL_TB:
1395  case SvxFrameDirection::Vertical_RL_TB:
1396  sConverted = "rtl";
1397  break;
1398  default: break;
1399  }
1400  return sConverted;
1401 }
1402 
1403 OString SwHTMLWriter::GetIndentString(sal_uInt16 nIncLvl)
1404 {
1405  OString sRet;
1406 
1407  // somewhat cumbersome, but we have only one indent string!
1408  sal_uInt16 nLevel = m_nIndentLvl + nIncLvl;
1409 
1410  if( nLevel && nLevel <= MAX_INDENT_LEVEL)
1411  {
1412  sIndentTabs[nLevel] = 0;
1413  sRet = sIndentTabs;
1414  sIndentTabs[nLevel] = '\t';
1415  }
1416 
1417  return sRet;
1418 }
1419 
1420 void SwHTMLWriter::OutNewLine( bool bCheck )
1421 {
1422  if( !bCheck || (Strm().Tell()-m_nLastLFPos) > m_nIndentLvl )
1423  {
1425  m_nLastLFPos = Strm().Tell();
1426  }
1427 
1429  {
1432  sIndentTabs[m_nIndentLvl] = '\t';
1433  }
1434 }
1435 
1436 sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
1437 {
1438  sal_uInt16 nSize = 1;
1439  for( sal_uInt16 i=6; i>0; i-- )
1440  {
1441  if( nHeight > (m_aFontHeights[i] + m_aFontHeights[i-1])/2 )
1442  {
1443  nSize = i+1;
1444  break;
1445  }
1446  }
1447 
1448  return nSize;
1449 }
1450 
1451 // Paragraphs with Table of Contents and other index styles will be typeset with
1452 // dot leaders at the position of the last tabulator in PrintLayout (CSS2) mode
1453 sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rStr )
1454 {
1455  if (m_bCfgPrintLayout && ((nPoolId >= RES_POOLCOLL_TOX_CNTNT1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT5) ||
1456  (nPoolId >= RES_POOLCOLL_TOX_IDX1 && nPoolId <= RES_POOLCOLL_TOX_IDX3) ||
1457  (nPoolId >= RES_POOLCOLL_TOX_USER1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT10) ||
1458  nPoolId == RES_POOLCOLL_TOX_ILLUS1 || nPoolId == RES_POOLCOLL_TOX_TABLES1 ||
1459  nPoolId == RES_POOLCOLL_TOX_OBJECT1 ||
1460  (nPoolId >= RES_POOLCOLL_TOX_AUTHORITIES1 && nPoolId <= RES_POOLCOLL_TOX_USER10))) {
1461  sal_Int32 i = rStr.lastIndexOf('\t');
1462  // there are only ASCII (Latin-1) characters after the tabulator
1463  if (i > -1 && OUStringToOString(rStr.copy(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
1464  return i;
1465  }
1466  return -1;
1467 }
1468 
1470 {
1471  if (maNamespace.isEmpty())
1472  return OString();
1473 
1474  return maNamespace + ":";
1475 }
1476 
1477 // Structure caches the current data of the writer to output a
1478 // other part of the document, like e.g. header/footer
1480  sal_uLong nEnd, bool bSaveNum,
1481  const SwFrameFormat *pFrameFormat)
1482  : rWrt(rWriter)
1483  , pOldPam(rWrt.m_pCurrentPam)
1484  , pOldEnd(rWrt.GetEndPaM())
1485  , nOldDefListLvl(rWrt.m_nDefListLvl)
1486  , nOldDirection(rWrt.m_nDirection)
1487  , bOldOutHeader(rWrt.m_bOutHeader)
1488  , bOldOutFooter(rWrt.m_bOutFooter)
1489  , bOldOutFlyFrame(rWrt.m_bOutFlyFrame)
1490 {
1492 
1494 
1495  // recognize table in special areas
1496  if( nStt != rWrt.m_pCurrentPam->GetMark()->nNode.GetIndex() )
1497  {
1498  const SwNode *pNd = rWrt.m_pDoc->GetNodes()[ nStt ];
1499  if( pNd->IsTableNode() || pNd->IsSectionNode() )
1500  rWrt.m_pCurrentPam->GetMark()->nNode = nStt;
1501  }
1502 
1503  rWrt.SetEndPaM( rWrt.m_pCurrentPam.get() );
1504  rWrt.m_pCurrentPam->Exchange( );
1505  rWrt.m_bWriteAll = true;
1506  rWrt.m_nDefListLvl = 0;
1507  rWrt.m_bOutHeader = rWrt.m_bOutFooter = false;
1508 
1509  // Maybe save the current numbering information, so that it can be started again.
1510  // Only then also the numbering information of the next paragraph will be valid.
1511  if( bSaveNum )
1512  {
1515  }
1516  else
1517  {
1519  }
1520 
1521  // The numbering will be in any case interrupted.
1522  rWrt.GetNumInfo().Clear();
1523 
1524  if( pFrameFormat )
1525  rWrt.m_nDirection = rWrt.GetHTMLDirection( pFrameFormat->GetAttrSet() );
1526 }
1527 
1529 {
1530  rWrt.m_pCurrentPam.reset(); // delete PaM again
1531 
1533  rWrt.SetEndPaM( pOldEnd );
1535  rWrt.m_nBkmkTabPos = bOldWriteAll ? rWrt.FindPos_Bkmk( *pOldPam->GetPoint() ) : -1;
1536  rWrt.m_nLastParaToken = HtmlTokenId::NONE;
1542 
1543  // Maybe continue the numbering from before section. The numbering
1544  // of the next paragraph will be invalid in any case.
1545  if( pOldNumRuleInfo )
1546  {
1548  pOldNumRuleInfo.reset();
1549  rWrt.SetNextNumInfo( std::move(pOldNextNumRuleInfo) );
1550  }
1551  else
1552  {
1553  rWrt.GetNumInfo().Clear();
1555  }
1556 }
1557 
1558 void GetHTMLWriter( const OUString& rFilterOptions, const OUString& rBaseURL, WriterRef& xRet )
1559 {
1560  xRet = new SwHTMLWriter( rBaseURL, rFilterOptions );
1561 }
1562 
1563 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:960
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
bool m_bCfgFormFeed
Definition: wrthtml.hxx:341
Starts a section of nodes in the document model.
Definition: node.hxx:303
bool m_bCfgCpyLinkedGrfs
Definition: wrthtml.hxx:343
std::unique_ptr< SwHTMLPosFlyFrames > m_pHTMLPosFlyFrames
Definition: wrthtml.hxx:258
sal_uLong GetIndex() const
Definition: node.hxx:282
FieldUnit
const OUString & GetBaseURL() const
Definition: shellio.hxx:439
SwHTMLNumRuleInfo & GetNumInfo()
Definition: wrthtml.hxx:525
#define RES_COL
Definition: hintids.hxx:214
sal_uLong Count() const
Definition: ndarr.hxx:143
bool mbXHTML
If XHTML markup should be written instead of HTML.
Definition: wrthtml.hxx:394
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
Marks a position in the document model.
Definition: pam.hxx:35
static void lcl_html_OutSectionEndTag(SwHTMLWriter &rHTMLWrt)
Definition: wrthtml.cxx:693
std::vector< OUString > m_aImgMapNames
Definition: wrthtml.hxx:279
bool m_bPreserveForm
Definition: wrthtml.hxx:383
HTMLControls m_aHTMLControls
Definition: wrthtml.hxx:286
void OutBasicBodyEvents()
Definition: htmlbas.cxx:310
bool IsSectionNode() const
Definition: node.hxx:644
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
#define RES_HEADER
Definition: hintids.hxx:201
bool IsGrfNode() const
Definition: node.hxx:656
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars=nullptr)
static sal_Char sIndentTabs[MAX_INDENT_LEVEL+2]
Definition: wrthtml.cxx:91
sal_Int32 m_nDfltRightMargin
Definition: wrthtml.hxx:317
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:673
SwPaM * pOldEnd
Definition: wrthtml.hxx:629
bool m_bClearLeft
Definition: wrthtml.hxx:377
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
static bool GraphicToBase64(const Graphic &rGraphic, OUString &rOUString, bool bAddPrefix=true, ConvertDataFormat aTargetFormat=ConvertDataFormat::Unknown)
#define OOO_STRING_SVTOOLS_HTML_IT_checkbox
SwDocShell * GetDocShell()
Definition: doc.hxx:1341
sal_uInt32 m_nLastLFPos
Definition: wrthtml.hxx:307
short m_nDfltFirstLineIndent
Definition: wrthtml.hxx:319
std::string GetValue
Writer & OutCSS1_BodyTagStyleOpt(Writer &rWrt, const SfxItemSet &rItemSet)
Definition: css1atr.cxx:1791
std::vector< OUString > m_aOutlineMarks
Definition: wrthtml.hxx:284
sal_uInt16 m_nTextAttrsToIgnore
Definition: wrthtml.hxx:327
#define OOO_STRING_SVTOOLS_HTML_O_bgcolor
sal_uInt16 m_nExportMode
Definition: wrthtml.hxx:328
bool m_bFirstLine
Definition: wrthtml.hxx:347
void Set(const SwHTMLNumRuleInfo &rInf)
Definition: htmlnum.hxx:93
#define HTMLMODE_BORDER_NONE
Definition: wrthtml.hxx:124
static OUString convertToBcp47(LanguageType nLangID)
LanguageType m_eLang
Definition: wrthtml.hxx:335
sal_uIntPtr sal_uLong
#define RES_FRAMEDIR
Definition: hintids.hxx:225
void OutBookmarks()
Definition: wrthtml.cxx:1124
const sal_Unicode cTokenSeparator
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
std::shared_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack)
SwHTMLWriter & rWrt
Definition: wrthtml.hxx:627
SwHTMLFormatInfos m_TextCollInfos
Definition: wrthtml.hxx:288
#define OOO_STRING_SVTOOLS_HTML_O_dir
Provides access to the marks of a document.
Objects all levels.
Definition: poolfmt.hxx:401
#define ODF_FORMCHECKBOX
void DecIndentLevel()
Definition: wrthtml.hxx:498
Content 1st level.
Definition: poolfmt.hxx:375
OUString m_aNonConvertableCharacters
Definition: wrthtml.hxx:293
#define OOO_STRING_SVTOOLS_HTML_body
#define OOO_STRING_SVTOOLS_HTML_O_gutter
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:88
SvxFrameDirection
Writer & OutHTML_SwTextNode(Writer &rWrt, const SwContentNode &rNode)
Definition: htmlatr.cxx:2006
SwSectionFormat * GetFormat()
Definition: section.hxx:337
#define OOO_STRING_SVTOOLS_HTML_O_id
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1552
void OutImplicitMark(const OUString &rMark, const sal_Char *pMarkType)
Definition: wrthtml.cxx:1210
sal_Int32 m_nDefListMargin
Definition: wrthtml.hxx:325
sal_Int32 m_nLeftMargin
Definition: wrthtml.hxx:315
sal_uInt16 Which() const
Definition: txatbase.hxx:110
bool m_bFirstCSS1Property
Definition: wrthtml.hxx:369
#define OOO_STRING_SVTOOLS_HTML_O_background
OUString const & GetLinkFileName() const
Definition: section.cxx:548
Tables all levels.
Definition: poolfmt.hxx:405
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
bool m_bOutTable
Definition: wrthtml.hxx:361
SvStream & WriteCharPtr(const char *pBuf)
void OutHiddenForms()
Definition: htmlforw.cxx:346
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
OString maNamespace
XML namespace, in case of XHTML.
Definition: wrthtml.hxx:396
static SVT_DLLPUBLIC SvStream & Out_Color(SvStream &, const Color &, bool bXHTML=false)
const SwPageDesc * MakeHeader(sal_uInt16 &rHeaderAtrs)
Definition: wrthtml.cxx:969
#define CSS1_OUTMODE_CJK
Definition: wrthtml.hxx:180
Content 5th level.
Definition: poolfmt.hxx:379
ErrCode m_nWarn
Definition: wrthtml.hxx:306
static LanguageType nLang
Definition: srtdlg.cxx:60
#define OOO_STRING_SVTOOLS_HTML_O_text
void OutBackground(const SvxBrushItem *pBrushItem, bool bGraphic)
Definition: wrthtml.cxx:1257
const SwSection & GetSection() const
Definition: node.hxx:541
static OutputDevice * GetDefaultDevice()
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1420
bool m_bWriteAll
Definition: shellio.hxx:406
#define OOO_STRING_SVTOOLS_XHTML_O_lang
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
#define OOO_STRING_SVTOOLS_HTML_O_link
#define MAX_INDENT_LEVEL
Definition: wrthtml.cxx:87
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
bool m_bLFPossible
Definition: wrthtml.hxx:379
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, const OString &rStr, bool bOn=true)
sal_uInt16 const nOldDefListLvl
Definition: wrthtml.hxx:632
SwTableNode * GetTableNode()
Definition: node.hxx:599
bool mbReqIF
If the ReqIF subset of XHTML should be written.
Definition: wrthtml.hxx:398
bool m_bWriteOnlyFirstTable
Definition: shellio.hxx:409
void StartProgress(const char *pMessResId, long nStartValue, long nEndValue, SwDocShell *pDocShell)
Definition: mainwn.cxx:48
NONE
#define HTMLMODE_FLY_MARGINS
Definition: wrthtml.hxx:123
boost::optional< Color > m_xDfltColor
Definition: wrthtml.hxx:299
#define OOO_STRING_SVTOOLS_HTML_O_href
#define SAL_MAX_UINT16
void SetupFilterOptions(const OUString &rFilterOptions)
Definition: wrthtml.cxx:194
#define OOO_STRING_SVTOOLS_HTML_O_lang
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
std::set< OUString > m_aNumRuleNames
Definition: wrthtml.hxx:281
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:458
#define WARN_SWG_POOR_LOAD
Definition: swerror.h:40
char sal_Char
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:682
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
static const SwFormatCol * lcl_html_GetFormatCol(const SwSection &rSection, const SwSectionFormat &rFormat)
Definition: wrthtml.cxx:551
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
Reader * ReadHTML
Definition: fltini.cxx:65
#define HTMLMODE_NO_CONTROL_CENTERING
Definition: wrthtml.hxx:127
OString GetIndentString(sal_uInt16 nIncLvl=0)
Definition: wrthtml.cxx:1403
const SwTable & GetTable() const
Definition: node.hxx:497
std::unique_ptr< utl::TempFile > mpTempBaseURL
Temporary base URL for paste of images.
Definition: wrthtml.hxx:392
static void Out_DocInfo(SvStream &rStrm, const OUString &rBaseURL, const css::uno::Reference< css::document::XDocumentProperties > &, const sal_Char *pIndent, rtl_TextEncoding eDestEnc=RTL_TEXTENCODING_MS_1252, OUString *pNonConvertableChars=nullptr)
const Graphic * GetGraphic(OUString const &referer=OUString()) const
static void lcl_html_OutSectionStartTag(SwHTMLWriter &rHTMLWrt, const SwSection &rSection, const SwSectionFormat &rFormat, const SwFormatCol *pCol, bool bContinued=false)
Definition: wrthtml.cxx:594
bool mbSkipHeaderFooter
If HTML header and footer should be written as well, or just the content itself.
Definition: wrthtml.hxx:389
static SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
Authorities all levels.
Definition: poolfmt.hxx:409
#define HTML_CFG_WRITER
const sal_Unicode cDelim
bool m_bCfgPrintLayout
Definition: wrthtml.hxx:401
sal_uInt16 m_nFormCntrlCnt
Definition: wrthtml.hxx:312
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:567
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:143
void SetProgressState(long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:78
#define HTMLMODE_FONT_GENERIC
Definition: wrthtml.hxx:125
void ChangeParaToken(HtmlTokenId nNew)
Definition: htmlatr.cxx:164
bool IsOLENode() const
Definition: node.hxx:652
void SetBaseURL(const OUString &rURL)
Definition: shellio.hxx:394
Base class for various Writer styles.
Definition: format.hxx:43
static SvxHtmlOptions & Get()
#define OOO_STRING_SVTOOLS_HTML_O_data
std::unique_ptr< SwHTMLNumRuleInfo > pOldNumRuleInfo
Definition: wrthtml.hxx:630
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:164
std::set< OUString > m_aScriptTextStyles
Definition: wrthtml.hxx:283
#define RES_BACKGROUND
Definition: hintids.hxx:210
virtual const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
const Color & GetColor() const
short m_nFirstLineIndent
Definition: wrthtml.hxx:318
bool m_bWriteClipboardDoc
Definition: shellio.hxx:408
#define RES_CHRATR_COLOR
Definition: hintids.hxx:71
bool IsContentNode() const
Definition: node.hxx:628
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool CopyNextPam(SwPaM **)
Definition: writer.cxx:165
SwPaM * m_pOrigPam
Definition: shellio.hxx:404
#define OOO_STRING_SVTOOLS_HTML_doctype
static void OutBodyColor(const sal_Char *pTag, const SwFormat *pFormat, SwHTMLWriter &rHWrt)
Definition: wrthtml.cxx:862
void OutLanguage(LanguageType eLang)
Definition: wrthtml.cxx:1331
#define OOO_STRING_SVTOOLS_HTML_html
virtual bool IsChecked() const =0
SvtScriptType
Style of a layout element.
Definition: frmfmt.hxx:57
FieldUnit m_eCSS1Unit
Definition: wrthtml.hxx:263
size_t Count() const
Definition: ndhints.hxx:142
bool m_bCfgStarBasic
Definition: wrthtml.hxx:342
rtl_TextEncoding m_eDestEnc
Definition: wrthtml.hxx:334
#define SW_MOD()
Definition: swmodule.hxx:256
sal_Int32 m_nWhishLineLen
Definition: wrthtml.hxx:323
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
css::uno::Reference< css::container::XIndexContainer > mxFormComps
Definition: wrthtml.hxx:296
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::shared_ptr< SwUnoCursor > pOldPam
Definition: wrthtml.hxx:628
Internet visited.
Definition: poolfmt.hxx:122
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const OUString & GetSectionName() const
Definition: section.hxx:169
#define HTMLMODE_FLOAT_FRAME
Definition: wrthtml.hxx:115
std::vector< SwTextFormatColl * >::size_type size_type
Definition: docary.hxx:70
sal_uInt16 m_nHeaderFooterSpace
Definition: wrthtml.hxx:326
Writer & OutHTML_SwTableNode(Writer &rWrt, SwTableNode &rNode, const SwFrameFormat *pFlyFrameFormat, const OUString *pCaption, bool bTopCaption)
Definition: htmltabw.cxx:861
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:876
#define OOO_STRING_SVTOOLS_HTML_O_vlink
void OutBasic()
Definition: htmlbas.cxx:253
Count
sal_uInt16 GetGutterWidth(bool bMin=false) const
Definition: atrfrm.cxx:896
int i
sal_uInt32 m_nHTMLMode
Definition: wrthtml.hxx:261
SwContentNode * GetContentNode()
Definition: node.hxx:615
SwFieldIds
Definition: fldbas.hxx:38
HTMLMODE_ON
void SetNextNumInfo(std::unique_ptr< SwHTMLNumRuleInfo > pNxt)
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
Internet normal.
Definition: poolfmt.hxx:121
static const SwFormat * GetTemplateFormat(sal_uInt16 nPoolId, IDocumentStylePoolAccess *pTemplate)
Definition: css1atr.cxx:962
sal_Int32 m_nBkmkTabPos
Definition: wrthtml.hxx:310
sal_uInt32 m_aFontHeights[7]
Definition: wrthtml.hxx:304
#define HTML_CFG_MSIE
void OutCSS1_SectionFormatOptions(const SwFrameFormat &rFrameFormat, const SwFormatCol *pCol)
Definition: css1atr.cxx:2116
#define OOO_STRING_SVTOOLS_HTML_O_name
bool m_bCSS1IgnoreFirstPageDesc
Definition: wrthtml.hxx:372
OUString m_aBulletGrfs[MAXLEVEL]
Definition: wrthtml.hxx:294
#define LANGUAGE_DONTKNOW
bool m_bCfgNetscape4
Definition: wrthtml.hxx:385
SfxItemSet * GetItemSet() const
#define HTMLMODE_PRINT_EXT
Definition: wrthtml.hxx:120
sal_uInt16 GetHTMLFontSize(sal_uInt32 nFontHeight) const
Definition: wrthtml.cxx:1436
void GetControls()
Definition: htmlforw.cxx:1318
sal_uInt16 m_nDfltBottomMargin
Definition: wrthtml.hxx:321
Marks a node in the document model.
Definition: ndindex.hxx:31
void GetHTMLWriter(const OUString &rFilterOptions, const OUString &rBaseURL, WriterRef &xRet)
Definition: wrthtml.cxx:1558
bool mbEmbedImages
Definition: wrthtml.hxx:390
SwpHints & GetSwpHints()
getters for SwpHints
Definition: ndtxt.hxx:809
void SetStream(SvStream *const pStream)
Definition: writer.cxx:224
void OutStyleSheet(const SwPageDesc &rPageDesc)
Definition: css1atr.cxx:499
HTMLSaveData(SwHTMLWriter &, sal_uLong nStt, sal_uLong nEnd, bool bSaveNum=true, const SwFrameFormat *pFrameFormat=nullptr)
Definition: wrthtml.cxx:1479
bool bOldWriteAll
Definition: wrthtml.hxx:634
sal_uInt16 m_nEndNote
Definition: wrthtml.hxx:313
virtual ~SwHTMLWriter() override
Definition: wrthtml.cxx:170
SwNodeIndex * m_pStartNdIdx
Definition: wrthtml.hxx:300
bool m_bOutFooter
Definition: wrthtml.hxx:363
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:137
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
sal_uInt16 m_nIndentLvl
Definition: wrthtml.hxx:322
SfxItemPool * GetPool() const
ErrCode WriteStream() override
Definition: wrthtml.cxx:230
void Out_SwDoc(SwPaM *)
Definition: wrthtml.cxx:791
bool const bOldOutFlyFrame
Definition: wrthtml.hxx:637
Illustrations all levels.
Definition: poolfmt.hxx:397
const SwFormatFootnote * m_pFormatFootnote
Definition: wrthtml.hxx:302
static bool lcl_html_IsMultiColEnd(const SwHTMLWriter &rHTMLWrt, sal_uLong nIndex)
Definition: wrthtml.cxx:583
void ClearNextNumInfo()
HtmlTokenId
std::set< OUString > m_aScriptParaStyles
Definition: wrthtml.hxx:282
Point LogicToPixel(const Point &rLogicPt) const
#define RES_FOOTER
Definition: hintids.hxx:202
static Writer & OutHTML_Section(Writer &rWrt, const SwSectionNode &rSectNd)
Definition: wrthtml.cxx:702
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
bool m_bClearRight
Definition: wrthtml.hxx:378
const OUString & GetGraphicLink() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
std::set< OUString > m_aImplicitMarks
Definition: wrthtml.hxx:280
#define OOO_STRING_SVTOOLS_HTML_division
sal_uInt16 m_nCSS1OutMode
Definition: wrthtml.hxx:329
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:216
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
Writer & OutHTML_SwFormatField(Writer &rWrt, const SfxPoolItem &rHt)
Definition: htmlfldw.cxx:445
#define RES_TXTATR_FIELD
Definition: hintids.hxx:150
bool m_bFirstCSS1Rule
Definition: wrthtml.hxx:368
bool const bOldOutHeader
Definition: wrthtml.hxx:635
static std::shared_ptr< SwUnoCursor > NewUnoCursor(SwDoc &rDoc, sal_uLong const nStartIdx, sal_uLong const nEndIdx)
Definition: writer.cxx:194
static SVT_DLLPUBLIC OString ConvertStringToHTML(const OUString &sSrc, rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars)
#define HTMLMODE_ABS_POS_FLY
Definition: wrthtml.hxx:121
std::unique_ptr< std::vector< SwTextFootnote * > > m_pFootEndNotes
Definition: wrthtml.hxx:290
HTMLMODE_SOME_STYLES
virtual sal_Int32 getAllMarksCount() const =0
returns the number of marks.
bool m_bOutHeader
Definition: wrthtml.hxx:362
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define ERRCODE_NONE
#define HTMLMODE_LSPACE_IN_NUMBUL
Definition: wrthtml.hxx:118
rtl::Reference< SwDoc > m_xTemplate
Definition: wrthtml.hxx:298
void OutForm(bool bTagOn=true, const SwStartNode *pStNd=nullptr)
Definition: htmlforw.cxx:233
#define HTML_CFG_NS40
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
void IncIndentLevel()
Definition: wrthtml.hxx:494
#define CSS1_OUTMODE_WESTERN
Definition: wrthtml.hxx:178
#define RES_TXTATR_ANNOTATION
Definition: hintids.hxx:153
void OutFootEndNotes()
Definition: htmlftn.cxx:305
void CollectFlyFrames()
#define OOO_STRING_SVTOOLS_HTML_doctype40
LanguageType GetAppLanguage()
Definition: init.cxx:765
#define OOO_STRING_SVTOOLS_XHTML_doctype11
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:208
SwNodes & GetNodes()
Definition: doc.hxx:402
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
#define HTMLMODE_BLOCK_SPACER
Definition: wrthtml.hxx:114
SvxFrameDirection GetHTMLDirection(SvxFrameDirection nDir) const
Definition: wrthtml.cxx:1354
const SwPageDesc * m_pCurrPageDesc
Definition: wrthtml.hxx:301
void SetEndPaM(SwPaM *pPam)
Definition: wrthtml.hxx:512
Content 10th level.
Definition: poolfmt.hxx:393
const sal_Int32 * End() const
Definition: txatbase.hxx:148
sal_uInt64 Tell() const
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
Definition: wrthtml.cxx:1469
void OutHyperlinkHRefValue(const OUString &rURL)
Definition: wrthtml.cxx:1251
std::unique_ptr< SwHTMLNumRuleInfo > pOldNextNumRuleInfo
Definition: wrthtml.hxx:631
Writer & OutHTML_HeaderFooter(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bHeader)
#define HTMLMODE_NBSP_IN_TABLES
Definition: wrthtml.hxx:117
sal_uInt16 m_nDfltTopMargin
Definition: wrthtml.hxx:320
SvStream & WriteChar(char nChar)
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
sal_uInt16 m_nFootNote
Definition: wrthtml.hxx:314
IDocumentStylePoolAccess & getIDocumentStylePoolAccess()
Definition: writer.cxx:141
static bool lcl_html_IsMultiColStart(const SwHTMLWriter &rHTMLWrt, sal_uLong nIndex)
Definition: wrthtml.cxx:567
sal_Int32 FindPos_Bkmk(const SwPosition &rPos) const
Definition: writer.cxx:184
bool m_bCfgPreferStyles
Definition: wrthtml.hxx:340
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:196
std::shared_ptr< SwUnoCursor > m_pCurrentPam
Definition: shellio.hxx:405
#define OOO_STRING_SVTOOLS_HTML_input
void OutAnchor(const OUString &rName)
Definition: wrthtml.cxx:1103
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
SwHTMLFormatInfos m_CharFormatInfos
Definition: wrthtml.hxx:287
OString const aName
void OutPointFieldmarks(const SwPosition &rPos)
Definition: wrthtml.cxx:1165
SvStream & Strm()
Definition: writer.cxx:218
#define OOO_STRING_SVTOOLS_HTML_O_type
#define OOO_STRING_SVTOOLS_HTML_O_checked
virtual OUString GetFieldname() const =0
HTMLMODE_FULL_STYLES
void CollectLinkTargets()
bool IsTableNode() const
Definition: node.hxx:640
std::unique_ptr< SwHTMLNumRuleInfo > ReleaseNextNumInfo()
Definition: wrthtml.cxx:174
SwSectionNode * GetSectionNode()
Definition: node.hxx:607
Ends a section of nodes in the document model.
Definition: node.hxx:333
#define OOO_STRING_SVTOOLS_HTML_head
SectionType GetType() const
Definition: section.hxx:171
bool const bOldOutFooter
Definition: wrthtml.hxx:636
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
bool m_bCfgOutStyles
Definition: wrthtml.hxx:339
SwHTMLWriter(const OUString &rBaseURL, const OUString &rFilterOptions="")
Construct an instance of SwHTMLWriter and optionally give it the filter options directly, which can also be set via SetupFilterOptions().
Definition: wrthtml.cxx:94
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:79
void OutDirection(SvxFrameDirection nDir)
Definition: wrthtml.cxx:1373
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
SS for PoolItems: hard attributation.
Definition: node.hxx:730
void OutAndSetDefList(sal_uInt16 nNewLvl)
Definition: htmlatr.cxx:126
std::unique_ptr< SwHTMLNumRuleInfo > m_pNextNumRuleInfo
Definition: wrthtml.hxx:260
#define RES_PAGEDESC
Definition: hintids.hxx:198
OUString convertHyperlinkHRefValue(const OUString &rURL)
Definition: wrthtml.cxx:1223
sal_Int32 indexOfDotLeaders(sal_uInt16 nPoolId, const OUString &rText)
Definition: wrthtml.cxx:1453
std::vector< sal_uInt32 > m_aOutlineMarkPoss
Definition: wrthtml.hxx:285
SvxFrameDirection m_nDirection
Definition: wrthtml.hxx:332
static sal_uInt16 GetLangWhichIdFromScript(sal_uInt16 nScript)
Definition: wrthtml.cxx:1313
long GetTextLeft() const
sal_Int32 nPos
bool IsTextNode() const
Definition: node.hxx:636
#define CSS1_OUTMODE_CTL
Definition: wrthtml.hxx:182
bool mbSkipImages
Definition: wrthtml.hxx:387
static OString convertDirection(SvxFrameDirection nDirection)
Definition: wrthtml.cxx:1385
#define HTMLMODE_ABS_POS_DRAW
Definition: wrthtml.hxx:122
#define OOO_STRING_SVTOOLS_HTML_anchor
void OutFootEndNoteInfo()
Definition: htmlftn.cxx:522
SvxFrameDirection const nOldDirection
Definition: wrthtml.hxx:633
sal_uInt16 Which() const
sal_uInt16 m_nDefListLvl
Definition: wrthtml.hxx:324
sal_Int32 m_nDfltLeftMargin
Definition: wrthtml.hxx:316
OUString convertCommaSeparated(uno::Sequence< OUString > const &i_rSeq)
sal_uInt16 m_nCSS1Script
Definition: wrthtml.hxx:330
#define SAL_NEWLINE_STRING
SwDoc * m_pDoc
Definition: shellio.hxx:403
const Color & GetValue() const
HtmlTokenId m_nLastParaToken
Definition: wrthtml.hxx:309
bool m_bOutFlyFrame
Definition: wrthtml.hxx:364
bool CopyLocalFileToINet(OUString &rFileNm)
Definition: writer.cxx:303
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
bool HasHints() const
Definition: ndtxt.hxx:221
sal_uInt16 OutHeaderAttrs()
Definition: wrthtml.cxx:924
bool m_bShowProgress
Definition: shellio.hxx:407
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
Base class of the Writer document model elements.
Definition: node.hxx:79