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