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