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