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