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