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