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