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