LibreOffice Module sw (master) 1
htmlflywriter.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 <com/sun/star/text/HoriOrientation.hpp>
21#include <com/sun/star/text/VertOrientation.hpp>
22#include <com/sun/star/text/RelOrientation.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <hintids.hxx>
25#include <tools/fract.hxx>
26#include <svl/urihelper.hxx>
27#include <vcl/svapp.hxx>
28#include <sfx2/event.hxx>
29#include <svtools/htmlkywd.hxx>
30#include <svtools/htmlout.hxx>
31#include <svtools/htmltokn.h>
32#include <vcl/imap.hxx>
33#include <vcl/imapobj.hxx>
34#include <svtools/htmlcfg.hxx>
36#include <svx/svdouno.hxx>
37#include <svx/xoutbmp.hxx>
38#include <editeng/boxitem.hxx>
39#include <editeng/lrspitem.hxx>
40#include <editeng/ulspitem.hxx>
41#include <editeng/brushitem.hxx>
42#include <sal/log.hxx>
43#include <osl/diagnose.h>
44#include <svx/svdograf.hxx>
46
47#include <fmtanchr.hxx>
48#include <fmtornt.hxx>
49#include <fmturl.hxx>
50#include <fmtfsize.hxx>
51#include <fmtclds.hxx>
52#include <fmtcntnt.hxx>
53#include <fmtsrnd.hxx>
54#include <fmtinfmt.hxx>
55#include <txtinet.hxx>
56#include <frmatr.hxx>
57#include <grfatr.hxx>
58#include <flypos.hxx>
59#include <ndgrf.hxx>
60
61#include <doc.hxx>
62#include <ndtxt.hxx>
63#include <pam.hxx>
64#include <swerror.h>
65#include <frmfmt.hxx>
66#include "wrthtml.hxx"
67#include "htmlatr.hxx"
68#include "htmlfly.hxx"
69#include "htmlreqifreader.hxx"
70
71using namespace css;
72
90
102
109
116
124
132
133static SwHTMLWriter& OutHTML_FrameFormatTableNode( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat );
135 bool bInCntnr );
138 const SwFrameFormat& rFrameFormat, bool bSpan );
139static SwHTMLWriter& OutHTML_FrameFormatAsImage( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat, bool bPNGFallback );
140
142 bool bInCntnr, bool bPNGFallback );
143
144static SwHTMLWriter& OutHTML_FrameFormatAsMarquee( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
145 const SdrObject& rSdrObj );
146
148{
149 { OOO_STRING_SVTOOLS_HTML_O_SDonload, OOO_STRING_SVTOOLS_HTML_O_onload, SvMacroItemId::OnImageLoadDone },
150 { OOO_STRING_SVTOOLS_HTML_O_SDonabort, OOO_STRING_SVTOOLS_HTML_O_onabort, SvMacroItemId::OnImageLoadCancel },
152 { nullptr, nullptr, SvMacroItemId::NONE }
153};
154
156{
159 { nullptr, nullptr, SvMacroItemId::NONE }
160};
161
163 const SdrObject*& rpSdrObj )
164{
166
167 if( RES_DRAWFRMFMT == rFrameFormat.Which() )
168 {
169 // use an arbitrary draw object as the default value
171
172 const SdrObject *pObj =
173 SwHTMLWriter::GetMarqueeTextObj( static_cast<const SwDrawFrameFormat &>(rFrameFormat) );
174 if( pObj )
175 {
176 // scrolling text
177 rpSdrObj = pObj;
179 }
180 else
181 {
182 pObj = GetHTMLControl( static_cast<const SwDrawFrameFormat &>(rFrameFormat) );
183
184 if( pObj )
185 {
186 // Form control
187 rpSdrObj = pObj;
189 }
190 }
191 }
192 else
193 {
194 // use a text frame as the default value
196
197 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
198 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
199 const SwNode* pNd = m_pDoc->GetNodes()[ nStt ];
200
201 if( pNd->IsGrfNode() )
202 {
203 // graphic node
205 }
206 else if( pNd->IsOLENode() )
207 {
208 // applet, plugin, floating frame
210 }
211 else
212 {
213 SwNodeOffset nEnd = m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
214
215 const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
216 const SwFormatCol* pFormatCol = rItemSet.GetItemIfSet( RES_COL );
217 if( pFormatCol && pFormatCol->GetNumCols() > 1 )
218 {
219 // frame with columns
221 }
222 else if( pNd->IsTableNode() )
223 {
224 const SwTableNode *pTableNd = pNd->GetTableNode();
225 SwNodeOffset nTableEnd = pTableNd->EndOfSectionIndex();
226
227 if( nTableEnd+1 == nEnd )
228 {
229 // table
231 }
232 else if( nTableEnd+2 == nEnd )
233 {
234 // table with caption
236 }
237 }
238 else if( pNd->IsTextNode() )
239 {
240 const SwTextNode *pTextNd = pNd->GetTextNode();
241
242 bool bEmpty = false;
243 if( nStt==nEnd-1 && !pTextNd->Len() )
244 {
245 // empty frame? Only if no frame is
246 // anchored to the text or start node.
247 bEmpty = true;
248 for( auto & pHTMLPosFlyFrame : m_aHTMLPosFlyFrames )
249 {
250 SwNodeOffset nIdx = pHTMLPosFlyFrame->GetNdIndex().GetIndex();
251 bEmpty = (nIdx != nStt) && (nIdx != nStt-1);
252 if( !bEmpty || nIdx > nStt )
253 break;
254 }
255 }
256 if( bEmpty )
257 {
258 std::unique_ptr<SvxBrushItem> aBrush = rFrameFormat.makeBackgroundBrushItem();
261 if( GPOS_NONE != aBrush->GetGraphicPos() ||
262 aBrush->GetColor() != COL_TRANSPARENT )
263 {
264 bEmpty = false;
265 }
266 }
267 if( bEmpty )
268 {
269 // empty frame
271 }
272 else if( m_pDoc->GetNodes()[nStt+1]->IsTableNode() )
273 {
274 const SwTableNode *pTableNd =
275 m_pDoc->GetNodes()[nStt+1]->GetTableNode();
276 if( pTableNd->EndOfSectionIndex()+1 == nEnd )
277 {
278 // table with heading
280 }
281 }
282 }
283 }
284 }
285
286 return eType;
287}
288
290{
291 SwPosFlyFrames aFlyPos(
292 m_pDoc->GetAllFlyFormats(m_bWriteAll ? nullptr : m_pCurrentPam.get(), true));
293
294 for(const SwPosFlyFrame& rItem : aFlyPos)
295 {
296 const SwFrameFormat& rFrameFormat = rItem.GetFormat();
297 const SdrObject *pSdrObj = nullptr;
298 const SwNode *pAnchorNode;
299 const SwContentNode *pACNd;
300 SwHTMLFrameType eType = GuessFrameType( rFrameFormat, pSdrObj );
301
302 AllHtmlFlags nMode;
303 const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor();
304 sal_Int16 eHoriRel = rFrameFormat.GetHoriOrient().GetRelationOrient();
305 switch( rAnchor.GetAnchorId() )
306 {
307 case RndStdIds::FLY_AT_PAGE:
308 case RndStdIds::FLY_AT_FLY:
310 break;
311
312 case RndStdIds::FLY_AT_PARA:
313 // frames that are anchored to a paragraph are only placed
314 // before the paragraph, if the paragraph has a
315 // spacing.
316 if( text::RelOrientation::FRAME == eHoriRel &&
317 (pAnchorNode = rAnchor.GetAnchorNode()) != nullptr &&
318 (pACNd = pAnchorNode->GetContentNode()) != nullptr )
319 {
320 const SvxTextLeftMarginItem& rTextLeftMargin =
322 const SvxRightMarginItem& rRightMargin =
324 if (rTextLeftMargin.GetTextLeft() || rRightMargin.GetRight())
325 {
327 break;
328 }
329 }
331 break;
332
333 case RndStdIds::FLY_AT_CHAR:
334 if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel )
336 else
338 break;
339
340 default:
342 break;
343 }
344
345 m_aHTMLPosFlyFrames.insert( std::make_unique<SwHTMLPosFlyFrame>(rItem, pSdrObj, nMode) );
346 }
347}
348
349bool SwHTMLWriter::OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx, HtmlPosition nPos )
350{
351 bool bFlysLeft = false; // Are there still Flys left at the current node position?
352
353 // OutFlyFrame can be called recursively. Thus, sometimes it is
354 // necessary to start over after a Fly was returned.
355 bool bRestart = true;
356 while( !m_aHTMLPosFlyFrames.empty() && bRestart )
357 {
358 bFlysLeft = bRestart = false;
359
360 // search for the beginning of the FlyFrames
361 size_t i {0};
362
363 for( ; i < m_aHTMLPosFlyFrames.size() &&
364 m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() < nNdIdx; i++ )
365 ;
366 for( ; !bRestart && i < m_aHTMLPosFlyFrames.size() &&
367 m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() == nNdIdx; i++ )
368 {
369 SwHTMLPosFlyFrame *pPosFly = m_aHTMLPosFlyFrames[i].get();
370 if( ( HtmlPosition::Any == nPos ||
371 pPosFly->GetOutPos() == nPos ) &&
372 pPosFly->GetContentIndex() == nContentIdx )
373 {
374 // It is important to remove it first, because additional
375 // elements or the whole array could be deleted on
376 // deeper recursion levels.
377 std::unique_ptr<SwHTMLPosFlyFrame> flyHolder = m_aHTMLPosFlyFrames.erase_extract(i);
378 i--;
380 {
381 bRestart = true; // not really, only exit the loop
382 }
383
384 HTMLOutFuncs::FlushToAscii(Strm()); // it was one time only; do we still need it?
385
386 OutFrameFormat( pPosFly->GetOutMode(), pPosFly->GetFormat(),
387 pPosFly->GetSdrObject() );
388 switch( pPosFly->GetOutFn() )
389 {
390 case HtmlOut::Div:
391 case HtmlOut::Span:
394 bRestart = true; // It could become recursive here
395 break;
396 default: break;
397 }
398 }
399 else
400 {
401 bFlysLeft = true;
402 }
403 }
404 }
405
406 return bFlysLeft;
407}
408
410 const SdrObject *pSdrObject )
411{
412 HtmlContainerFlags nCntnrMode = nMode.nContainer;
413 HtmlOut nOutMode = nMode.nOut;
414 OString aContainerStr;
415 if( HtmlContainerFlags::NONE != nCntnrMode )
416 {
417
418 if( m_bLFPossible && HtmlContainerFlags::Div == nCntnrMode )
419 OutNewLine();
420
421 OStringBuffer sOut;
422 aContainerStr = (HtmlContainerFlags::Div == nCntnrMode)
425 sOut.append("<" + GetNamespace() + aContainerStr + " "
427 "sd-abs-pos\"");
428 Strm().WriteOString( sOut );
429 sOut.setLength(0);
430
431 // Output a width for non-draw objects
432 HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_CNTNR;
433
434 // For frames with columns we can also output the background
435 if( HtmlOut::MultiCol == nOutMode )
437
439 nFrameFlags |= HtmlFrmOpts::SNoBorder;
440 OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags, pSdrObject );
441 Strm().WriteChar( '>' );
442
443 if( HtmlContainerFlags::Div == nCntnrMode )
444 {
446 m_bLFPossible = true;
447 }
448 }
449
450 switch( nOutMode )
451 {
452 case HtmlOut::TableNode: // OK
453 OSL_ENSURE( aContainerStr.isEmpty(), "Table: Container is not supposed to be here" );
454 OutHTML_FrameFormatTableNode( *this, rFrameFormat );
455 break;
456 case HtmlOut::GraphicNode: // OK
457 OutHTML_FrameFormatGrfNode( *this, rFrameFormat, !aContainerStr.isEmpty(), /*bPNGFallback=*/true );
458 break;
459 case HtmlOut::OleNode: // OK
460 OutHTML_FrameFormatOLENode( *this, rFrameFormat, !aContainerStr.isEmpty() );
461 break;
462 case HtmlOut::OleGraphic: // OK
463 OutHTML_FrameFormatOLENodeGrf( *this, rFrameFormat, !aContainerStr.isEmpty() );
464 break;
465 case HtmlOut::Div:
466 case HtmlOut::Span:
467 OSL_ENSURE( aContainerStr.isEmpty(), "Div: Container is not supposed to be here" );
468 OutHTML_FrameFormatAsDivOrSpan( *this, rFrameFormat, HtmlOut::Span==nOutMode );
469 break;
470 case HtmlOut::MultiCol: // OK
471 OutHTML_FrameFormatAsMulticol( *this, rFrameFormat, !aContainerStr.isEmpty() );
472 break;
473 case HtmlOut::Spacer: // OK
474 OSL_ENSURE( aContainerStr.isEmpty(), "Spacer: Container is not supposed to be here" );
475 OutHTML_FrameFormatAsSpacer( *this, rFrameFormat );
476 break;
477 case HtmlOut::Control: // OK
479 static_cast<const SwDrawFrameFormat &>(rFrameFormat), dynamic_cast<const SdrUnoObj&>(*pSdrObject),
480 !aContainerStr.isEmpty() );
481 break;
483 OutHTML_FrameFormatAsMarquee( *this, rFrameFormat, *pSdrObject );
484 break;
485 case HtmlOut::Marquee:
486 OSL_ENSURE( aContainerStr.isEmpty(), "Marquee: Container is not supposed to be here" );
488 static_cast<const SwDrawFrameFormat &>(rFrameFormat), *pSdrObject );
489 break;
491 OutHTML_FrameFormatAsImage( *this, rFrameFormat, /*bPNGFallback=*/true );
492 break;
493 }
494
495 if( HtmlContainerFlags::Div == nCntnrMode )
496 {
498 if( m_bLFPossible )
499 OutNewLine();
501 m_bLFPossible = true;
502 }
503 else if( HtmlContainerFlags::Span == nCntnrMode )
505}
506
508 const OUString& rAlternateText,
509 HtmlFrmOpts nFrameOpts )
510{
511 OString sRetEndTags;
512 OStringBuffer sOut;
513 const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
514
515 // Name
516 if( (nFrameOpts & (HtmlFrmOpts::Id|HtmlFrmOpts::Name)) &&
517 !rFrameFormat.GetName().isEmpty() )
518 {
519 const char *pStr =
521 sOut.append(OString::Concat(" ") + pStr + "=\"");
522 Strm().WriteOString( sOut );
523 sOut.setLength(0);
524 HTMLOutFuncs::Out_String( Strm(), rFrameFormat.GetName() );
525 sOut.append('\"');
526 }
527
528 // Name
529 if( nFrameOpts & HtmlFrmOpts::Dir )
530 {
531 SvxFrameDirection nDir = GetHTMLDirection( rItemSet );
532 Strm().WriteOString( sOut );
533 sOut.setLength(0);
534 OutDirection( nDir );
535 }
536
537 // ALT
538 if( (nFrameOpts & HtmlFrmOpts::Alt) && !rAlternateText.isEmpty() )
539 {
540 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_alt "=\"");
541 Strm().WriteOString( sOut );
542 sOut.setLength(0);
543 HTMLOutFuncs::Out_String( Strm(), rAlternateText );
544 sOut.append('\"');
545 }
546
547 // ALIGN
548 const char *pStr = nullptr;
549 RndStdIds eAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
550 if( (nFrameOpts & HtmlFrmOpts::Align) &&
551 ((RndStdIds::FLY_AT_PARA == eAnchorId) || (RndStdIds::FLY_AT_CHAR == eAnchorId)) )
552 {
553 // MIB 12.3.98: Wouldn't it be more clever to left-align frames that
554 // are anchored to a paragraph if necessary, instead of inserting them
555 // as being anchored to characters?
556 const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
557 if( !(nFrameOpts & HtmlFrmOpts::SAlign) ||
558 text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() ||
559 text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() )
560 {
561 pStr = text::HoriOrientation::RIGHT == rHoriOri.GetHoriOrient()
564 }
565 }
566 const SwFormatVertOrient* pVertOrient;
567 if( (nFrameOpts & HtmlFrmOpts::Align) && !pStr &&
568 ( !(nFrameOpts & HtmlFrmOpts::SAlign) ||
569 (RndStdIds::FLY_AS_CHAR == eAnchorId) ) &&
570 (pVertOrient = rItemSet.GetItemIfSet( RES_VERT_ORIENT )) )
571 {
572 switch( pVertOrient->GetVertOrient() )
573 {
574 case text::VertOrientation::LINE_TOP: pStr = OOO_STRING_SVTOOLS_HTML_VA_top; break;
575 case text::VertOrientation::CHAR_TOP:
576 case text::VertOrientation::BOTTOM: pStr = OOO_STRING_SVTOOLS_HTML_VA_texttop; break; // not possible
577 case text::VertOrientation::LINE_CENTER:
578 case text::VertOrientation::CHAR_CENTER: pStr = OOO_STRING_SVTOOLS_HTML_VA_absmiddle; break; // not possible
579 case text::VertOrientation::CENTER: pStr = OOO_STRING_SVTOOLS_HTML_VA_middle; break;
580 case text::VertOrientation::LINE_BOTTOM:
581 case text::VertOrientation::CHAR_BOTTOM: pStr = OOO_STRING_SVTOOLS_HTML_VA_absbottom; break; // not possible
582 case text::VertOrientation::TOP: pStr = OOO_STRING_SVTOOLS_HTML_VA_bottom; break;
583 case text::VertOrientation::NONE: break;
584 }
585 }
586 if( pStr )
587 {
588 sOut.append(OString::Concat(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"") +
589 pStr + "\"");
590 }
591
592 // HSPACE and VSPACE
593 Size aTwipSpc( 0, 0 );
594 const SvxLRSpaceItem* pLRSpaceItem;
595 if( (nFrameOpts & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
596 (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) )
597 {
598 aTwipSpc.setWidth(
599 ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 );
601 }
602 const SvxULSpaceItem* pULSpaceItem;
603 if( (nFrameOpts & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
604 (pULSpaceItem = rItemSet.GetItemIfSet( RES_UL_SPACE )) )
605 {
606 aTwipSpc.setHeight(
607 ( pULSpaceItem->GetUpper() + pULSpaceItem->GetLower() ) / 2 );
608 m_nDfltTopMargin = m_nDfltBottomMargin = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
609 }
610
611 if( (nFrameOpts & HtmlFrmOpts::Space) &&
612 (aTwipSpc.Width() || aTwipSpc.Height()) &&
614 !mbReqIF )
615 {
616 Size aPixelSpc =
618 MapMode(MapUnit::MapTwip) );
619 if( !aPixelSpc.Width() && aTwipSpc.Width() )
620 aPixelSpc.setWidth( 1 );
621 if( !aPixelSpc.Height() && aTwipSpc.Height() )
622 aPixelSpc.setHeight( 1 );
623
624 if( aPixelSpc.Width() )
625 {
627 "=\"" + OString::number(aPixelSpc.Width()) + "\"");
628 }
629
630 if( aPixelSpc.Height() )
631 {
633 "=\"" + OString::number(aPixelSpc.Height()) + "\"");
634 }
635 }
636
637 // The spacing must be considered for the size, if the corresponding flag
638 // is set.
639 if( nFrameOpts & HtmlFrmOpts::MarginSize )
640 {
641 aTwipSpc.setWidth( aTwipSpc.Width() * -2 );
642 aTwipSpc.setHeight( aTwipSpc.Height() * -2 );
643 }
644 else
645 {
646 aTwipSpc.setWidth( 0 );
647 aTwipSpc.setHeight( 0 );
648 }
649
650 const SvxBoxItem* pBoxItem;
651 if( !(nFrameOpts & HtmlFrmOpts::AbsSize) &&
652 (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
653 {
654 aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT ) );
655 aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) );
656 aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::TOP ) );
657 aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::BOTTOM ) );
658 }
659
660 // WIDTH and/or HEIGHT
661 // Output SwFrameSize::Variable/SwFrameSize::Minimum only, if ANYSIZE is set
662 const SwFormatFrameSize *pFSItem;
663 if( (nFrameOpts & HtmlFrmOpts::Size) &&
664 (pFSItem = rItemSet.GetItemIfSet( RES_FRM_SIZE )) &&
665 ( (nFrameOpts & HtmlFrmOpts::AnySize) ||
667 {
668 sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
669 sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
670
671 // Size of the object in Twips without margins
672 Size aTwipSz( (nPercentWidth ? 0
673 : pFSItem->GetWidth()-aTwipSpc.Width()),
674 (nPercentHeight ? 0
675 : pFSItem->GetHeight()-aTwipSpc.Height()) );
676
677 OSL_ENSURE( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0, "Frame size minus spacing < 0!!!???" );
678 if( aTwipSz.Width() < 0 )
679 aTwipSz.setWidth( 0 );
680 if( aTwipSz.Height() < 0 )
681 aTwipSz.setHeight( 0 );
682
683 Size aPixelSz( 0, 0 );
684 if( (aTwipSz.Width() || aTwipSz.Height()) &&
686 {
687 aPixelSz =
689 MapMode(MapUnit::MapTwip) );
690 if( !aPixelSz.Width() && aTwipSz.Width() )
691 aPixelSz.setWidth( 1 );
692 if( !aPixelSz.Height() && aTwipSz.Height() )
693 aPixelSz.setHeight( 1 );
694 }
695
696 if( (nFrameOpts & HtmlFrmOpts::Width) &&
697 ((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
698 {
699 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
700 if( nPercentWidth )
701 sOut.append(OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%");
702 else
703 sOut.append(static_cast<sal_Int32>(aPixelSz.Width()));
704 sOut.append("\"");
705 }
706
707 if( (nFrameOpts & HtmlFrmOpts::Height) &&
708 ((nPercentHeight && nPercentHeight!=255) || aPixelSz.Height()) )
709 {
710 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_height "=\"");
711 if( nPercentHeight )
712 sOut.append(OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%");
713 else
714 sOut.append(static_cast<sal_Int32>(aPixelSz.Height()));
715 sOut.append("\"");
716 }
717 }
718
719 if (!sOut.isEmpty())
720 {
721 Strm().WriteOString( sOut );
722 sOut.setLength(0);
723 }
724
725 // Insert wrap for graphics that are anchored to a paragraph as
726 // <BR CLEAR=...> in the string
727 const SwFormatSurround* pSurround;
728 if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
729 ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
730 (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
731 (pSurround = rItemSet.GetItemIfSet( RES_SURROUND )) )
732 {
733 sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
734 pStr = nullptr;
735 css::text::WrapTextMode eSurround = pSurround->GetSurround();
736 bool bAnchorOnly = pSurround->IsAnchorOnly();
737 switch( eHoriOri )
738 {
739 case text::HoriOrientation::RIGHT:
740 {
741 switch( eSurround )
742 {
743 case css::text::WrapTextMode_NONE:
744 case css::text::WrapTextMode_RIGHT:
746 break;
747 case css::text::WrapTextMode_LEFT:
748 case css::text::WrapTextMode_PARALLEL:
749 if( bAnchorOnly )
750 m_bClearRight = true;
751 break;
752 default:
753 ;
754 }
755 }
756 break;
757
758 default:
759 // If a frame is centered, it gets left aligned. This
760 // should be taken into account here, too.
761 {
762 switch( eSurround )
763 {
764 case css::text::WrapTextMode_NONE:
765 case css::text::WrapTextMode_LEFT:
767 break;
768 case css::text::WrapTextMode_RIGHT:
769 case css::text::WrapTextMode_PARALLEL:
770 if( bAnchorOnly )
771 m_bClearLeft = true;
772 break;
773 default:
774 ;
775 }
776 }
777 break;
778
779 }
780
781 if( pStr )
782 {
785 "=\"" + OString::Concat(pStr) + "\">");
786 sRetEndTags = sOut.makeStringAndClear();
787 }
788 }
789 return sRetEndTags;
790}
791
792void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, std::u16string_view rAlternateText, HtmlFrmOpts nFrameOptions)
793{
794 bool bReplacement = (nFrameOptions & HtmlFrmOpts::Replacement) || mbReqIF;
795 const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
796
797 // Name
798 if( (nFrameOptions & (HtmlFrmOpts::Id|HtmlFrmOpts::Name)) &&
799 !rFrameFormat.GetName().isEmpty() && !bReplacement)
800 {
801 const char* pAttributeName = (nFrameOptions & HtmlFrmOpts::Id) ? OOO_STRING_SVTOOLS_HTML_O_id : OOO_STRING_SVTOOLS_HTML_O_name;
802 aHtml.attribute(pAttributeName, rFrameFormat.GetName());
803 }
804
805 // Name
806 if (nFrameOptions & HtmlFrmOpts::Dir)
807 {
808 SvxFrameDirection nCurrentDirection = GetHTMLDirection(rItemSet);
809 OString sDirection = convertDirection(nCurrentDirection);
810 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_dir, sDirection);
811 }
812
813 // alt
814 if( (nFrameOptions & HtmlFrmOpts::Alt) && !rAlternateText.empty() && !bReplacement )
815 {
816 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_alt, rAlternateText);
817 }
818
819 // align
820 std::string_view pAlignString;
821 RndStdIds eAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
822 if( (nFrameOptions & HtmlFrmOpts::Align) &&
823 ((RndStdIds::FLY_AT_PARA == eAnchorId) || (RndStdIds::FLY_AT_CHAR == eAnchorId)) && !bReplacement)
824 {
825 const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
826 if( !(nFrameOptions & HtmlFrmOpts::SAlign) ||
827 text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() ||
828 text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() )
829 {
830 pAlignString = text::HoriOrientation::RIGHT == rHoriOri.GetHoriOrient()
831 ? std::string_view(OOO_STRING_SVTOOLS_HTML_AL_right)
832 : std::string_view(OOO_STRING_SVTOOLS_HTML_AL_left);
833 }
834 }
835 const SwFormatVertOrient* pVertOrient;
836 if( (nFrameOptions & HtmlFrmOpts::Align) && pAlignString.empty() &&
837 ( !(nFrameOptions & HtmlFrmOpts::SAlign) ||
838 (RndStdIds::FLY_AS_CHAR == eAnchorId) ) &&
839 (pVertOrient = rItemSet.GetItemIfSet( RES_VERT_ORIENT )) )
840 {
841 switch( pVertOrient->GetVertOrient() )
842 {
843 case text::VertOrientation::LINE_TOP: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_top; break;
844 case text::VertOrientation::CHAR_TOP:
845 case text::VertOrientation::BOTTOM: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_texttop; break;
846 case text::VertOrientation::LINE_CENTER:
847 case text::VertOrientation::CHAR_CENTER: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_absmiddle; break;
848 case text::VertOrientation::CENTER: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_middle; break;
849 case text::VertOrientation::LINE_BOTTOM:
850 case text::VertOrientation::CHAR_BOTTOM: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_absbottom; break;
851 case text::VertOrientation::TOP: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_bottom; break;
852 case text::VertOrientation::NONE: break;
853 }
854 }
855 if (!pAlignString.empty() && !bReplacement)
856 {
857 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_align, pAlignString);
858 }
859
860 // hspace and vspace
861 Size aTwipSpc( 0, 0 );
862 const SvxLRSpaceItem* pLRSpaceItem;
863 if( (nFrameOptions & (HtmlFrmOpts::Space | HtmlFrmOpts::MarginSize)) &&
864 (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) )
865 {
866 aTwipSpc.setWidth(
867 ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 );
869 }
870 const SvxULSpaceItem* pULSpaceItem;
871 if( (nFrameOptions & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
872 (pULSpaceItem = rItemSet.GetItemIfSet( RES_UL_SPACE )) )
873 {
874 aTwipSpc.setHeight(
875 ( pULSpaceItem->GetUpper() + pULSpaceItem->GetLower() ) / 2 );
876 m_nDfltTopMargin = m_nDfltBottomMargin = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
877 }
878
879 if( (nFrameOptions & HtmlFrmOpts::Space) &&
880 (aTwipSpc.Width() || aTwipSpc.Height()) &&
882 !mbReqIF )
883 {
884 Size aPixelSpc =
886 MapMode(MapUnit::MapTwip) );
887 if( !aPixelSpc.Width() && aTwipSpc.Width() )
888 aPixelSpc.setWidth( 1 );
889 if( !aPixelSpc.Height() && aTwipSpc.Height() )
890 aPixelSpc.setHeight( 1 );
891
892 if (aPixelSpc.Width())
893 {
894 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_hspace, static_cast<sal_Int32>(aPixelSpc.Width()));
895 }
896
897 if (aPixelSpc.Height())
898 {
899 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_vspace, static_cast<sal_Int32>(aPixelSpc.Height()));
900 }
901 }
902
903 // The spacing must be considered for the size, if the corresponding flag
904 // is set.
905 if( nFrameOptions & HtmlFrmOpts::MarginSize )
906 {
907 aTwipSpc.setWidth( aTwipSpc.Width() * -2 );
908 aTwipSpc.setHeight( aTwipSpc.Height() * -2 );
909 }
910 else
911 {
912 aTwipSpc.setWidth( 0 );
913 aTwipSpc.setHeight( 0 );
914 }
915
916 const SvxBoxItem* pBoxItem;
917 if( !(nFrameOptions & HtmlFrmOpts::AbsSize) &&
918 (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
919 {
920 aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT ) );
921 aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) );
922 aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::TOP ) );
923 aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::BOTTOM ) );
924 }
925
926 // "width" and/or "height"
927 // Only output SwFrameSize::Variable/SwFrameSize::Minimum if ANYSIZE is set
928 std::optional<SwFormatFrameSize> aFrameSize;
929 const SwFormatFrameSize* pFSItem = rItemSet.GetItemIfSet( RES_FRM_SIZE );
930 const SdrObject* pObject;
931 if (!pFSItem && (pObject = rFrameFormat.FindSdrObject()))
932 {
933 // Write size for Draw shapes as well.
934 const tools::Rectangle& rSnapRect = pObject->GetSnapRect();
935 aFrameSize.emplace();
936 aFrameSize->SetWidthSizeType(SwFrameSize::Fixed);
937 aFrameSize->SetWidth(rSnapRect.getOpenWidth());
938 aFrameSize->SetHeightSizeType(SwFrameSize::Fixed);
939 aFrameSize->SetHeight(rSnapRect.getOpenHeight());
940 pFSItem = &*aFrameSize;
941 }
942 if( (nFrameOptions & HtmlFrmOpts::Size) &&
943 pFSItem &&
944 ( (nFrameOptions & HtmlFrmOpts::AnySize) ||
946 {
947 sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
948 sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
949
950 // Size of the object in Twips without margins
951 Size aTwipSz( (nPercentWidth && nPercentWidth != 255 ? 0
952 : pFSItem->GetWidth()-aTwipSpc.Width()),
953 (nPercentHeight && nPercentHeight != 255 ? 0
954 : pFSItem->GetHeight()-aTwipSpc.Height()) );
955
956 OSL_ENSURE( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0, "Frame size minus spacing < 0!!!???" );
957 if( aTwipSz.Width() < 0 )
958 aTwipSz.setWidth( 0 );
959 if( aTwipSz.Height() < 0 )
960 aTwipSz.setHeight( 0 );
961
962 Size aPixelSz( 0, 0 );
963 if( (aTwipSz.Width() || aTwipSz.Height()) &&
965 {
966 aPixelSz =
968 MapMode(MapUnit::MapTwip) );
969 if( !aPixelSz.Width() && aTwipSz.Width() )
970 aPixelSz.setWidth( 1 );
971 if( !aPixelSz.Height() && aTwipSz.Height() )
972 aPixelSz.setHeight( 1 );
973 }
974
975 if( (nFrameOptions & HtmlFrmOpts::Width) &&
976 ((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
977 {
978 OString sWidth;
979 if (nPercentWidth)
980 {
981 if (nPercentWidth == 255)
982 {
983 if (nPercentHeight)
984 {
985 sWidth = "auto";
986 }
987 else
988 {
989 sWidth = OString::number(static_cast<sal_Int32>(aPixelSz.Width()));
990 }
991 }
992 else
993 {
994 sWidth = OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%";
995 }
996 }
997 else
998 sWidth = OString::number(static_cast<sal_Int32>(aPixelSz.Width()));
999 if (!mbXHTML || sWidth != "auto")
1000 {
1002 }
1003 }
1004
1005 if( (nFrameOptions & HtmlFrmOpts::Height) &&
1006 ((nPercentHeight && nPercentHeight!=255) || aPixelSz.Height()) )
1007 {
1008 OString sHeight;
1009 if (nPercentHeight)
1010 {
1011 if (nPercentHeight == 255)
1012 {
1013 if (nPercentWidth)
1014 {
1015 sHeight = "auto";
1016 }
1017 else
1018 {
1019 sHeight = OString::number(static_cast<sal_Int32>(aPixelSz.Height()));
1020 }
1021 }
1022 else
1023 {
1024 sHeight = OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%";
1025 }
1026 }
1027 else
1028 sHeight = OString::number(static_cast<sal_Int32>(aPixelSz.Height()));
1029 if (!mbXHTML || sHeight != "auto")
1030 {
1032 }
1033 }
1034 }
1035
1036 // Insert wrap for graphics that are anchored to a paragraph as
1037 // <BR CLEAR=...> in the string
1038
1039 if( !(nFrameOptions & HtmlFrmOpts::BrClear) )
1040 return;
1041 RndStdIds nAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
1042 if (RndStdIds::FLY_AT_PARA != nAnchorId && RndStdIds::FLY_AT_CHAR != nAnchorId)
1043 return;
1044 const SwFormatSurround* pSurround = rItemSet.GetItemIfSet( RES_SURROUND );
1045 if (!pSurround)
1046 return;
1047
1048 std::string_view pSurroundString;
1049
1050 sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
1051 css::text::WrapTextMode eSurround = pSurround->GetSurround();
1052 bool bAnchorOnly = pSurround->IsAnchorOnly();
1053 switch( eHoriOri )
1054 {
1055 case text::HoriOrientation::RIGHT:
1056 {
1057 switch( eSurround )
1058 {
1059 case css::text::WrapTextMode_NONE:
1060 case css::text::WrapTextMode_RIGHT:
1061 pSurroundString = OOO_STRING_SVTOOLS_HTML_AL_right;
1062 break;
1063 case css::text::WrapTextMode_LEFT:
1064 case css::text::WrapTextMode_PARALLEL:
1065 if( bAnchorOnly )
1066 m_bClearRight = true;
1067 break;
1068 default:
1069 ;
1070 }
1071 }
1072 break;
1073
1074 default:
1075 // If a frame is centered, it gets left aligned. This
1076 // should be taken into account here, too.
1077 {
1078 switch( eSurround )
1079 {
1080 case css::text::WrapTextMode_NONE:
1081 case css::text::WrapTextMode_LEFT:
1082 pSurroundString = OOO_STRING_SVTOOLS_HTML_AL_left;
1083 break;
1084 case css::text::WrapTextMode_RIGHT:
1085 case css::text::WrapTextMode_PARALLEL:
1086 if( bAnchorOnly )
1087 m_bClearLeft = true;
1088 break;
1089 default:
1090 break;
1091 }
1092 }
1093 break;
1094 }
1095
1096 if (!pSurroundString.empty())
1097 {
1099 aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, pSurroundString);
1100 aHtml.end();
1101 }
1102}
1103
1104namespace
1105{
1106
1107OUString lclWriteOutImap(SwHTMLWriter& rWrt, const SfxItemSet& rItemSet, const SwFrameFormat& rFrameFormat,
1108 const Size& rRealSize, const ImageMap* pAltImgMap, const SwFormatURL*& pURLItem)
1109{
1110 OUString aIMapName;
1111
1112 // Only consider the URL attribute if no ImageMap was supplied
1113 if (!pAltImgMap)
1114 pURLItem = rItemSet.GetItemIfSet( RES_URL );
1115
1116 // write ImageMap
1117 const ImageMap* pIMap = pAltImgMap;
1118 if( !pIMap && pURLItem )
1119 {
1120 pIMap = pURLItem->GetMap();
1121 }
1122
1123 if (pIMap)
1124 {
1125 // make the name unique
1126 aIMapName = pIMap->GetName();
1127 OUString aNameBase;
1128 if (!aIMapName.isEmpty())
1129 aNameBase = aIMapName;
1130 else
1131 aNameBase = OOO_STRING_SVTOOLS_HTML_map;
1132
1133 if (aIMapName.isEmpty())
1134 aIMapName = aNameBase + OUString::number(rWrt.m_nImgMapCnt);
1135
1136 bool bFound;
1137 do
1138 {
1139 bFound = false;
1140 for (const OUString & rImgMapName : rWrt.m_aImgMapNames)
1141 {
1142 // TODO: Unicode: Comparison is case insensitive for ASCII
1143 // characters only now!
1144 if (aIMapName.equalsIgnoreAsciiCase(rImgMapName))
1145 {
1146 bFound = true;
1147 break;
1148 }
1149 }
1150 if (bFound)
1151 {
1152 rWrt.m_nImgMapCnt++;
1153 aIMapName = aNameBase + OUString::number( rWrt.m_nImgMapCnt );
1154 }
1155 } while (bFound);
1156
1157 bool bScale = false;
1158 Fraction aScaleX(1, 1);
1159 Fraction aScaleY(1, 1);
1160
1161 const SwFormatFrameSize& rFrameSize = rFrameFormat.GetFrameSize();
1162 const SvxBoxItem& rBox = rFrameFormat.GetBox();
1163
1164 if (!rFrameSize.GetWidthPercent() && rRealSize.Width())
1165 {
1166 SwTwips nWidth = rFrameSize.GetWidth();
1167 nWidth -= rBox.CalcLineSpace(SvxBoxItemLine::LEFT) + rBox.CalcLineSpace(SvxBoxItemLine::RIGHT);
1168
1169 OSL_ENSURE( nWidth > 0, "Are there any graphics that are 0 twip wide!?" );
1170 if (nWidth <= 0) // should not happen
1171 nWidth = 1;
1172
1173 if (rRealSize.Width() != nWidth)
1174 {
1175 aScaleX = Fraction(nWidth, rRealSize.Width());
1176 bScale = true;
1177 }
1178 }
1179
1180 if (!rFrameSize.GetHeightPercent() && rRealSize.Height())
1181 {
1182 SwTwips nHeight = rFrameSize.GetHeight();
1183
1184 nHeight -= rBox.CalcLineSpace(SvxBoxItemLine::TOP) + rBox.CalcLineSpace(SvxBoxItemLine::BOTTOM);
1185
1186 OSL_ENSURE( nHeight > 0, "Are there any graphics that are 0 twip high!?" );
1187 if (nHeight <= 0)
1188 nHeight = 1;
1189
1190 if (rRealSize.Height() != nHeight)
1191 {
1192 aScaleY = Fraction(nHeight, rRealSize.Height());
1193 bScale = true;
1194 }
1195 }
1196
1197 rWrt.m_aImgMapNames.push_back(aIMapName);
1198
1199 OString aIndMap, aIndArea;
1200 const char *pIndArea = nullptr, *pIndMap = nullptr;
1201
1202 if (rWrt.m_bLFPossible)
1203 {
1204 rWrt.OutNewLine( true );
1205 aIndMap = rWrt.GetIndentString();
1206 aIndArea = rWrt.GetIndentString(1);
1207 pIndArea = aIndArea.getStr();
1208 pIndMap = aIndMap.getStr();
1209 }
1210
1211 if (bScale)
1212 {
1213 ImageMap aScaledIMap(*pIMap);
1214 aScaledIMap.Scale(aScaleX, aScaleY);
1215 HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), rWrt.GetBaseURL(), aScaledIMap, aIMapName,
1217 rWrt.m_bCfgStarBasic,
1218 SAL_NEWLINE_STRING, pIndArea, pIndMap );
1219 }
1220 else
1221 {
1222 HTMLOutFuncs::Out_ImageMap( rWrt.Strm(), rWrt.GetBaseURL(), *pIMap, aIMapName,
1224 rWrt.m_bCfgStarBasic,
1225 SAL_NEWLINE_STRING, pIndArea, pIndMap );
1226 }
1227 }
1228 return aIMapName;
1229}
1230
1231OUString getFrameFormatText(const SwFrameFormat& rFrameFormat)
1232{
1233 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1234 const SwNodeIndex* pSttIx = rFlyContent.GetContentIdx();
1235 if (!pSttIx)
1236 return {};
1237
1238 const SwNodeOffset nStt = pSttIx->GetIndex();
1239 const auto& nodes = rFrameFormat.GetDoc()->GetNodes();
1240 const SwNodeOffset nEnd = nodes[nStt]->EndOfSectionIndex();
1241
1242 OUStringBuffer result;
1243 for (SwNodeOffset i = nStt + 1; i < nEnd; ++i)
1244 {
1245 if (const auto* pTextNd = nodes[i]->GetTextNode())
1246 {
1247 if (!result.isEmpty())
1248 result.append("\n");
1249 result.append(comphelper::string::encodeForXml(pTextNd->GetExpandText(
1250 nullptr, 0, -1, true, true, false,
1253 }
1254 }
1255
1256 return result.makeStringAndClear();
1257}
1258
1259}
1260
1262 const OUString& rGraphicURL,
1263 Graphic const & rGraphic, const OUString& rAlternateText,
1264 const Size &rRealSize, HtmlFrmOpts nFrameOpts,
1265 const char *pMarkType,
1266 const ImageMap *pAltImgMap,
1267 std::u16string_view rMimeType )
1268{
1269 // <object data="..."> instead of <img src="...">
1270 bool bReplacement = (nFrameOpts & HtmlFrmOpts::Replacement) || rWrt.mbReqIF;
1271
1272 if (rWrt.mbSkipImages)
1273 return rWrt;
1274
1275 // if necessary, temporarily close an open attribute
1276 if( !rWrt.m_aINetFormats.empty() )
1277 {
1278 SwFormatINetFormat* pINetFormat = rWrt.m_aINetFormats.back();
1279 OutHTML_INetFormat( rWrt, *pINetFormat, false );
1280 }
1281
1282 OUString aGraphicURL( rGraphicURL );
1283 if( !rWrt.mbEmbedImages && !HTMLOutFuncs::PrivateURLToInternalImg(aGraphicURL) && !rWrt.mpTempBaseURL )
1284 aGraphicURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), aGraphicURL);
1285
1286 const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
1287
1288 const SwFormatURL* pURLItem = nullptr;
1289 OUString aIMapName = lclWriteOutImap(rWrt, rItemSet, rFrameFormat, rRealSize, pAltImgMap, pURLItem);
1290
1291 // put img into new line
1292 if( rWrt.m_bLFPossible )
1293 rWrt.OutNewLine( true );
1294
1295 // <a name=...></a>...<img ...>
1296 if( pMarkType && !rFrameFormat.GetName().isEmpty() )
1297 {
1298 rWrt.OutImplicitMark( rFrameFormat.GetName(), pMarkType );
1299 }
1300
1301 // URL -> <a>...<img ... >...</a>
1302 const SvxMacroItem *pMacItem = rItemSet.GetItemIfSet(RES_FRMMACRO);
1303
1304 if (pURLItem || pMacItem)
1305 {
1306 OUString aMapURL;
1307 OUString aName;
1308 OUString aTarget;
1309
1310 if(pURLItem)
1311 {
1312 aMapURL = pURLItem->GetURL();
1313 aName = pURLItem->GetName();
1314 aTarget = pURLItem->GetTargetFrameName();
1315 }
1316
1317 bool bEvents = pMacItem && !pMacItem->GetMacroTable().empty();
1318
1319 if( !aMapURL.isEmpty() || !aName.isEmpty() || !aTarget.isEmpty() || bEvents )
1320 {
1322
1323 // Output "href" element if a link or macro exists
1324 if( !aMapURL.isEmpty() || bEvents )
1325 {
1327 }
1328
1329 if( !aName.isEmpty() )
1330 {
1332 }
1333
1334 if( !aTarget.isEmpty() )
1335 {
1337 }
1338
1339 if( pMacItem )
1340 {
1341 const SvxMacroTableDtor& rMacTable = pMacItem->GetMacroTable();
1342 if (!rMacTable.empty())
1343 {
1345 }
1346 }
1347 }
1348 }
1349
1350 // <font color = ...>...<img ... >...</font>
1351 sal_uInt16 nBorderWidth = 0;
1352 const SvxBoxItem* pBoxItem;
1353 if( (nFrameOpts & HtmlFrmOpts::Border) &&
1354 (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
1355 {
1356 Size aTwipBorder( 0, 0 );
1357 const ::editeng::SvxBorderLine *pColBorderLine = nullptr;
1358 const ::editeng::SvxBorderLine *pBorderLine = pBoxItem->GetLeft();
1359 if( pBorderLine )
1360 {
1361 pColBorderLine = pBorderLine;
1362 aTwipBorder.AdjustWidth(pBorderLine->GetOutWidth() );
1363 }
1364
1365 pBorderLine = pBoxItem->GetRight();
1366 if( pBorderLine )
1367 {
1368 pColBorderLine = pBorderLine;
1369 aTwipBorder.AdjustWidth(pBorderLine->GetOutWidth() );
1370 }
1371
1372 pBorderLine = pBoxItem->GetTop();
1373 if( pBorderLine )
1374 {
1375 pColBorderLine = pBorderLine;
1376 aTwipBorder.AdjustHeight(pBorderLine->GetOutWidth() );
1377 }
1378
1379 pBorderLine = pBoxItem->GetBottom();
1380 if( pBorderLine )
1381 {
1382 pColBorderLine = pBorderLine;
1383 aTwipBorder.AdjustHeight(pBorderLine->GetOutWidth() );
1384 }
1385
1386 aTwipBorder.setWidth( aTwipBorder.Width() / 2 );
1387 aTwipBorder.setHeight( aTwipBorder.Height() / 2 );
1388
1389 if( (aTwipBorder.Width() || aTwipBorder.Height()) &&
1391 {
1392 Size aPixelBorder =
1394 MapMode(MapUnit::MapTwip) );
1395 if( !aPixelBorder.Width() && aTwipBorder.Width() )
1396 aPixelBorder.setWidth( 1 );
1397 if( !aPixelBorder.Height() && aTwipBorder.Height() )
1398 aPixelBorder.setHeight( 1 );
1399
1400 if( aPixelBorder.Width() )
1401 aPixelBorder.setHeight( 0 );
1402
1403 nBorderWidth =
1404 o3tl::narrowing<sal_uInt16>(aPixelBorder.Width() + aPixelBorder.Height());
1405 }
1406
1407 if( pColBorderLine )
1408 {
1410 HtmlWriterHelper::applyColor(rHtml, OOO_STRING_SVTOOLS_HTML_O_color, pColBorderLine->GetColor());
1411 }
1412 }
1413
1414 OString aTag(OOO_STRING_SVTOOLS_HTML_image);
1415 if (bReplacement)
1416 // Write replacement graphic of OLE object as <object>.
1418 rHtml.start(aTag);
1419
1420 if(rWrt.mbEmbedImages)
1421 {
1422 OUString aGraphicInBase64;
1423 if (XOutBitmap::GraphicToBase64(rGraphic, aGraphicInBase64))
1424 {
1425 OString sBuffer(OString::Concat(OOO_STRING_SVTOOLS_HTML_O_data)
1426 + ":"
1427 + OUStringToOString(aGraphicInBase64, RTL_TEXTENCODING_UTF8));
1429 }
1430 else
1432 }
1433 else
1434 {
1435 OString sBuffer(OUStringToOString(aGraphicURL, RTL_TEXTENCODING_UTF8));
1436 OString aAttribute(OOO_STRING_SVTOOLS_HTML_O_src);
1437 if (bReplacement)
1438 aAttribute = OOO_STRING_SVTOOLS_HTML_O_data;
1439 rHtml.attribute(aAttribute, sBuffer);
1440 }
1441
1442 if (bReplacement)
1443 {
1444 // Handle XHTML type attribute for OLE replacement images.
1445 if (!rMimeType.empty())
1446 rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, rMimeType);
1447 }
1448
1449 // Events
1450 if (const SvxMacroItem* pMacroItem = rItemSet.GetItemIfSet(RES_FRMMACRO))
1451 {
1452 const SvxMacroTableDtor& rMacTable = pMacroItem->GetMacroTable();
1453 if (!rMacTable.empty())
1454 {
1456 }
1457 }
1458
1459 // alt, align, width, height, hspace, vspace
1460 rWrt.writeFrameFormatOptions(rHtml, rFrameFormat, rAlternateText, nFrameOpts);
1461 if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) )
1462 rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
1463
1464 if ((nFrameOpts & HtmlFrmOpts::Border) && !bReplacement)
1465 {
1467 }
1468
1469 if( pURLItem && pURLItem->IsServerMap() )
1470 {
1472 }
1473
1474 if( !aIMapName.isEmpty() )
1475 {
1476 rHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_usemap, Concat2View("#" + aIMapName));
1477 }
1478
1479 if (bReplacement)
1480 {
1481 OUString aAltText = rAlternateText;
1482 // In ReqIF mode, output text from the frame instead
1483 if (rWrt.mbReqIF)
1484 if (OUString aFrameText = getFrameFormatText(rFrameFormat); !aFrameText.isEmpty())
1485 aAltText = aFrameText;
1486
1487 // XHTML object replacement image's alternate text doesn't use the
1488 // "alt" attribute.
1489 if (aAltText.isEmpty())
1490 // Empty alternate text is not valid.
1491 rHtml.characters(" ");
1492 else
1493 rHtml.characters(aAltText.toUtf8());
1494 }
1495
1496 return rWrt;
1497}
1498
1500{
1501 rHtml.flushStack();
1502
1503 if( !rWrt.m_aINetFormats.empty() )
1504 {
1505 // There is still an attribute on the stack that has to be reopened
1506 SwFormatINetFormat *pINetFormat = rWrt.m_aINetFormats.back();
1507 OutHTML_INetFormat( rWrt, *pINetFormat, true );
1508 }
1509
1510 return rWrt;
1511}
1512
1514 const char *pTag,
1515 const SvxBrushItem* pBrush,
1516 const OUString &rGraphicURL)
1517{
1518 OUString aGraphicInBase64;
1519 OUString aLink;
1520 if( pBrush )
1521 {
1522 aLink = pBrush->GetGraphicLink();
1523 if(rWrt.mbEmbedImages || aLink.isEmpty())
1524 {
1525 const Graphic* pGrf = pBrush->GetGraphic();
1526 if( pGrf )
1527 {
1528 if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
1529 {
1531 }
1532 }
1533 }
1534 else if(!aLink.isEmpty())
1535 {
1536 if( rWrt.m_bCfgCpyLinkedGrfs )
1537 {
1538 rWrt.CopyLocalFileToINet( aLink );
1539 }
1540
1541 }
1542 }
1543 else if(!rWrt.mbEmbedImages)
1544 {
1545 aLink = rGraphicURL;
1546 }
1547 if(!aLink.isEmpty())
1548 {
1551 }
1552
1553 OStringBuffer sOut;
1554 if( pTag )
1555 sOut.append(OString::Concat("<") + pTag);
1556
1557 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_style "=\"");
1558 if(!aLink.isEmpty())
1559 {
1560 sOut.append(OOO_STRING_SVTOOLS_HTML_O_src "=\"");
1561 rWrt.Strm().WriteOString( sOut );
1562 sOut.setLength(0);
1563 HTMLOutFuncs::Out_String( rWrt.Strm(), aLink );
1564 }
1565 else
1566 {
1567 sOut.append("list-style-image: url("
1569 rWrt.Strm().WriteOString( sOut );
1570 sOut.setLength(0);
1571 HTMLOutFuncs::Out_String( rWrt.Strm(), aGraphicInBase64 );
1572 sOut.append(");");
1573 }
1574 sOut.append('\"');
1575
1576 if (pTag)
1577 sOut.append('>');
1578 rWrt.Strm().WriteOString( sOut );
1579
1580 return rWrt;
1581}
1582
1584{
1585 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1586 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1587 SwNodeOffset nEnd = rWrt.m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
1588
1589 OUString aCaption;
1590 bool bTopCaption = false;
1591
1592 // Not const, because GetTable won't be const sometime later
1593 SwNode *pNd = rWrt.m_pDoc->GetNodes()[ nStt ];
1594 SwTableNode *pTableNd = pNd->GetTableNode();
1595 const SwTextNode *pTextNd = pNd->GetTextNode();
1596 if( !pTableNd && pTextNd )
1597 {
1598 // Table with heading
1599 bTopCaption = true;
1600 pTableNd = rWrt.m_pDoc->GetNodes()[nStt+1]->GetTableNode();
1601 }
1602 OSL_ENSURE( pTableNd, "Frame does not contain a table" );
1603 if( pTableNd )
1604 {
1605 SwNodeOffset nTableEnd = pTableNd->EndOfSectionIndex();
1606 OSL_ENSURE( nTableEnd == nEnd - 1 ||
1607 (nTableEnd == nEnd - 2 && !bTopCaption),
1608 "Invalid frame content for a table" );
1609
1610 if( nTableEnd == nEnd - 2 )
1611 pTextNd = rWrt.m_pDoc->GetNodes()[nTableEnd+1]->GetTextNode();
1612 }
1613 if( pTextNd )
1614 aCaption = pTextNd->GetText();
1615
1616 if( pTableNd )
1617 {
1618 HTMLSaveData aSaveData( rWrt, pTableNd->GetIndex()+1,
1619 pTableNd->EndOfSectionIndex(),
1620 true, &rFrameFormat );
1621 rWrt.m_bOutFlyFrame = true;
1622 OutHTML_SwTableNode( rWrt, *pTableNd, &rFrameFormat, &aCaption,
1623 bTopCaption );
1624 }
1625
1626 return rWrt;
1627}
1628
1630 const SwFrameFormat& rFrameFormat,
1631 bool bInCntnr )
1632{
1633 rWrt.ChangeParaToken( HtmlTokenId::NONE );
1634
1635 // Close the current <DL>!
1636 rWrt.OutAndSetDefList( 0 );
1637
1638 // output as Multicol
1639 if( rWrt.m_bLFPossible )
1640 rWrt.OutNewLine();
1641
1642 OStringBuffer sOut("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol);
1643
1644 const SwFormatCol& rFormatCol = rFrameFormat.GetCol();
1645
1646 // output the number of columns as COLS
1647 sal_uInt16 nCols = rFormatCol.GetNumCols();
1648 if( nCols )
1649 {
1650 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cols
1651 "=\"" + OString::number(nCols) + "\"");
1652 }
1653
1654 // the Gutter width (minimum value) as GUTTER
1655 sal_uInt16 nGutter = rFormatCol.GetGutterWidth( true );
1656 if( nGutter!=USHRT_MAX )
1657 {
1658 if( nGutter && Application::GetDefaultDevice() )
1659 {
1660 nGutter = o3tl::narrowing<sal_uInt16>(Application::GetDefaultDevice()
1661 ->LogicToPixel( Size(nGutter,0),
1662 MapMode(MapUnit::MapTwip) ).Width());
1663 }
1664 sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_gutter
1665 "=\"" + OString::number(nGutter) + "\"");
1666 }
1667
1668 rWrt.Strm().WriteOString( sOut );
1669 sOut.setLength(0);
1670
1671 // WIDTH
1672 HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MULTICOL;
1673 if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1674 nFrameFlags |= HTML_FRMOPTS_MULTICOL_CSS1;
1675 rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
1676 if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1677 rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
1678
1679 rWrt.Strm().WriteChar( '>' );
1680
1681 rWrt.m_bLFPossible = true;
1682 rWrt.IncIndentLevel(); // indent the content of Multicol
1683
1684 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1685 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
1686 const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
1687 OSL_ENSURE( pSttNd, "Where is the start node" );
1688
1689 {
1690 // in a block, so that the old state can be restored in time
1691 // before the end
1692 HTMLSaveData aSaveData( rWrt, nStt+1,
1693 pSttNd->EndOfSectionIndex(),
1694 true, &rFrameFormat );
1695 rWrt.m_bOutFlyFrame = true;
1696 rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
1697 }
1698
1699 rWrt.DecIndentLevel(); // indent the content of Multicol;
1700 if( rWrt.m_bLFPossible )
1701 rWrt.OutNewLine();
1702 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol), false );
1703 rWrt.m_bLFPossible = true;
1704
1705 return rWrt;
1706}
1707
1709{
1710 // if possible, output a line break before the graphic
1711 if( rWrt.m_bLFPossible )
1712 rWrt.OutNewLine( true );
1713
1714 OString sOut =
1718 rWrt.Strm().WriteOString( sOut );
1719
1720 // ALIGN, WIDTH, HEIGHT
1721 OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), HTML_FRMOPTS_SPACER);
1722
1723 rWrt.Strm().WriteChar( '>' );
1724 if( !aEndTags.isEmpty() )
1725 rWrt.Strm().WriteOString( aEndTags );
1726
1727 return rWrt;
1728}
1729
1731 const SwFrameFormat& rFrameFormat, bool bSpan)
1732{
1733 OString aTag;
1734 if( !bSpan )
1735 {
1736 rWrt.ChangeParaToken( HtmlTokenId::NONE );
1737
1738 // Close the current <DL>!
1739 rWrt.OutAndSetDefList( 0 );
1741 }
1742 else
1744
1745 // output as DIV
1746 if( rWrt.m_bLFPossible )
1747 rWrt.OutNewLine();
1748
1749 OStringBuffer sOut("<" + rWrt.GetNamespace() + aTag);
1750
1751 rWrt.Strm().WriteOString( sOut );
1752 sOut.setLength(0);
1753 HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_DIV;
1754 if( rWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
1755 nFrameFlags |= HtmlFrmOpts::SNoBorder;
1756 OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
1757 rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
1758 rWrt.Strm().WriteChar( '>' );
1759
1760 rWrt.IncIndentLevel(); // indent the content
1761 rWrt.m_bLFPossible = true;
1762
1763 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1764 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
1765
1766 // Output frame-anchored frames that are anchored to the start node
1767 rWrt.OutFlyFrame( nStt, 0, HtmlPosition::Any );
1768
1769 const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
1770 OSL_ENSURE( pSttNd, "Where is the start node" );
1771
1772 {
1773 // in a block, so that the old state can be restored in time
1774 // before the end
1775 HTMLSaveData aSaveData( rWrt, nStt+1,
1776 pSttNd->EndOfSectionIndex(),
1777 true, &rFrameFormat );
1778 rWrt.m_bOutFlyFrame = true;
1779 rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
1780 }
1781
1782 rWrt.DecIndentLevel(); // indent the content of Multicol;
1783 if( rWrt.m_bLFPossible )
1784 rWrt.OutNewLine();
1785 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aTag), false );
1786
1787 if( !aEndTags.isEmpty() )
1788 rWrt.Strm().WriteOString( aEndTags );
1789
1790 return rWrt;
1791}
1792
1794static void OutHTML_ImageOLEStart(SwHTMLWriter& rWrt, const Graphic& rGraphic,
1795 const SwFrameFormat& rFrameFormat)
1796{
1797 if (!rWrt.mbReqIF || !rWrt.m_bExportImagesAsOLE)
1798 return;
1799
1800 // Write the original image as an RTF fragment.
1801 OUString aFileName;
1802 if (rWrt.GetOrigFileName())
1803 aFileName = *rWrt.GetOrigFileName();
1804 INetURLObject aURL(aFileName);
1805 OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_"
1806 + OUString::number(rGraphic.GetChecksum(), 16);
1807 aURL.setBase(aName);
1808 aURL.setExtension(u"ole");
1809 aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
1810
1811 SvFileStream aOutStream(aFileName, StreamMode::WRITE);
1812 if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream))
1813 SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed");
1814
1815 // Refer to this data.
1816 aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
1817 rWrt.Strm().WriteOString(
1818 Concat2View("<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
1819 rWrt.Strm().WriteOString(Concat2View(" data=\"" + aFileName.toUtf8() + "\""));
1820 rWrt.Strm().WriteOString(" type=\"text/rtf\"");
1821 rWrt.Strm().WriteOString(">");
1822 rWrt.OutNewLine();
1823}
1824
1827{
1828 if (rWrt.mbReqIF && rWrt.m_bExportImagesAsOLE)
1829 {
1830 rWrt.Strm().WriteOString(
1831 Concat2View("</" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">"));
1832 }
1833}
1834
1835static SwHTMLWriter & OutHTML_FrameFormatAsImage( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat, bool bPNGFallback)
1836{
1837 bool bWritePNGFallback = rWrt.mbReqIF && !rWrt.m_bExportImagesAsOLE && bPNGFallback;
1838
1839 if (rWrt.mbSkipImages)
1840 return rWrt;
1841
1842 ImageMap aIMap;
1843 std::optional<Size> aDPI;
1844 if (rWrt.m_nShapeDPI.has_value())
1845 {
1846 aDPI.emplace(*rWrt.m_nShapeDPI, *rWrt.m_nShapeDPI);
1847 }
1848 Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap, /*nMaximumQuadraticPixels=*/2100000, aDPI ) );
1849
1850 if (rWrt.mbReqIF)
1851 {
1852 // ImageMap doesn't seem to be allowed in reqif.
1853 if (auto pGrafObj = dynamic_cast<const SdrGrafObj*>(rFrameFormat.FindSdrObject()))
1854 {
1855 aGraphic = pGrafObj->GetGraphic();
1856 }
1857 else
1858 {
1859 // We only have a bitmap, write that as PNG without any fallback.
1860 bWritePNGFallback = false;
1861 }
1862 }
1863
1864 Size aSz( 0, 0 );
1865 OUString GraphicURL;
1866 OUString aMimeType("image/jpeg");
1867 if(!rWrt.mbEmbedImages)
1868 {
1869 if( rWrt.GetOrigFileName() )
1870 GraphicURL = *rWrt.GetOrigFileName();
1871
1872 OUString aFilterName("JPG");
1873 XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
1874
1875 if (rWrt.mbReqIF && !bWritePNGFallback)
1876 {
1877 // Writing image without fallback PNG in ReqIF mode: force PNG output.
1878 aFilterName = "PNG";
1879 nFlags = XOutFlags::NONE;
1880 aMimeType = "image/png";
1881 }
1882 else if (rWrt.mbReqIF)
1883 {
1884 // Original format is wanted, don't force JPG.
1885 aFilterName.clear();
1886 aMimeType.clear();
1887 }
1888
1889 if( aGraphic.GetType() == GraphicType::NONE ||
1890 XOutBitmap::WriteGraphic( aGraphic, GraphicURL,
1891 aFilterName,
1892 nFlags ) != ERRCODE_NONE )
1893 {
1894 // empty or incorrect, because there is nothing to output
1896 return rWrt;
1897 }
1898
1899 GraphicURL = URIHelper::SmartRel2Abs(
1900 INetURLObject(rWrt.GetBaseURL()), GraphicURL,
1902
1903 }
1904 uno::Reference<beans::XPropertySet> xGraphic(aGraphic.GetXGraphic(), uno::UNO_QUERY);
1905 if (xGraphic.is() && aMimeType.isEmpty())
1906 xGraphic->getPropertyValue("MimeType") >>= aMimeType;
1907
1908 OutHTML_ImageOLEStart(rWrt, aGraphic, rFrameFormat);
1909
1910 HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
1911 OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, GraphicURL, aGraphic, rFrameFormat.GetName(), aSz,
1912 HtmlFrmOpts::GenImgMask, "frame",
1913 aIMap.GetIMapObjectCount() ? &aIMap : nullptr, aMimeType );
1914
1915 GfxLink aLink = aGraphic.GetGfxLink();
1916 if (bWritePNGFallback && aLink.GetType() != GfxLinkType::NativePng)
1917 {
1918 OutHTML_FrameFormatAsImage( rWrt, rFrameFormat, /*bPNGFallback=*/false);
1919 }
1920
1921 OutHTML_ImageEnd(aHtml, rWrt);
1922
1923 OutHTML_ImageOLEEnd(rWrt);
1924
1925 return rWrt;
1926}
1927
1929 bool bInCntnr, bool bPNGFallback )
1930{
1931 bool bWritePNGFallback = rWrt.mbReqIF && !rWrt.m_bExportImagesAsOLE && bPNGFallback;
1932
1933 if (rWrt.mbSkipImages)
1934 return rWrt;
1935
1936 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1937 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1938 SwGrfNode *pGrfNd = rWrt.m_pDoc->GetNodes()[ nStt ]->GetGrfNode();
1939 OSL_ENSURE( pGrfNd, "Grf node expected" );
1940 if( !pGrfNd )
1941 return rWrt;
1942
1943 HtmlFrmOpts nFrameFlags = bInCntnr ? HTML_FRMOPTS_IMG_CNTNR : HTML_FRMOPTS_IMG;
1944 if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1945 nFrameFlags |= HTML_FRMOPTS_IMG_CSS1;
1946
1947 Graphic aGraphic = pGrfNd->GetGraphic();
1948
1949 if (aGraphic.GetType() == GraphicType::GdiMetafile)
1950 {
1951 // We only have a metafile, write that as PNG without any fallback.
1952 bWritePNGFallback = false;
1953 }
1954
1955 OUString aGraphicURL;
1956 OUString aMimeType;
1957 if(!rWrt.mbEmbedImages)
1958 {
1959 const SwMirrorGrf& rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
1960
1961 if( !pGrfNd->IsLinkedFile() || MirrorGraph::Dont != rMirror.GetValue() )
1962 {
1963 // create a (mirrored) jpeg file
1964 if( rWrt.GetOrigFileName() )
1965 aGraphicURL = *rWrt.GetOrigFileName();
1966 else
1967 aGraphicURL = rWrt.GetBaseURL();
1968 pGrfNd->GetGrf( true );
1969
1970 XOutFlags nFlags = XOutFlags::UseGifIfSensible |
1971 XOutFlags::UseNativeIfPossible;
1972 switch( rMirror.GetValue() )
1973 {
1974 case MirrorGraph::Vertical: nFlags = XOutFlags::MirrorHorz; break;
1975 case MirrorGraph::Horizontal: nFlags = XOutFlags::MirrorVert; break;
1976 case MirrorGraph::Both:
1977 nFlags = XOutFlags::MirrorVert | XOutFlags::MirrorHorz;
1978 break;
1979 default: break;
1980 }
1981
1982 const SwFormatFrameSize& rSize = rFrameFormat.GetFrameSize();
1983 Size aMM100Size = o3tl::convert( rSize.GetSize(),
1985
1986 OUString aFilterName;
1987
1988 if (rWrt.mbReqIF)
1989 {
1990 // In ReqIF mode, do not try to write GIF for other image types
1991 nFlags &= ~XOutFlags::UseGifIfSensible;
1992 if (!bWritePNGFallback)
1993 {
1994 // Writing image without fallback PNG in ReqIF mode: force PNG
1995 // output.
1996 // But don't force it when writing the original format and we'll write PNG inside
1997 // that.
1998 aFilterName = "PNG";
1999 nFlags &= ~XOutFlags::UseNativeIfPossible;
2000 }
2001 }
2002
2003 const Graphic& rGraphic = pGrfNd->GetGrf();
2004
2005 // So that Graphic::IsTransparent() can report true.
2006 if (!rGraphic.isAvailable())
2007 const_cast<Graphic&>(rGraphic).makeAvailable();
2008
2009 if (rWrt.mbReqIF && bWritePNGFallback)
2010 {
2011 // ReqIF: force native data if possible.
2012 const std::shared_ptr<VectorGraphicData>& pVectorGraphicData = rGraphic.getVectorGraphicData();
2013 if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Svg)
2014 {
2015 aFilterName = "svg";
2016 }
2017 else if (rGraphic.GetGfxLink().IsEMF())
2018 {
2019 aFilterName = "emf";
2020 }
2021 else if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Wmf)
2022 {
2023 aFilterName = "wmf";
2024 }
2025 else if (rGraphic.GetGfxLink().GetType() == GfxLinkType::NativeTif)
2026 {
2027 aFilterName = "tif";
2028 }
2029 }
2030
2031 ErrCode nErr = XOutBitmap::WriteGraphic( rGraphic, aGraphicURL,
2032 aFilterName, nFlags, &aMM100Size, nullptr, &aMimeType );
2033 if( nErr )
2034 {
2036 return rWrt;
2037 }
2038 aGraphicURL = URIHelper::SmartRel2Abs(
2039 INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
2041 }
2042 else
2043 {
2044 pGrfNd->GetFileFilterNms( &aGraphicURL, nullptr );
2045 if( rWrt.m_bCfgCpyLinkedGrfs )
2046 rWrt.CopyLocalFileToINet( aGraphicURL );
2047 }
2048
2049 }
2050 uno::Reference<beans::XPropertySet> xGraphic(aGraphic.GetXGraphic(), uno::UNO_QUERY);
2051 if (xGraphic.is() && aMimeType.isEmpty())
2052 xGraphic->getPropertyValue("MimeType") >>= aMimeType;
2053
2054 OutHTML_ImageOLEStart(rWrt, aGraphic, rFrameFormat);
2055
2056 HtmlWriter aHtml(rWrt.Strm(), rWrt.maNamespace);
2057 OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, aGraphicURL, aGraphic, pGrfNd->GetTitle(),
2058 pGrfNd->GetTwipSize(), nFrameFlags, "graphic", nullptr, aMimeType );
2059
2060 GfxLink aLink = aGraphic.GetGfxLink();
2061 if (bWritePNGFallback && aLink.GetType() != GfxLinkType::NativePng)
2062 {
2063 // Not OLE mode, outer format is not PNG: write inner PNG.
2064 OutHTML_FrameFormatGrfNode( rWrt, rFrameFormat,
2065 bInCntnr, /*bPNGFallback=*/false );
2066 }
2067
2068 OutHTML_ImageEnd(aHtml, rWrt);
2069
2070 OutHTML_ImageOLEEnd(rWrt);
2071
2072 return rWrt;
2073}
2074
2076 const SdrObject& rSdrObj )
2077{
2078 // get the edit engine attributes of the object as SW attributes and
2079 // sort them as Hints
2080 const SfxItemSet& rFormatItemSet = rFrameFormat.GetAttrSet();
2081 SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END> aItemSet( *rFormatItemSet.GetPool() );
2082 SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, &rSdrObj );
2083 bool bCfgOutStylesOld = rWrt.m_bCfgOutStyles;
2084 rWrt.m_bCfgOutStyles = false;
2085 rWrt.m_bTextAttr = true;
2086 rWrt.m_bTagOn = true;
2087 Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
2088 rWrt.m_bTextAttr = false;
2089
2091 static_cast<const SwDrawFrameFormat &>(rFrameFormat),
2092 rSdrObj );
2093 rWrt.m_bTextAttr = true;
2094 rWrt.m_bTagOn = false;
2095 Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
2096 rWrt.m_bTextAttr = false;
2097 rWrt.m_bCfgOutStyles = bCfgOutStylesOld;
2098
2099 return rWrt;
2100}
2101
2103 bool bHeader )
2104{
2105 // output as Multicol
2106 rWrt.OutNewLine();
2107 OStringBuffer sOut;
2108 sOut.append(OOO_STRING_SVTOOLS_HTML_division " "
2110 .append( bHeader ? "header" : "footer" ).append("\"");
2111 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + sOut) );
2112
2113 rWrt.IncIndentLevel(); // indent the content of Multicol;
2114
2115 // Piece a spacer for the spacing together. Because the
2116 // <DL> or </DL> always produces a space between paragraphs, it is
2117 // subtracted if necessary.
2118 const SvxULSpaceItem& rULSpace = rFrameFormat.GetULSpace();
2119 sal_uInt16 nSize = bHeader ? rULSpace.GetLower() : rULSpace.GetUpper();
2120 rWrt.m_nHeaderFooterSpace = nSize;
2121
2122 OString aSpacer;
2123 if( rWrt.IsHTMLMode(HTMLMODE_VERT_SPACER) &&
2125 {
2126 nSize -= HTML_PARSPACE;
2127 nSize = static_cast<sal_Int16>(Application::GetDefaultDevice()
2128 ->LogicToPixel( Size(nSize,0), MapMode(MapUnit::MapTwip) ).Width());
2129
2134 "=\"" + OString::number(nSize) + "\"";
2135 }
2136
2137 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
2138 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex();
2139 const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
2140 OSL_ENSURE( pSttNd, "Where is the start node" );
2141
2142 if( !bHeader && !aSpacer.isEmpty() )
2143 {
2144 rWrt.OutNewLine();
2145 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aSpacer) );
2146 }
2147
2148 {
2149 // in a block, so that the old state can be restored in time
2150 // before the end. pFlyFormat doesn't need to be set here, because
2151 // PageDesc attributes cannot occur here
2152 HTMLSaveData aSaveData( rWrt, nStt+1,
2153 pSttNd->EndOfSectionIndex() );
2154
2155 if( bHeader )
2156 rWrt.m_bOutHeader = true;
2157 else
2158 rWrt.m_bOutFooter = true;
2159
2160 rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
2161 }
2162
2163 if( bHeader && !aSpacer.isEmpty() )
2164 {
2165 rWrt.OutNewLine();
2166 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + aSpacer) );
2167 }
2168
2169 rWrt.DecIndentLevel(); // indent the content of Multicol;
2170 rWrt.OutNewLine();
2171 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false );
2172
2173 rWrt.m_nHeaderFooterSpace = 0;
2174
2175 return rWrt;
2176}
2177
2178void SwHTMLWriter::AddLinkTarget( std::u16string_view aURL )
2179{
2180 if( aURL.empty() || aURL[0] != '#' )
2181 return;
2182
2183 // There might be a '|' as delimiter (if the link has been inserted
2184 // freshly) or a '%7c' or a '%7C' if the document has been saved and
2185 // loaded already.
2186 sal_Int32 nPos = aURL.size();
2187 bool bFound = false, bEncoded = false;
2188 while( !bFound && nPos > 0 )
2189 {
2190 sal_Unicode c = aURL[ --nPos ];
2191 switch( c )
2192 {
2193 case cMarkSeparator:
2194 bFound = true;
2195 break;
2196 case '%':
2197 bFound = (aURL.size() - nPos) >=3 && aURL[ nPos+1 ] == '7';
2198 if(bFound)
2199 {
2200 c = aURL[ nPos+2 ];
2201 bFound = (c == 'C' || c == 'c');
2202 }
2203 if( bFound )
2204 bEncoded = true;
2205 }
2206 }
2207 if( !bFound || nPos < 2 ) // at least "#a|..."
2208 return;
2209
2210 aURL = aURL.substr( 1 );
2211
2212 // nPos-1+1/3 (-1 because of Erase)
2213 OUString sCmp = OUString(aURL.substr(bEncoded ? nPos+2 : nPos)).replaceAll(" ","");
2214 if( sCmp.isEmpty() )
2215 return;
2216
2217 sCmp = sCmp.toAsciiLowerCase();
2218
2219 if( sCmp == "region" ||
2220 sCmp == "frame" ||
2221 sCmp == "graphic" ||
2222 sCmp == "ole" ||
2223 sCmp == "table" )
2224 {
2225 // Just remember it in a sorted array
2226 OUString aURL2(aURL);
2227 if( bEncoded )
2228 {
2229 aURL2 = aURL2.replaceAt( nPos - 1, 3, rtl::OUStringChar(cMarkSeparator) );
2230 }
2231 m_aImplicitMarks.insert( aURL2 );
2232 }
2233 else if( sCmp == "outline" )
2234 {
2235 // Here, we need position and name. That's why we sort a
2236 // sal_uInt16 and a string array ourselves.
2237 OUString aOutline( aURL.substr( 0, nPos-1 ) );
2238 SwPosition aPos( *m_pCurrentPam->GetPoint() );
2239 if( m_pDoc->GotoOutline( aPos, aOutline ) )
2240 {
2241 SwNodeOffset nIdx = aPos.GetNodeIndex();
2242
2243 decltype(m_aOutlineMarkPoss)::size_type nIns=0;
2244 while( nIns < m_aOutlineMarkPoss.size() &&
2245 m_aOutlineMarkPoss[nIns] < nIdx )
2246 nIns++;
2247
2248 m_aOutlineMarkPoss.insert( m_aOutlineMarkPoss.begin()+nIns, nIdx );
2249 OUString aURL2(aURL);
2250 if( bEncoded )
2251 {
2252 aURL2 = aURL2.replaceAt( nPos - 1, 3, rtl::OUStringChar(cMarkSeparator) );
2253 }
2254 m_aOutlineMarks.insert( m_aOutlineMarks.begin()+nIns, aURL2 );
2255 }
2256 }
2257}
2258
2260{
2261 const SwTextINetFormat* pTextAttr;
2262
2264 {
2265 auto pINetFormat = dynamic_cast<const SwFormatINetFormat*>(pItem);
2266 const SwTextNode* pTextNd;
2267
2268 if( pINetFormat &&
2269 nullptr != ( pTextAttr = pINetFormat->GetTextINetFormat()) &&
2270 nullptr != ( pTextNd = pTextAttr->GetpTextNode() ) &&
2271 pTextNd->GetNodes().IsDocNodes() )
2272 {
2273 AddLinkTarget( pINetFormat->GetValue() );
2274 }
2275 }
2276
2277 for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_URL))
2278 {
2279 auto pURL = dynamic_cast<const SwFormatURL*>(pItem);
2280 if( pURL )
2281 {
2282 AddLinkTarget( pURL->GetURL() );
2283 const ImageMap *pIMap = pURL->GetMap();
2284 if( pIMap )
2285 {
2286 for( size_t i=0; i<pIMap->GetIMapObjectCount(); ++i )
2287 {
2288 const IMapObject* pObj = pIMap->GetIMapObject( i );
2289 if( pObj )
2290 {
2291 AddLinkTarget( pObj->GetURL() );
2292 }
2293 }
2294 }
2295 }
2296 }
2297}
2298
2299/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GPOS_NONE
constexpr int nBorderWidth
static OutputDevice * GetDefaultDevice()
bool isAvailable() const
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
GraphicType GetType() const
GfxLink GetGfxLink() const
BitmapChecksum GetChecksum() const
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
void attribute(std::string_view aAttribute, const char *aValue)
void flushStack()
bool end(const OString &aElement)
void start(const OString &aElement)
void characters(std::string_view rChars)
const OUString & GetURL() const
const OUString & GetName() const
IMapObject * GetIMapObject(size_t nPos) const
size_t GetIMapObjectCount() const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
EnumT GetValue() const
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & WriteOString(std::string_view rStr)
SvStream & WriteChar(char nChar)
const editeng::SvxBorderLine * GetTop() const
sal_Int16 CalcLineSpace(SvxBoxItemLine nLine, bool bEvenIfNoLine=false, bool bAllowNegative=false) const
const editeng::SvxBorderLine * GetRight() const
const editeng::SvxBorderLine * GetLeft() const
const editeng::SvxBorderLine * GetBottom() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
const OUString & GetGraphicLink() const
tools::Long GetRight() const
tools::Long GetLeft() const
const SvxMacroTableDtor & GetMacroTable() const
bool empty() const
tools::Long GetRight() const
tools::Long GetHeight() const
tools::Long GetWidth() const
const Size & GetSize() const
tools::Long GetTextLeft() const
sal_uInt16 GetUpper() const
sal_uInt16 GetLower() const
const SwMirrorGrf & GetMirrorGrf(bool=true) const
Definition: grfatr.hxx:282
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
SS for PoolItems: hard attributation.
Definition: node.hxx:732
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:727
bool GotoOutline(SwPosition &rPos, const OUString &rName, SwRootFrame const *=nullptr) const
Definition: docnum.cxx:733
SwNodes & GetNodes()
Definition: doc.hxx:422
SwPosFlyFrames GetAllFlyFormats(const SwPaM *, bool bDrawAlso, bool bAsCharAlso=false) const
Returns positions of all FlyFrames in the document.
Definition: doclay.cxx:498
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
FlyAnchors.
Definition: fmtanchr.hxx:37
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1614
sal_uInt16 GetGutterWidth(bool bMin=false) const
Definition: atrfrm.cxx:918
sal_uInt16 GetNumCols() const
Definition: fmtclds.hxx:114
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:32
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:94
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:95
bool IsAnchorOnly() const
Definition: fmtsrnd.hxx:52
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
SfxPoolItem subclass that wraps a URL.
Definition: fmturl.hxx:33
const ImageMap * GetMap() const
Definition: fmturl.hxx:67
const OUString & GetName() const
Definition: fmturl.hxx:70
const OUString & GetTargetFrameName() const
Definition: fmturl.hxx:64
const OUString & GetURL() const
Definition: fmturl.hxx:65
bool IsServerMap() const
Definition: fmturl.hxx:66
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:57
const SvxBoxItem & GetBox(bool=true) const
Definition: frmatr.hxx:108
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const OUString & GetName() const
Definition: format.hxx:131
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:115
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:100
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:736
Style of a layout element.
Definition: frmfmt.hxx:72
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:153
virtual Size GetTwipSize() const override
Definition: ndgrf.cxx:409
bool IsLinkedFile() const
Definition: ndgrf.hxx:160
const Graphic & GetGrf(bool bWait=false) const
Definition: ndgrf.cxx:358
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:470
HtmlOut GetOutFn() const
Definition: htmlfly.hxx:118
const SdrObject * GetSdrObject() const
Definition: htmlfly.hxx:114
const SwFrameFormat & GetFormat() const
Definition: htmlfly.hxx:113
sal_Int32 GetContentIndex() const
Definition: htmlfly.hxx:116
AllHtmlFlags const & GetOutMode() const
Definition: htmlfly.hxx:117
HtmlPosition GetOutPos() const
Definition: htmlfly.hxx:119
bool mbXHTML
If XHTML markup should be written instead of HTML.
Definition: wrthtml.hxx:410
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
SwHTMLPosFlyFrames m_aHTMLPosFlyFrames
Definition: wrthtml.hxx:274
void ChangeParaToken(HtmlTokenId nNew)
Definition: htmlatr.cxx:160
static const SdrObject * GetMarqueeTextObj(const SwDrawFrameFormat &rFormat)
sal_uInt16 m_nImgMapCnt
Definition: wrthtml.hxx:328
std::set< OUString > m_aImplicitMarks
Definition: wrthtml.hxx:298
bool mbSkipImages
Definition: wrthtml.hxx:403
static OString convertDirection(SvxFrameDirection nDirection)
Definition: wrthtml.cxx:1502
std::vector< OUString > m_aImgMapNames
Definition: wrthtml.hxx:297
bool mbEmbedImages
Definition: wrthtml.hxx:406
SwHTMLFrameType GuessFrameType(const SwFrameFormat &rFrameFormat, const SdrObject *&rpStrObj)
void IncIndentLevel()
Definition: wrthtml.hxx:525
void OutDirection(SvxFrameDirection nDir)
Definition: wrthtml.cxx:1490
void OutFrameFormat(AllHtmlFlags nType, const SwFrameFormat &rFormat, const SdrObject *pSdrObj)
bool m_bLFPossible
Definition: wrthtml.hxx:395
ErrCode m_nWarn
Definition: wrthtml.hxx:323
OUString convertHyperlinkHRefValue(const OUString &rURL)
Definition: wrthtml.cxx:1344
bool m_bTextAttr
Definition: wrthtml.hxx:373
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
std::unique_ptr< utl::TempFileNamed > mpTempBaseURL
Temporary base URL for paste of images.
Definition: wrthtml.hxx:408
bool m_bTagOn
Definition: wrthtml.hxx:364
bool m_bOutFlyFrame
Definition: wrthtml.hxx:380
bool m_bCfgOutStyles
Definition: wrthtml.hxx:355
void AddLinkTarget(std::u16string_view aURL)
bool m_bExportImagesAsOLE
ReqIF mode: export images as OLE objects.
Definition: wrthtml.hxx:428
sal_Int32 m_nDfltRightMargin
Definition: wrthtml.hxx:334
std::vector< SwFormatINetFormat * > m_aINetFormats
Definition: wrthtml.hxx:307
void DecIndentLevel()
Definition: wrthtml.hxx:529
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
Definition: wrthtml.cxx:1586
void Out_SwDoc(SwPaM *)
Definition: wrthtml.cxx:900
sal_uInt16 m_nExportMode
Definition: wrthtml.hxx:345
sal_Int32 m_nDfltLeftMargin
Definition: wrthtml.hxx:333
bool mbReqIF
If the ReqIF subset of XHTML should be written.
Definition: wrthtml.hxx:414
OString OutFrameFormatOptions(const SwFrameFormat &rFrameFormat, const OUString &rAltText, HtmlFrmOpts nFrameOpts)
OString GetIndentString(sal_uInt16 nIncLvl=0)
Definition: wrthtml.cxx:1520
void OutCSS1_FrameFormatOptions(const SwFrameFormat &rFrameFormat, HtmlFrmOpts nFrameOpts, const SdrObject *pSdrObj=nullptr, const SfxItemSet *pItemSet=nullptr)
Definition: css1atr.cxx:1840
void CollectFlyFrames()
sal_uInt16 m_nDfltTopMargin
Definition: wrthtml.hxx:337
bool m_bClearLeft
Definition: wrthtml.hxx:393
sal_uInt16 m_nHeaderFooterSpace
Definition: wrthtml.hxx:343
static SwHTMLFrameType GuessOLENodeFrameType(const SwNode &rNd)
Definition: htmlplug.cxx:1193
sal_uInt16 m_nDfltBottomMargin
Definition: wrthtml.hxx:338
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1537
OString maNamespace
XML namespace, in case of XHTML.
Definition: wrthtml.hxx:412
void writeFrameFormatOptions(HtmlWriter &aHtml, const SwFrameFormat &rFrameFormat, std::u16string_view rAltText, HtmlFrmOpts nFrameOpts)
bool m_bCfgStarBasic
Definition: wrthtml.hxx:358
static const SdrObject * GetHTMLControl(const SwDrawFrameFormat &rFormat)
Definition: htmlforw.cxx:614
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:598
SvxFrameDirection GetHTMLDirection(SvxFrameDirection nDir) const
Definition: wrthtml.cxx:1471
static void GetEEAttrsFromDrwObj(SfxItemSet &rItemSet, const SdrObject *pObj)
bool m_bCfgCpyLinkedGrfs
Definition: wrthtml.hxx:359
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
Definition: wrthtml.cxx:1331
bool OutFlyFrame(SwNodeOffset nNdIdx, sal_Int32 nContentIdx, HtmlPosition nPos)
bool m_bOutFooter
Definition: wrthtml.hxx:379
OUString GetTitle() const
Definition: ndnotxt.cxx:258
Graphic GetGraphic() const
Definition: ndnotxt.cxx:229
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:111
Base class of the Writer document model elements.
Definition: node.hxx:98
bool IsGrfNode() const
Definition: node.hxx:195
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
bool IsTableNode() const
Definition: node.hxx:191
bool IsTextNode() const
Definition: node.hxx:190
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:691
SwContentNode * GetContentNode()
Definition: node.hxx:666
SwTableNode * GetTableNode()
Definition: node.hxx:650
bool IsOLENode() const
Definition: node.hxx:193
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2555
For querying current flys in document.
Definition: flypos.hxx:31
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
Definition: txtinet.hxx:30
const SwTextNode * GetpTextNode() const
Definition: txtinet.hxx:46
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:291
const OUString & GetText() const
Definition: ndtxt.hxx:244
const OUString * GetOrigFileName() const
Definition: shellio.hxx:438
SvStream & Strm()
Definition: writer.cxx:193
SwDoc * m_pDoc
Definition: shellio.hxx:407
std::shared_ptr< SwUnoCursor > m_pCurrentPam
Definition: shellio.hxx:409
bool m_bWriteAll
Definition: shellio.hxx:410
const OUString & GetBaseURL() const
Definition: shellio.hxx:443
bool CopyLocalFileToINet(OUString &rFileNm)
Definition: writer.cxx:264
static ErrCode WriteGraphic(const Graphic &rGraphic, OUString &rFileName, const OUString &rFilterName, const XOutFlags nFlags, const Size *pMtfSize_100TH_MM=nullptr, const css::uno::Sequence< css::beans::PropertyValue > *pFilterData=nullptr, OUString *pMediaType=nullptr)
static bool GraphicToBase64(const Graphic &rGraphic, OUString &rOUString, bool bAddPrefix=true, ConvertDataFormat aTargetFormat=ConvertDataFormat::Unknown)
Value erase_extract(size_t index)
bool empty() const
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
tools::Long getOpenHeight() const
tools::Long getOpenWidth() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
URL aURL
float u
EmbeddedObjectRef * pObject
#define ERRCODE_NONE
std::set< SwPosFlyFrame, SwPosFlyFrameCmp > SwPosFlyFrames
Definition: flypos.hxx:45
DocumentType eType
@ Fixed
Frame cannot be moved in Var-direction.
SvxFrameDirection
constexpr TypedWhichId< SwFormatURL > RES_URL(117)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatCol > RES_COL(115)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxMacroItem > RES_FRMMACRO(114)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SvxRightMarginItem > RES_MARGIN_RIGHT(93)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(107)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
HTMLOutEvent const aAnchorEventTable[]
Definition: htmlatr.cxx:86
SwAttrFnTab aHTMLAttrFnTab
Definition: htmlatr.cxx:3219
SwHTMLWriter & OutHTML_INetFormat(SwHTMLWriter &rWrt, const SwFormatINetFormat &rINetFormat, bool bOn)
Definition: htmlatr.cxx:2958
SwHTMLWriter & OutHTML_DrawFrameFormatAsMarquee(SwHTMLWriter &rWrt, const SwDrawFrameFormat &rFormat, const SdrObject &rSdrObject)
HtmlContainerFlags
Definition: htmlfly.hxx:73
AllHtmlFlags getHTMLOutFrameParaPrtAreaTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
Definition: htmlflyt.cxx:294
SwHTMLFrameType
Definition: htmlfly.hxx:34
@ HTML_FRMTYPE_GRF
Definition: htmlfly.hxx:40
@ HTML_FRMTYPE_MARQUEE
Definition: htmlfly.hxx:45
@ HTML_FRMTYPE_MULTICOL
Definition: htmlfly.hxx:37
@ HTML_FRMTYPE_EMPTY
Definition: htmlfly.hxx:38
@ HTML_FRMTYPE_CONTROL
Definition: htmlfly.hxx:46
@ HTML_FRMTYPE_DRAW
Definition: htmlfly.hxx:47
@ HTML_FRMTYPE_TABLE
Definition: htmlfly.hxx:35
@ HTML_FRMTYPE_TEXT
Definition: htmlfly.hxx:39
@ HTML_FRMTYPE_TABLE_CAP
Definition: htmlfly.hxx:36
AllHtmlFlags getHTMLOutFramePageFlyTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
Definition: htmlflyt.cxx:109
AllHtmlFlags getHTMLOutFrameParaOtherTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
Definition: htmlflyt.cxx:386
HtmlPosition
Definition: htmlfly.hxx:66
HtmlOut
Definition: htmlfly.hxx:51
@ GraphicFrame
AllHtmlFlags getHTMLOutFrameParaFrameTable(SwHTMLFrameType eFrameType, sal_uInt16 nExportMode)
Definition: htmlflyt.cxx:202
SwHTMLWriter & OutHTML_HeaderFooter(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, bool bHeader)
static SwHTMLWriter & OutHTML_FrameFormatAsDivOrSpan(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, bool bSpan)
SwHTMLWriter & OutHTML_BulletImage(SwHTMLWriter &rWrt, const char *pTag, const SvxBrushItem *pBrush, const OUString &rGraphicURL)
static SwHTMLWriter & OutHTML_FrameFormatTableNode(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat)
HTMLOutEvent const aIMapEventTable[]
HTMLOutEvent const aImageEventTable[]
const HtmlFrmOpts HTML_FRMOPTS_SPACER
static SwHTMLWriter & OutHTML_FrameFormatAsMulticol(SwHTMLWriter &rWrt, const SwFrameFormat &rFormat, bool bInCntnr)
const HtmlFrmOpts HTML_FRMOPTS_IMG_CNTNR
SwHTMLWriter & OutHTML_ImageEnd(HtmlWriter &rHtml, SwHTMLWriter &rWrt)
static SwHTMLWriter & OutHTML_FrameFormatGrfNode(SwHTMLWriter &rWrt, const SwFrameFormat &rFormat, bool bInCntnr, bool bPNGFallback)
const HtmlFrmOpts HTML_FRMOPTS_IMG
static void OutHTML_ImageOLEEnd(SwHTMLWriter &rWrt)
Ends the OLE version of an image in the ReqIF + OLE case.
const HtmlFrmOpts HTML_FRMOPTS_DIV
const HtmlFrmOpts HTML_FRMOPTS_MULTICOL
static SwHTMLWriter & OutHTML_FrameFormatAsImage(SwHTMLWriter &rWrt, const SwFrameFormat &rFormat, bool bPNGFallback)
SwHTMLWriter & OutHTML_ImageStart(HtmlWriter &rHtml, SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, const OUString &rGraphicURL, Graphic const &rGraphic, const OUString &rAlternateText, const Size &rRealSize, HtmlFrmOpts nFrameOpts, const char *pMarkType, const ImageMap *pAltImgMap, std::u16string_view rMimeType)
const HtmlFrmOpts HTML_FRMOPTS_CNTNR
const HtmlFrmOpts HTML_FRMOPTS_MULTICOL_CSS1
static SwHTMLWriter & OutHTML_FrameFormatAsMarquee(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, const SdrObject &rSdrObj)
const HtmlFrmOpts HTML_FRMOPTS_IMG_CSS1
const HtmlFrmOpts HTML_FRMOPTS_IMG_ALL
static void OutHTML_ImageOLEStart(SwHTMLWriter &rWrt, const Graphic &rGraphic, const SwFrameFormat &rFrameFormat)
Starts the OLE version of an image in the ReqIF + OLE case.
static SwHTMLWriter & OutHTML_FrameFormatAsSpacer(SwHTMLWriter &rWrt, const SwFrameFormat &rFormat)
SwHTMLWriter & OutHTML_DrawFrameFormatAsControl(SwHTMLWriter &rWrt, const SwDrawFrameFormat &rFormat, const SdrUnoObj &rFormObj, bool bInCntnr)
Definition: htmlforw.cxx:673
#define OOO_STRING_SVTOOLS_HTML_O_height
#define OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical
#define OOO_STRING_SVTOOLS_HTML_O_data
#define OOO_STRING_SVTOOLS_HTML_O_target
#define OOO_STRING_SVTOOLS_HTML_O_clear
#define OOO_STRING_SVTOOLS_HTML_O_color
#define OOO_STRING_SVTOOLS_HTML_AL_left
#define OOO_STRING_SVTOOLS_HTML_O_SDonmouseover
#define OOO_STRING_SVTOOLS_HTML_O_align
#define OOO_STRING_SVTOOLS_HTML_division
#define OOO_STRING_SVTOOLS_HTML_O_title
#define OOO_STRING_SVTOOLS_HTML_O_SDonerror
#define OOO_STRING_SVTOOLS_HTML_VA_middle
#define OOO_STRING_SVTOOLS_HTML_O_SDonmouseout
#define OOO_STRING_SVTOOLS_HTML_O_onmouseout
#define OOO_STRING_SVTOOLS_HTML_O_dir
#define OOO_STRING_SVTOOLS_HTML_spacer
#define OOO_STRING_SVTOOLS_HTML_O_onmouseover
#define OOO_STRING_SVTOOLS_HTML_VA_absmiddle
#define OOO_STRING_SVTOOLS_HTML_O_size
#define OOO_STRING_SVTOOLS_HTML_SPTYPE_block
#define OOO_STRING_SVTOOLS_HTML_anchor
#define OOO_STRING_SVTOOLS_HTML_VA_bottom
#define OOO_STRING_SVTOOLS_HTML_O_onerror
#define OOO_STRING_SVTOOLS_HTML_multicol
#define OOO_STRING_SVTOOLS_HTML_span
#define OOO_STRING_SVTOOLS_HTML_VA_absbottom
#define OOO_STRING_SVTOOLS_HTML_O_src
#define OOO_STRING_SVTOOLS_HTML_VA_top
#define OOO_STRING_SVTOOLS_HTML_O_cols
#define OOO_STRING_SVTOOLS_HTML_O_SDonabort
#define OOO_STRING_SVTOOLS_HTML_image
#define OOO_STRING_SVTOOLS_HTML_O_SDonload
#define OOO_STRING_SVTOOLS_HTML_map
#define OOO_STRING_SVTOOLS_HTML_O_class
#define OOO_STRING_SVTOOLS_HTML_O_href
#define OOO_STRING_SVTOOLS_HTML_O_onabort
#define OOO_STRING_SVTOOLS_HTML_O_hspace
#define OOO_STRING_SVTOOLS_HTML_VA_texttop
#define OOO_STRING_SVTOOLS_HTML_AL_right
#define OOO_STRING_SVTOOLS_HTML_O_ismap
#define OOO_STRING_SVTOOLS_HTML_O_border
#define OOO_STRING_SVTOOLS_HTML_O_vspace
#define OOO_STRING_SVTOOLS_HTML_O_type
#define OOO_STRING_SVTOOLS_HTML_O_onload
#define OOO_STRING_SVTOOLS_HTML_O_name
#define OOO_STRING_SVTOOLS_HTML_font
#define OOO_STRING_SVTOOLS_HTML_O_id
#define OOO_STRING_SVTOOLS_HTML_O_gutter
#define OOO_STRING_SVTOOLS_HTML_O_width
#define OOO_STRING_SVTOOLS_HTML_object
#define OOO_STRING_SVTOOLS_HTML_linebreak
#define OOO_STRING_SVTOOLS_HTML_O_usemap
#define OOO_STRING_SVTOOLS_HTML_O_alt
#define OOO_STRING_SVTOOLS_HTML_O_style
SwHTMLWriter & OutHTML_FrameFormatOLENode(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1221
SwHTMLWriter & OutHTML_FrameFormatOLENodeGrf(SwHTMLWriter &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr, bool bWriteReplacementGraphic)
Definition: htmlplug.cxx:1487
SwHTMLWriter & OutHTML_SwTableNode(SwHTMLWriter &rWrt, SwTableNode &rNode, const SwFrameFormat *pFlyFrameFormat, const OUString *pCaption, bool bTopCaption)
Definition: htmltabw.cxx:913
OUString aName
sal_uInt16 nPos
#define SAL_WARN(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
@ HideFieldmarkCommands
bool WrapGraphicInRtf(const Graphic &rGraphic, const SwFrameFormat &rFormat, SvStream &rRtf)
Wraps an image in an RTF fragment.
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
OUString encodeForXml(std::u16string_view rStr)
int i
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const sal_Unicode *const aMimeType[]
HtmlOut nOut
Definition: htmlfly.hxx:83
HtmlContainerFlags nContainer
Definition: htmlfly.hxx:85
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 bool PrivateURLToInternalImg(OUString &rURL)
static SVT_DLLPUBLIC SvStream & Out_ImageMap(SvStream &, const OUString &, const ImageMap &, const OUString &, const HTMLOutEvent *pEventTable, bool bOutStarBasic, const char *pDelim, const char *pIndentArea, const char *pIndentMap)
static SVT_DLLPUBLIC SvStream & FlushToAscii(SvStream &)
static SVT_DLLPUBLIC void applyEvents(HtmlWriter &rHtmlWriter, const SvxMacroTableDtor &rMacroTable, const HTMLOutEvent *pEventTable, bool bOutStarBasic)
static SVT_DLLPUBLIC void applyColor(HtmlWriter &rHtmlWriter, std::string_view aAttributeName, const Color &rColor)
Marks a position in the document model.
Definition: pam.hxx:38
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:78
#define WARN_SWG_POOR_LOAD
Definition: swerror.h:39
RndStdIds
tools::Long SwTwips
Definition: swtypes.hxx:51
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:124
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
Any result
SwHTMLWriter & Out_SfxItemSet(const SwAttrFnTab, SwHTMLWriter &, const SfxItemSet &, bool bDeep)
Definition: wrt_fn.cxx:42
HtmlFrmOpts
Definition: wrthtml.hxx:76
@ Replacement
The graphic frame is a replacement image of an OLE object.
#define HTML_PARSPACE
Definition: wrthtml.hxx:70
#define HTMLMODE_BORDER_NONE
Definition: wrthtml.hxx:126
#define HTMLMODE_ABS_POS_FLY
Definition: wrthtml.hxx:123
#define HTMLMODE_VERT_SPACER
Definition: wrthtml.hxx:118
XOutFlags