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