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