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::shared_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.Width() >= 0 && aTwipSz.Height() >= 0,
689  "Frame size minus spacing < 0!!!???" );
690  if( aTwipSz.Width() < 0 )
691  aTwipSz.setWidth( 0 );
692  if( aTwipSz.Height() < 0 )
693  aTwipSz.setHeight( 0 );
694 
695  Size aPixelSz( 0, 0 );
696  if( (aTwipSz.Width() || aTwipSz.Height()) &&
698  {
699  aPixelSz =
701  MapMode(MapUnit::MapTwip) );
702  if( !aPixelSz.Width() && aTwipSz.Width() )
703  aPixelSz.setWidth( 1 );
704  if( !aPixelSz.Height() && aTwipSz.Height() )
705  aPixelSz.setHeight( 1 );
706  }
707 
708  if( (nFrameOpts & HtmlFrmOpts::Width) &&
709  ((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
710  {
711  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
712  append("=\"");
713  if( nPercentWidth )
714  sOut.append(static_cast<sal_Int32>(nPercentWidth)).append('%');
715  else
716  sOut.append(static_cast<sal_Int32>(aPixelSz.Width()));
717  sOut.append("\"");
718  }
719 
720  if( (nFrameOpts & HtmlFrmOpts::Height) &&
721  ((nPercentHeight && nPercentHeight!=255) || aPixelSz.Height()) )
722  {
723  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
724  append("=\"");
725  if( nPercentHeight )
726  sOut.append(static_cast<sal_Int32>(nPercentHeight)).append('%');
727  else
728  sOut.append(static_cast<sal_Int32>(aPixelSz.Height()));
729  sOut.append("\"");
730  }
731  }
732 
733  if (!sOut.isEmpty())
734  Strm().WriteOString( sOut.makeStringAndClear() );
735 
736  // Insert wrap for graphics that are anchored to a paragraph as
737  // <BR CLEAR=...> in the string
738  if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
739  ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
740  (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
741  SfxItemState::SET == rItemSet.GetItemState( RES_SURROUND, true, &pItem ))
742  {
743  const SwFormatSurround* pSurround = static_cast<const SwFormatSurround*>(pItem);
744  sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
745  pStr = nullptr;
746  css::text::WrapTextMode eSurround = pSurround->GetSurround();
747  bool bAnchorOnly = pSurround->IsAnchorOnly();
748  switch( eHoriOri )
749  {
750  case text::HoriOrientation::RIGHT:
751  {
752  switch( eSurround )
753  {
754  case css::text::WrapTextMode_NONE:
755  case css::text::WrapTextMode_RIGHT:
757  break;
758  case css::text::WrapTextMode_LEFT:
759  case css::text::WrapTextMode_PARALLEL:
760  if( bAnchorOnly )
761  m_bClearRight = true;
762  break;
763  default:
764  ;
765  }
766  }
767  break;
768 
769  default:
770  // If a frame is centered, it gets left aligned. This
771  // should be taken into account here, too.
772  {
773  switch( eSurround )
774  {
775  case css::text::WrapTextMode_NONE:
776  case css::text::WrapTextMode_LEFT:
778  break;
779  case css::text::WrapTextMode_RIGHT:
780  case css::text::WrapTextMode_PARALLEL:
781  if( bAnchorOnly )
782  m_bClearLeft = true;
783  break;
784  default:
785  ;
786  }
787  }
788  break;
789 
790  }
791 
792  if( pStr )
793  {
794  sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_linebreak).
795  append(' ').append(OOO_STRING_SVTOOLS_HTML_O_clear).
796  append("=\"").append(pStr).append("\">");
797  sRetEndTags = sOut.makeStringAndClear();
798  }
799  }
800  return sRetEndTags;
801 }
802 
803 void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAlternateText, HtmlFrmOpts nFrameOptions)
804 {
805  bool bReplacement = (nFrameOptions & HtmlFrmOpts::Replacement) || mbReqIF;
806  const SfxPoolItem* pItem;
807  const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
808 
809  // Name
810  if( (nFrameOptions & (HtmlFrmOpts::Id|HtmlFrmOpts::Name)) &&
811  !rFrameFormat.GetName().isEmpty() && !bReplacement)
812  {
813  const char* pAttributeName = (nFrameOptions & HtmlFrmOpts::Id) ? OOO_STRING_SVTOOLS_HTML_O_id : OOO_STRING_SVTOOLS_HTML_O_name;
814  aHtml.attribute(pAttributeName, rFrameFormat.GetName());
815  }
816 
817  // Name
818  if (nFrameOptions & HtmlFrmOpts::Dir)
819  {
820  SvxFrameDirection nCurrentDirection = GetHTMLDirection(rItemSet);
821  OString sDirection = convertDirection(nCurrentDirection);
822  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_dir, sDirection);
823  }
824 
825  // alt
826  if( (nFrameOptions & HtmlFrmOpts::Alt) && !rAlternateText.isEmpty() && !bReplacement )
827  {
828  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_alt, rAlternateText);
829  }
830 
831  // align
832  const char* pAlignString = nullptr;
833  RndStdIds eAnchorId = rFrameFormat.GetAnchor().GetAnchorId();
834  if( (nFrameOptions & HtmlFrmOpts::Align) &&
835  ((RndStdIds::FLY_AT_PARA == eAnchorId) || (RndStdIds::FLY_AT_CHAR == eAnchorId)) && !bReplacement)
836  {
837  const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
838  if( !(nFrameOptions & HtmlFrmOpts::SAlign) ||
839  text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() ||
840  text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() )
841  {
842  pAlignString = text::HoriOrientation::RIGHT == rHoriOri.GetHoriOrient()
845  }
846  }
847  if( (nFrameOptions & HtmlFrmOpts::Align) && !pAlignString &&
848  ( !(nFrameOptions & HtmlFrmOpts::SAlign) ||
849  (RndStdIds::FLY_AS_CHAR == eAnchorId) ) &&
850  SfxItemState::SET == rItemSet.GetItemState( RES_VERT_ORIENT, true, &pItem ))
851  {
852  switch( static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
853  {
854  case text::VertOrientation::LINE_TOP: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_top; break;
855  case text::VertOrientation::CHAR_TOP:
856  case text::VertOrientation::BOTTOM: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_texttop; break;
857  case text::VertOrientation::LINE_CENTER:
858  case text::VertOrientation::CHAR_CENTER: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_absmiddle; break;
859  case text::VertOrientation::CENTER: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_middle; break;
860  case text::VertOrientation::LINE_BOTTOM:
861  case text::VertOrientation::CHAR_BOTTOM: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_absbottom; break;
862  case text::VertOrientation::TOP: pAlignString = OOO_STRING_SVTOOLS_HTML_VA_bottom; break;
863  case text::VertOrientation::NONE: break;
864  }
865  }
866  if (pAlignString && !bReplacement)
867  {
868  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_align, pAlignString);
869  }
870 
871  // hspace and vspace
872  Size aTwipSpc( 0, 0 );
873  if( (nFrameOptions & (HtmlFrmOpts::Space | HtmlFrmOpts::MarginSize)) &&
874  SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, true, &pItem ))
875  {
876  aTwipSpc.setWidth(
877  ( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() +
878  static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) / 2 );
879  m_nDfltLeftMargin = m_nDfltRightMargin = aTwipSpc.Width();
880  }
881  if( (nFrameOptions & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) &&
882  SfxItemState::SET == rItemSet.GetItemState( RES_UL_SPACE, true, &pItem ))
883  {
884  aTwipSpc.setHeight(
885  ( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() +
886  static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) / 2 );
887  m_nDfltTopMargin = m_nDfltBottomMargin = static_cast<sal_uInt16>(aTwipSpc.Height());
888  }
889 
890  if( (nFrameOptions & HtmlFrmOpts::Space) &&
891  (aTwipSpc.Width() || aTwipSpc.Height()) &&
893  {
894  Size aPixelSpc =
896  MapMode(MapUnit::MapTwip) );
897  if( !aPixelSpc.Width() && aTwipSpc.Width() )
898  aPixelSpc.setWidth( 1 );
899  if( !aPixelSpc.Height() && aTwipSpc.Height() )
900  aPixelSpc.setHeight( 1 );
901 
902  if (aPixelSpc.Width())
903  {
904  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_hspace, static_cast<sal_Int32>(aPixelSpc.Width()));
905  }
906 
907  if (aPixelSpc.Height())
908  {
909  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_vspace, static_cast<sal_Int32>(aPixelSpc.Height()));
910  }
911  }
912 
913  // The spacing must be considered for the size, if the corresponding flag
914  // is set.
915  if( nFrameOptions & HtmlFrmOpts::MarginSize )
916  {
917  aTwipSpc.setWidth( aTwipSpc.Width() * -2 );
918  aTwipSpc.setHeight( aTwipSpc.Height() * -2 );
919  }
920  else
921  {
922  aTwipSpc.setWidth( 0 );
923  aTwipSpc.setHeight( 0 );
924  }
925 
926  if( !(nFrameOptions & HtmlFrmOpts::AbsSize) &&
927  SfxItemState::SET == rItemSet.GetItemState( RES_BOX, true, &pItem ))
928  {
929  const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
930 
931  aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT ) );
932  aTwipSpc.AdjustWidth(pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) );
933  aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::TOP ) );
934  aTwipSpc.AdjustHeight(pBoxItem->CalcLineSpace( SvxBoxItemLine::BOTTOM ) );
935  }
936 
937  // "width" and/or "height"
938  // Only output SwFrameSize::Variable/SwFrameSize::Minimum if ANYSIZE is set
939  if( (nFrameOptions & HtmlFrmOpts::Size) &&
940  SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ) &&
941  ( (nFrameOptions & HtmlFrmOpts::AnySize) ||
942  SwFrameSize::Fixed == static_cast<const SwFormatFrameSize *>(pItem)->GetHeightSizeType()) )
943  {
944  const SwFormatFrameSize *pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
945  sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
946  sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();
947 
948  // Size of the object in Twips without margins
949  Size aTwipSz( (nPercentWidth ? 0
950  : pFSItem->GetWidth()-aTwipSpc.Width()),
951  (nPercentHeight ? 0
952  : pFSItem->GetHeight()-aTwipSpc.Height()) );
953 
954  OSL_ENSURE( aTwipSz.Width() >= 0 && aTwipSz.Height() >= 0,
955  "Frame size minus spacing < 0!!!???" );
956  if( aTwipSz.Width() < 0 )
957  aTwipSz.setWidth( 0 );
958  if( aTwipSz.Height() < 0 )
959  aTwipSz.setHeight( 0 );
960 
961  Size aPixelSz( 0, 0 );
962  if( (aTwipSz.Width() || aTwipSz.Height()) &&
964  {
965  aPixelSz =
967  MapMode(MapUnit::MapTwip) );
968  if( !aPixelSz.Width() && aTwipSz.Width() )
969  aPixelSz.setWidth( 1 );
970  if( !aPixelSz.Height() && aTwipSz.Height() )
971  aPixelSz.setHeight( 1 );
972  }
973 
974  if( (nFrameOptions & HtmlFrmOpts::Width) &&
975  ((nPercentWidth && nPercentWidth!=255) || aPixelSz.Width()) )
976  {
977  OString sWidth;
978  if (nPercentWidth)
979  sWidth = OString::number(static_cast<sal_Int32>(nPercentWidth)) + "%";
980  else
981  sWidth = OString::number(static_cast<sal_Int32>(aPixelSz.Width()));
983  }
984 
985  if( (nFrameOptions & HtmlFrmOpts::Height) &&
986  ((nPercentHeight && nPercentHeight!=255) || aPixelSz.Height()) )
987  {
988  OString sHeight;
989  if (nPercentHeight)
990  sHeight = OString::number(static_cast<sal_Int32>(nPercentHeight)) + "%";
991  else
992  sHeight = OString::number(static_cast<sal_Int32>(aPixelSz.Height()));
994  }
995  }
996 
997  // Insert wrap for graphics that are anchored to a paragraph as
998  // <BR CLEAR=...> in the string
999 
1000  if( (nFrameOptions & HtmlFrmOpts::BrClear) &&
1001  ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
1002  (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
1003  SfxItemState::SET == rItemSet.GetItemState( RES_SURROUND, true, &pItem ))
1004  {
1005  const char* pSurroundString = nullptr;
1006 
1007  const SwFormatSurround* pSurround = static_cast<const SwFormatSurround*>(pItem);
1008  sal_Int16 eHoriOri = rFrameFormat.GetHoriOrient().GetHoriOrient();
1009  css::text::WrapTextMode eSurround = pSurround->GetSurround();
1010  bool bAnchorOnly = pSurround->IsAnchorOnly();
1011  switch( eHoriOri )
1012  {
1013  case text::HoriOrientation::RIGHT:
1014  {
1015  switch( eSurround )
1016  {
1017  case css::text::WrapTextMode_NONE:
1018  case css::text::WrapTextMode_RIGHT:
1019  pSurroundString = OOO_STRING_SVTOOLS_HTML_AL_right;
1020  break;
1021  case css::text::WrapTextMode_LEFT:
1022  case css::text::WrapTextMode_PARALLEL:
1023  if( bAnchorOnly )
1024  m_bClearRight = true;
1025  break;
1026  default:
1027  ;
1028  }
1029  }
1030  break;
1031 
1032  default:
1033  // If a frame is centered, it gets left aligned. This
1034  // should be taken into account here, too.
1035  {
1036  switch( eSurround )
1037  {
1038  case css::text::WrapTextMode_NONE:
1039  case css::text::WrapTextMode_LEFT:
1040  pSurroundString = OOO_STRING_SVTOOLS_HTML_AL_left;
1041  break;
1042  case css::text::WrapTextMode_RIGHT:
1043  case css::text::WrapTextMode_PARALLEL:
1044  if( bAnchorOnly )
1045  m_bClearLeft = true;
1046  break;
1047  default:
1048  break;
1049  }
1050  }
1051  break;
1052  }
1053 
1054  if (pSurroundString)
1055  {
1057  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_clear, pSurroundString);
1058  aHtml.end();
1059  }
1060  }
1061 }
1062 
1063 namespace
1064 {
1065 
1066 OUString lclWriteOutImap(SwHTMLWriter& rHTMLWrt, const SfxItemSet& rItemSet, const SwFrameFormat& rFrameFormat,
1067  const Size& rRealSize, const ImageMap* pAltImgMap, const SwFormatURL*& pURLItem)
1068 {
1069  OUString aIMapName;
1070 
1071  const SfxPoolItem* pItem;
1072 
1073  // Only consider the URL attribute if no ImageMap was supplied
1074  if (!pAltImgMap && SfxItemState::SET == rItemSet.GetItemState( RES_URL, true, &pItem))
1075  {
1076  pURLItem = static_cast<const SwFormatURL*>( pItem);
1077  }
1078 
1079  // write ImageMap
1080  const ImageMap* pIMap = pAltImgMap;
1081  if( !pIMap && pURLItem )
1082  {
1083  pIMap = pURLItem->GetMap();
1084  }
1085 
1086  if (pIMap)
1087  {
1088  // make the name unique
1089  aIMapName = pIMap->GetName();
1090  OUString aNameBase;
1091  if (!aIMapName.isEmpty())
1092  aNameBase = aIMapName;
1093  else
1094  aNameBase = OOO_STRING_SVTOOLS_HTML_map;
1095 
1096  if (aIMapName.isEmpty())
1097  aIMapName = aNameBase + OUString::number(rHTMLWrt.m_nImgMapCnt);
1098 
1099  bool bFound;
1100  do
1101  {
1102  bFound = false;
1103  for (const OUString & rImgMapName : rHTMLWrt.m_aImgMapNames)
1104  {
1105  // TODO: Unicode: Comparison is case insensitive for ASCII
1106  // characters only now!
1107  if (aIMapName.equalsIgnoreAsciiCase(rImgMapName))
1108  {
1109  bFound = true;
1110  break;
1111  }
1112  }
1113  if (bFound)
1114  {
1115  rHTMLWrt.m_nImgMapCnt++;
1116  aIMapName = aNameBase + OUString::number( rHTMLWrt.m_nImgMapCnt );
1117  }
1118  } while (bFound);
1119 
1120  bool bScale = false;
1121  Fraction aScaleX(1, 1);
1122  Fraction aScaleY(1, 1);
1123 
1124  const SwFormatFrameSize& rFrameSize = rFrameFormat.GetFrameSize();
1125  const SvxBoxItem& rBox = rFrameFormat.GetBox();
1126 
1127  if (!rFrameSize.GetWidthPercent() && rRealSize.Width())
1128  {
1129  SwTwips nWidth = rFrameSize.GetWidth();
1130  nWidth -= rBox.CalcLineSpace(SvxBoxItemLine::LEFT) + rBox.CalcLineSpace(SvxBoxItemLine::RIGHT);
1131 
1132  OSL_ENSURE( nWidth > 0, "Are there any graphics that are 0 twip wide!?" );
1133  if (nWidth <= 0) // should not happen
1134  nWidth = 1;
1135 
1136  if (rRealSize.Width() != nWidth)
1137  {
1138  aScaleX = Fraction(nWidth, rRealSize.Width());
1139  bScale = true;
1140  }
1141  }
1142 
1143  if (!rFrameSize.GetHeightPercent() && rRealSize.Height())
1144  {
1145  SwTwips nHeight = rFrameSize.GetHeight();
1146 
1147  nHeight -= rBox.CalcLineSpace(SvxBoxItemLine::TOP) + rBox.CalcLineSpace(SvxBoxItemLine::BOTTOM);
1148 
1149  OSL_ENSURE( nHeight > 0, "Are there any graphics that are 0 twip high!?" );
1150  if (nHeight <= 0)
1151  nHeight = 1;
1152 
1153  if (rRealSize.Height() != nHeight)
1154  {
1155  aScaleY = Fraction(nHeight, rRealSize.Height());
1156  bScale = true;
1157  }
1158  }
1159 
1160  rHTMLWrt.m_aImgMapNames.push_back(aIMapName);
1161 
1162  OString aIndMap, aIndArea;
1163  const char *pIndArea = nullptr, *pIndMap = nullptr;
1164 
1165  if (rHTMLWrt.m_bLFPossible)
1166  {
1167  rHTMLWrt.OutNewLine( true );
1168  aIndMap = rHTMLWrt.GetIndentString();
1169  aIndArea = rHTMLWrt.GetIndentString(1);
1170  pIndArea = aIndArea.getStr();
1171  pIndMap = aIndMap.getStr();
1172  }
1173 
1174  if (bScale)
1175  {
1176  ImageMap aScaledIMap(*pIMap);
1177  aScaledIMap.Scale(aScaleX, aScaleY);
1178  HTMLOutFuncs::Out_ImageMap( rHTMLWrt.Strm(), rHTMLWrt.GetBaseURL(), aScaledIMap, aIMapName,
1180  rHTMLWrt.m_bCfgStarBasic,
1181  SAL_NEWLINE_STRING, pIndArea, pIndMap,
1182  rHTMLWrt.m_eDestEnc,
1183  &rHTMLWrt.m_aNonConvertableCharacters );
1184  }
1185  else
1186  {
1187  HTMLOutFuncs::Out_ImageMap( rHTMLWrt.Strm(), rHTMLWrt.GetBaseURL(), *pIMap, aIMapName,
1189  rHTMLWrt.m_bCfgStarBasic,
1190  SAL_NEWLINE_STRING, pIndArea, pIndMap,
1191  rHTMLWrt.m_eDestEnc,
1192  &rHTMLWrt.m_aNonConvertableCharacters );
1193  }
1194  }
1195  return aIMapName;
1196 }
1197 
1198 }
1199 
1200 Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
1201  const OUString& rGraphicURL,
1202  Graphic const & rGraphic, const OUString& rAlternateText,
1203  const Size &rRealSize, HtmlFrmOpts nFrameOpts,
1204  const char *pMarkType,
1205  const ImageMap *pAltImgMap,
1206  const OUString& rMimeType )
1207 {
1208  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1209  // <object data="..."> instead of <img src="...">
1210  bool bReplacement = (nFrameOpts & HtmlFrmOpts::Replacement) || rHTMLWrt.mbReqIF;
1211 
1212  if (rHTMLWrt.mbSkipImages)
1213  return rHTMLWrt;
1214 
1215  // if necessary, temporarily close an open attribute
1216  if( !rHTMLWrt.m_aINetFormats.empty() )
1217  {
1218  SwFormatINetFormat* pINetFormat = rHTMLWrt.m_aINetFormats.back();
1219  OutHTML_INetFormat( rWrt, *pINetFormat, false );
1220  }
1221 
1222  OUString aGraphicURL( rGraphicURL );
1223  if( !rHTMLWrt.mbEmbedImages && !HTMLOutFuncs::PrivateURLToInternalImg(aGraphicURL) && !rHTMLWrt.mpTempBaseURL )
1224  aGraphicURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), aGraphicURL);
1225 
1226  const SfxPoolItem* pItem;
1227  const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
1228 
1229  const SwFormatURL* pURLItem = nullptr;
1230  OUString aIMapName = lclWriteOutImap(rHTMLWrt, rItemSet, rFrameFormat, rRealSize, pAltImgMap, pURLItem);
1231 
1232  // put img into new line
1233  if( rHTMLWrt.m_bLFPossible )
1234  rHTMLWrt.OutNewLine( true );
1235 
1236  HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
1237 
1238  // <a name=...></a>...<img ...>
1239  if( pMarkType && !rFrameFormat.GetName().isEmpty() )
1240  {
1241  rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(), pMarkType );
1242  }
1243 
1244  // URL -> <a>...<img ... >...</a>
1245  const SvxMacroItem *pMacItem = nullptr;
1246  if (SfxItemState::SET == rItemSet.GetItemState(RES_FRMMACRO, true, &pItem))
1247  {
1248  pMacItem = static_cast<const SvxMacroItem *>(pItem);
1249  }
1250 
1251  if (pURLItem || pMacItem)
1252  {
1253  OUString aMapURL;
1254  OUString aName;
1255  OUString aTarget;
1256 
1257  if(pURLItem)
1258  {
1259  aMapURL = pURLItem->GetURL();
1260  aName = pURLItem->GetName();
1261  aTarget = pURLItem->GetTargetFrameName();
1262  }
1263 
1264  bool bEvents = pMacItem && !pMacItem->GetMacroTable().empty();
1265 
1266  if( !aMapURL.isEmpty() || !aName.isEmpty() || !aTarget.isEmpty() || bEvents )
1267  {
1268  aHtml.start(OOO_STRING_SVTOOLS_HTML_anchor);
1269 
1270  // Output "href" element if a link or macro exists
1271  if( !aMapURL.isEmpty() || bEvents )
1272  {
1273  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_href, OUStringToOString(rHTMLWrt.convertHyperlinkHRefValue(aMapURL), RTL_TEXTENCODING_UTF8));
1274  }
1275 
1276  if( !aName.isEmpty() )
1277  {
1278  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_name, OUStringToOString(aName, RTL_TEXTENCODING_UTF8));
1279  }
1280 
1281  if( !aTarget.isEmpty() )
1282  {
1283  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_target, OUStringToOString(aTarget, RTL_TEXTENCODING_UTF8));
1284  }
1285 
1286  if( pMacItem )
1287  {
1288  const SvxMacroTableDtor& rMacTable = pMacItem->GetMacroTable();
1289  if (!rMacTable.empty())
1290  {
1292  }
1293  }
1294  }
1295  }
1296 
1297  // <font color = ...>...<img ... >...</font>
1298  sal_uInt16 nBorderWidth = 0;
1299  if( (nFrameOpts & HtmlFrmOpts::Border) &&
1300  SfxItemState::SET == rItemSet.GetItemState( RES_BOX, true, &pItem ))
1301  {
1302  Size aTwipBorder( 0, 0 );
1303  const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
1304 
1305  const ::editeng::SvxBorderLine *pColBorderLine = nullptr;
1306  const ::editeng::SvxBorderLine *pBorderLine = pBoxItem->GetLeft();
1307  if( pBorderLine )
1308  {
1309  pColBorderLine = pBorderLine;
1310  aTwipBorder.AdjustWidth(pBorderLine->GetOutWidth() );
1311  }
1312 
1313  pBorderLine = pBoxItem->GetRight();
1314  if( pBorderLine )
1315  {
1316  pColBorderLine = pBorderLine;
1317  aTwipBorder.AdjustWidth(pBorderLine->GetOutWidth() );
1318  }
1319 
1320  pBorderLine = pBoxItem->GetTop();
1321  if( pBorderLine )
1322  {
1323  pColBorderLine = pBorderLine;
1324  aTwipBorder.AdjustHeight(pBorderLine->GetOutWidth() );
1325  }
1326 
1327  pBorderLine = pBoxItem->GetBottom();
1328  if( pBorderLine )
1329  {
1330  pColBorderLine = pBorderLine;
1331  aTwipBorder.AdjustHeight(pBorderLine->GetOutWidth() );
1332  }
1333 
1334  aTwipBorder.setWidth( aTwipBorder.Width() / 2 );
1335  aTwipBorder.setHeight( aTwipBorder.Height() / 2 );
1336 
1337  if( (aTwipBorder.Width() || aTwipBorder.Height()) &&
1339  {
1340  Size aPixelBorder =
1342  MapMode(MapUnit::MapTwip) );
1343  if( !aPixelBorder.Width() && aTwipBorder.Width() )
1344  aPixelBorder.setWidth( 1 );
1345  if( !aPixelBorder.Height() && aTwipBorder.Height() )
1346  aPixelBorder.setHeight( 1 );
1347 
1348  if( aPixelBorder.Width() )
1349  aPixelBorder.setHeight( 0 );
1350 
1351  nBorderWidth =
1352  static_cast<sal_uInt16>(aPixelBorder.Width() + aPixelBorder.Height());
1353  }
1354 
1355  if( pColBorderLine )
1356  {
1357  aHtml.start(OOO_STRING_SVTOOLS_HTML_font);
1358  HtmlWriterHelper::applyColor(aHtml, OOO_STRING_SVTOOLS_HTML_O_color, pColBorderLine->GetColor());
1359  }
1360  }
1361 
1362  OString aTag(OOO_STRING_SVTOOLS_HTML_image);
1363  if (bReplacement)
1364  // Write replacement graphic of OLE object as <object>.
1366  aHtml.start(aTag);
1367 
1368  OStringBuffer sBuffer;
1369  if(rHTMLWrt.mbEmbedImages)
1370  {
1371  OUString aGraphicInBase64;
1372  if (XOutBitmap::GraphicToBase64(rGraphic, aGraphicInBase64))
1373  {
1374  sBuffer.append(OOO_STRING_SVTOOLS_HTML_O_data);
1375  sBuffer.append(":");
1376  sBuffer.append(OUStringToOString(aGraphicInBase64, RTL_TEXTENCODING_UTF8));
1377  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_src, sBuffer.makeStringAndClear().getStr());
1378  }
1379  else
1380  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1381  }
1382  else
1383  {
1384  sBuffer.append(OUStringToOString(aGraphicURL, RTL_TEXTENCODING_UTF8));
1385  OString aAttribute(OOO_STRING_SVTOOLS_HTML_O_src);
1386  if (bReplacement)
1387  aAttribute = OOO_STRING_SVTOOLS_HTML_O_data;
1388  aHtml.attribute(aAttribute, sBuffer.makeStringAndClear().getStr());
1389  }
1390 
1391  if (bReplacement)
1392  {
1393  // Handle XHTML type attribute for OLE replacement images.
1394  if (!rMimeType.isEmpty())
1395  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, rMimeType.toUtf8());
1396  }
1397 
1398  // Events
1399  if (SfxItemState::SET == rItemSet.GetItemState(RES_FRMMACRO, true, &pItem))
1400  {
1401  const SvxMacroTableDtor& rMacTable = static_cast<const SvxMacroItem *>(pItem)->GetMacroTable();
1402  if (!rMacTable.empty())
1403  {
1404  HtmlWriterHelper::applyEvents(aHtml, rMacTable, aImageEventTable, rHTMLWrt.m_bCfgStarBasic);
1405  }
1406  }
1407 
1408  // alt, align, width, height, hspace, vspace
1409  rHTMLWrt.writeFrameFormatOptions(aHtml, rFrameFormat, rAlternateText, nFrameOpts);
1410  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) )
1411  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
1412 
1413  if ((nFrameOpts & HtmlFrmOpts::Border) && !bReplacement)
1414  {
1415  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_border, nBorderWidth);
1416  }
1417 
1418  if( pURLItem && pURLItem->IsServerMap() )
1419  {
1420  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_ismap);
1421  }
1422 
1423  if( !aIMapName.isEmpty() )
1424  {
1425  aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_usemap, "#" + aIMapName);
1426  }
1427 
1428  if (bReplacement)
1429  {
1430  // XHTML object replacement image's alternate text doesn't use the
1431  // "alt" attribute.
1432  if (rAlternateText.isEmpty())
1433  // Empty alternate text is not valid.
1434  aHtml.characters(" ");
1435  else
1436  aHtml.characters(rAlternateText.toUtf8());
1437  }
1438 
1439  aHtml.flushStack();
1440 
1441  if( !rHTMLWrt.m_aINetFormats.empty() )
1442  {
1443  // There is still an attribute on the stack that has to be reopened
1444  SwFormatINetFormat *pINetFormat = rHTMLWrt.m_aINetFormats.back();
1445  OutHTML_INetFormat( rWrt, *pINetFormat, true );
1446  }
1447 
1448  return rHTMLWrt;
1449 }
1450 
1452  const char *pTag,
1453  const SvxBrushItem* pBrush,
1454  const OUString &rGraphicURL)
1455 {
1456  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1457 
1458  OUString aGraphicInBase64;
1459  OUString aLink;
1460  if( pBrush )
1461  {
1462  aLink = pBrush->GetGraphicLink();
1463  if(rHTMLWrt.mbEmbedImages || aLink.isEmpty())
1464  {
1465  const Graphic* pGrf = pBrush->GetGraphic();
1466  if( pGrf )
1467  {
1468  if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
1469  {
1470  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1471  }
1472  }
1473  }
1474  else if(!aLink.isEmpty())
1475  {
1476  if( rHTMLWrt.m_bCfgCpyLinkedGrfs )
1477  {
1478  rHTMLWrt.CopyLocalFileToINet( aLink );
1479  }
1480 
1481  }
1482  }
1483  else if(!rHTMLWrt.mbEmbedImages)
1484  {
1485  aLink = rGraphicURL;
1486  }
1487  if(!aLink.isEmpty())
1488  {
1490  aLink = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), aLink);
1491  }
1492 
1493  OStringBuffer sOut;
1494  if( pTag )
1495  sOut.append('<').append(pTag);
1496 
1497  sOut.append(' ');
1498  sOut.append(OOO_STRING_SVTOOLS_HTML_O_style).append("=\"");
1499  if(!aLink.isEmpty())
1500  {
1501  sOut.append(OOO_STRING_SVTOOLS_HTML_O_src).append("=\"");
1502  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1503  HTMLOutFuncs::Out_String( rWrt.Strm(), aLink, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1504  }
1505  else
1506  {
1507  sOut.append("list-style-image: ").append("url(").
1508  append(OOO_STRING_SVTOOLS_HTML_O_data).append(":");
1509  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1510  HTMLOutFuncs::Out_String( rWrt.Strm(), aGraphicInBase64, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1511  sOut.append(");");
1512  }
1513  sOut.append('\"');
1514 
1515  if (pTag)
1516  sOut.append('>');
1517  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1518 
1519  return rWrt;
1520 }
1521 
1522 static Writer& OutHTML_FrameFormatTableNode( Writer& rWrt, const SwFrameFormat& rFrameFormat )
1523 {
1524  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1525 
1526  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1527  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1528  sal_uLong nEnd = rHTMLWrt.m_pDoc->GetNodes()[nStt-1]->EndOfSectionIndex();
1529 
1530  OUString aCaption;
1531  bool bTopCaption = false;
1532 
1533  // Not const, because GetTable won't be const sometime later
1534  SwNode *pNd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ];
1535  SwTableNode *pTableNd = pNd->GetTableNode();
1536  const SwTextNode *pTextNd = pNd->GetTextNode();
1537  if( !pTableNd && pTextNd )
1538  {
1539  // Table with heading
1540  bTopCaption = true;
1541  pTableNd = rHTMLWrt.m_pDoc->GetNodes()[nStt+1]->GetTableNode();
1542  }
1543  OSL_ENSURE( pTableNd, "Frame does not contain a table" );
1544  if( pTableNd )
1545  {
1546  sal_uLong nTableEnd = pTableNd->EndOfSectionIndex();
1547  OSL_ENSURE( nTableEnd == nEnd - 1 ||
1548  (nTableEnd == nEnd - 2 && !bTopCaption),
1549  "Invalid frame content for a table" );
1550 
1551  if( nTableEnd == nEnd - 2 )
1552  pTextNd = rHTMLWrt.m_pDoc->GetNodes()[nTableEnd+1]->GetTextNode();
1553  }
1554  if( pTextNd )
1555  aCaption = pTextNd->GetText();
1556 
1557  if( pTableNd )
1558  {
1559  HTMLSaveData aSaveData( rHTMLWrt, pTableNd->GetIndex()+1,
1560  pTableNd->EndOfSectionIndex(),
1561  true, &rFrameFormat );
1562  rHTMLWrt.m_bOutFlyFrame = true;
1563  OutHTML_SwTableNode( rHTMLWrt, *pTableNd, &rFrameFormat, &aCaption,
1564  bTopCaption );
1565  }
1566 
1567  return rWrt;
1568 }
1569 
1571  const SwFrameFormat& rFrameFormat,
1572  bool bInCntnr )
1573 {
1574  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1575 
1576  rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
1577 
1578  // Close the current <DL>!
1579  rHTMLWrt.OutAndSetDefList( 0 );
1580 
1581  // output as Multicol
1582  if( rHTMLWrt.m_bLFPossible )
1583  rHTMLWrt.OutNewLine();
1584 
1585  OStringBuffer sOut;
1586  sOut.append('<').append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_multicol);
1587 
1588  const SwFormatCol& rFormatCol = rFrameFormat.GetCol();
1589 
1590  // output the number of columns as COLS
1591  sal_uInt16 nCols = rFormatCol.GetNumCols();
1592  if( nCols )
1593  {
1594  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
1595  append("=\"").append(static_cast<sal_Int32>(nCols)).append("\"");
1596  }
1597 
1598  // the Gutter width (minimum value) as GUTTER
1599  sal_uInt16 nGutter = rFormatCol.GetGutterWidth( true );
1600  if( nGutter!=USHRT_MAX )
1601  {
1602  if( nGutter && Application::GetDefaultDevice() )
1603  {
1604  nGutter = static_cast<sal_uInt16>(Application::GetDefaultDevice()
1605  ->LogicToPixel( Size(nGutter,0),
1606  MapMode(MapUnit::MapTwip) ).Width());
1607  }
1608  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_gutter).
1609  append("=\"").append(static_cast<sal_Int32>(nGutter)).append("\"");
1610  }
1611 
1612  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1613 
1614  // WIDTH
1615  HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MULTICOL;
1616  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1617  nFrameFlags |= HTML_FRMOPTS_MULTICOL_CSS1;
1618  rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
1619  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1620  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
1621 
1622  rWrt.Strm().WriteChar( '>' );
1623 
1624  rHTMLWrt.m_bLFPossible = true;
1625  rHTMLWrt.IncIndentLevel(); // indent the content of Multicol
1626 
1627  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1628  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
1629  const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
1630  OSL_ENSURE( pSttNd, "Where is the start node" );
1631 
1632  {
1633  // in a block, so that the old state can be restored in time
1634  // before the end
1635  HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
1636  pSttNd->EndOfSectionIndex(),
1637  true, &rFrameFormat );
1638  rHTMLWrt.m_bOutFlyFrame = true;
1639  rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
1640  }
1641 
1642  rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
1643  if( rHTMLWrt.m_bLFPossible )
1644  rHTMLWrt.OutNewLine();
1646  rHTMLWrt.m_bLFPossible = true;
1647 
1648  return rWrt;
1649 }
1650 
1651 static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& rFrameFormat )
1652 {
1653  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1654 
1655  // if possible, output a line break before the graphic
1656  if( rHTMLWrt.m_bLFPossible )
1657  rHTMLWrt.OutNewLine( true );
1658 
1659  OString sOut =
1660  "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_spacer " "
1663  rWrt.Strm().WriteOString( sOut );
1664 
1665  // ALIGN, WIDTH, HEIGHT
1666  OString aEndTags = rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), HTML_FRMOPTS_SPACER);
1667 
1668  rWrt.Strm().WriteChar( '>' );
1669  if( !aEndTags.isEmpty() )
1670  rWrt.Strm().WriteOString( aEndTags );
1671 
1672  return rWrt;
1673 }
1674 
1676  const SwFrameFormat& rFrameFormat, bool bSpan)
1677 {
1678  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1679 
1680  OString aTag;
1681  if( !bSpan )
1682  {
1683  rHTMLWrt.ChangeParaToken( HtmlTokenId::NONE );
1684 
1685  // Close the current <DL>!
1686  rHTMLWrt.OutAndSetDefList( 0 );
1688  }
1689  else
1691 
1692  // output as DIV
1693  if( rHTMLWrt.m_bLFPossible )
1694  rHTMLWrt.OutNewLine();
1695 
1696  OStringBuffer sOut;
1697  sOut.append('<').append(rHTMLWrt.GetNamespace() + aTag);
1698 
1699  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1700  HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_DIV;
1701  if( rHTMLWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
1702  nFrameFlags |= HtmlFrmOpts::SNoBorder;
1703  OString aEndTags = rHTMLWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
1704  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
1705  rWrt.Strm().WriteChar( '>' );
1706 
1707  rHTMLWrt.IncIndentLevel(); // indent the content
1708  rHTMLWrt.m_bLFPossible = true;
1709 
1710  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1711  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
1712 
1713  // Output frame-anchored frames that are anchored to the start node
1714  rHTMLWrt.OutFlyFrame( nStt, 0, HtmlPosition::Any );
1715 
1716  const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
1717  OSL_ENSURE( pSttNd, "Where is the start node" );
1718 
1719  {
1720  // in a block, so that the old state can be restored in time
1721  // before the end
1722  HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
1723  pSttNd->EndOfSectionIndex(),
1724  true, &rFrameFormat );
1725  rHTMLWrt.m_bOutFlyFrame = true;
1726  rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
1727  }
1728 
1729  rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
1730  if( rHTMLWrt.m_bLFPossible )
1731  rHTMLWrt.OutNewLine();
1732  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aTag, false );
1733 
1734  if( !aEndTags.isEmpty() )
1735  rWrt.Strm().WriteOString( aEndTags );
1736 
1737  return rWrt;
1738 }
1739 
1740 static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& rFrameFormat )
1741 {
1742  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1743 
1744  if (rHTMLWrt.mbSkipImages)
1745  return rWrt;
1746 
1747  ImageMap aIMap;
1748  Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap ) );
1749  Size aSz( 0, 0 );
1750  OUString GraphicURL;
1751  if(!rHTMLWrt.mbEmbedImages)
1752  {
1753  if( rHTMLWrt.GetOrigFileName() )
1754  GraphicURL = *rHTMLWrt.GetOrigFileName();
1755  if( aGraphic.GetType() == GraphicType::NONE ||
1756  XOutBitmap::WriteGraphic( aGraphic, GraphicURL,
1757  "JPG",
1758  (XOutFlags::UseGifIfPossible|
1759  XOutFlags::UseNativeIfPossible) ) != ERRCODE_NONE )
1760  {
1761  // empty or incorrect, because there is nothing to output
1762  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1763  return rWrt;
1764  }
1765 
1766  GraphicURL = URIHelper::SmartRel2Abs(
1767  INetURLObject(rWrt.GetBaseURL()), GraphicURL,
1769 
1770  }
1771  OutHTML_Image( rWrt, rFrameFormat, GraphicURL, aGraphic, rFrameFormat.GetName(), aSz,
1772  HtmlFrmOpts::GenImgMask, "frame",
1773  aIMap.GetIMapObjectCount() ? &aIMap : nullptr );
1774 
1775  return rWrt;
1776 }
1777 
1778 static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rFrameFormat,
1779  bool bInCntnr )
1780 {
1781  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1782 
1783  if (rHTMLWrt.mbSkipImages)
1784  return rWrt;
1785 
1786  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1787  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1788  SwGrfNode *pGrfNd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetGrfNode();
1789  OSL_ENSURE( pGrfNd, "Grf node expected" );
1790  if( !pGrfNd )
1791  return rWrt;
1792 
1793  HtmlFrmOpts nFrameFlags = bInCntnr ? HTML_FRMOPTS_IMG_CNTNR : HTML_FRMOPTS_IMG;
1794  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
1795  nFrameFlags |= HTML_FRMOPTS_IMG_CSS1;
1796 
1797  Graphic aGraphic = pGrfNd->GetGraphic();
1798  OUString aGraphicURL;
1799  OUString aMimeType;
1800  if(!rHTMLWrt.mbEmbedImages)
1801  {
1802  const SwMirrorGrf& rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
1803 
1804  if( !pGrfNd->IsLinkedFile() || MirrorGraph::Dont != rMirror.GetValue() )
1805  {
1806  // create a (mirrored) jpeg file
1807  if( rHTMLWrt.GetOrigFileName() )
1808  aGraphicURL = *rHTMLWrt.GetOrigFileName();
1809  else
1810  aGraphicURL = rHTMLWrt.GetBaseURL();
1811  pGrfNd->GetGrf( true );
1812 
1813  XOutFlags nFlags = XOutFlags::UseGifIfSensible |
1814  XOutFlags::UseNativeIfPossible;
1815  switch( rMirror.GetValue() )
1816  {
1817  case MirrorGraph::Vertical: nFlags = XOutFlags::MirrorHorz; break;
1818  case MirrorGraph::Horizontal: nFlags = XOutFlags::MirrorVert; break;
1819  case MirrorGraph::Both:
1820  nFlags = XOutFlags::MirrorVert | XOutFlags::MirrorHorz;
1821  break;
1822  default: break;
1823  }
1824 
1825  Size aMM100Size;
1826  const SwFormatFrameSize& rSize = rFrameFormat.GetFrameSize();
1827  aMM100Size = OutputDevice::LogicToLogic( rSize.GetSize(),
1828  MapMode( MapUnit::MapTwip ), MapMode( MapUnit::Map100thMM ));
1829 
1830  OUString aFilterName("JPG");
1831 
1832  if (rHTMLWrt.mbReqIF)
1833  {
1834  // Writing image without fallback PNG in ReqIF mode: force PNG
1835  // output.
1836  aFilterName = "PNG";
1837  nFlags &= ~XOutFlags::UseNativeIfPossible;
1838  nFlags &= ~XOutFlags::UseGifIfSensible;
1839  aMimeType = "image/png";
1840  }
1841 
1842  const Graphic& rGraphic = pGrfNd->GetGrf();
1843 
1844  // So that Graphic::IsTransparent() can report true.
1845  if (!rGraphic.isAvailable())
1846  const_cast<Graphic&>(rGraphic).makeAvailable();
1847 
1848  ErrCode nErr = XOutBitmap::WriteGraphic( rGraphic, aGraphicURL,
1849  aFilterName, nFlags, &aMM100Size );
1850  if( nErr )
1851  {
1852  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1853  return rWrt;
1854  }
1855  aGraphicURL = URIHelper::SmartRel2Abs(
1856  INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
1858  }
1859  else
1860  {
1861  pGrfNd->GetFileFilterNms( &aGraphicURL, nullptr );
1862  if( rHTMLWrt.m_bCfgCpyLinkedGrfs )
1863  rWrt.CopyLocalFileToINet( aGraphicURL );
1864  }
1865 
1866  }
1867  uno::Reference<beans::XPropertySet> xGraphic(aGraphic.GetXGraphic(), uno::UNO_QUERY);
1868  if (xGraphic.is() && aMimeType.isEmpty())
1869  xGraphic->getPropertyValue("MimeType") >>= aMimeType;
1870 
1871  if (rHTMLWrt.mbReqIF)
1872  {
1873  // Write the original image as an RTF fragment.
1874  OUString aFileName;
1875  if (rHTMLWrt.GetOrigFileName())
1876  aFileName = *rHTMLWrt.GetOrigFileName();
1877  INetURLObject aURL(aFileName);
1878  OUString aName = aURL.getBase() + "_" +
1879  aURL.getExtension() + "_" +
1880  OUString::number(aGraphic.GetChecksum(), 16);
1881  aURL.setBase(aName);
1882  aURL.setExtension("ole");
1884 
1885  SvFileStream aOutStream(aFileName, StreamMode::WRITE);
1886  if (!SwReqIfReader::WrapGraphicInRtf(aGraphic, pGrfNd->GetTwipSize(), aOutStream))
1887  SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed");
1888 
1889  // Refer to this data.
1890  aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
1891  rWrt.Strm().WriteOString("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object);
1892  rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\"");
1893  rWrt.Strm().WriteOString(" type=\"text/rtf\"");
1894  rWrt.Strm().WriteOString(">");
1895  rHTMLWrt.OutNewLine();
1896  }
1897 
1898  OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic, pGrfNd->GetTitle(),
1899  pGrfNd->GetTwipSize(), nFrameFlags, "graphic", nullptr, aMimeType );
1900 
1901  if (rHTMLWrt.mbReqIF)
1902  rWrt.Strm().WriteOString("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object ">");
1903 
1904  return rWrt;
1905 }
1906 
1907 static Writer& OutHTML_FrameFormatAsMarquee( Writer& rWrt, const SwFrameFormat& rFrameFormat,
1908  const SdrObject& rSdrObj )
1909 {
1910  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1911 
1912  // get the edit engine attributes of the object as SW attributes and
1913  // sort them as Hints
1914  const SfxItemSet& rFormatItemSet = rFrameFormat.GetAttrSet();
1915  SfxItemSet aItemSet( *rFormatItemSet.GetPool(), svl::Items<RES_CHRATR_BEGIN,
1916  RES_CHRATR_END>{} );
1917  SwHTMLWriter::GetEEAttrsFromDrwObj( aItemSet, &rSdrObj );
1918  bool bCfgOutStylesOld = rHTMLWrt.m_bCfgOutStyles;
1919  rHTMLWrt.m_bCfgOutStyles = false;
1920  rHTMLWrt.m_bTextAttr = true;
1921  rHTMLWrt.m_bTagOn = true;
1922  Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
1923  rHTMLWrt.m_bTextAttr = false;
1924 
1926  static_cast<const SwDrawFrameFormat &>(rFrameFormat),
1927  rSdrObj );
1928  rHTMLWrt.m_bTextAttr = true;
1929  rHTMLWrt.m_bTagOn = false;
1930  Out_SfxItemSet( aHTMLAttrFnTab, rWrt, aItemSet, false );
1931  rHTMLWrt.m_bTextAttr = false;
1932  rHTMLWrt.m_bCfgOutStyles = bCfgOutStylesOld;
1933 
1934  return rWrt;
1935 }
1936 
1937 Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
1938  bool bHeader )
1939 {
1940  SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1941 
1942  // output as Multicol
1943  rHTMLWrt.OutNewLine();
1944  OStringBuffer sOut;
1945  sOut.append(OOO_STRING_SVTOOLS_HTML_division).append(' ')
1946  .append(OOO_STRING_SVTOOLS_HTML_O_title).append("=\"")
1947  .append( bHeader ? "header" : "footer" ).append("\"");
1948  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + sOut.makeStringAndClear().getStr() );
1949 
1950  rHTMLWrt.IncIndentLevel(); // indent the content of Multicol;
1951 
1952  // Piece a spacer for the spacing together. Because the
1953  // <DL> or </DL> always produces a space between paragraphs, it is
1954  // subtracted if necessary.
1955  const SvxULSpaceItem& rULSpace = rFrameFormat.GetULSpace();
1956  sal_uInt16 nSize = bHeader ? rULSpace.GetLower() : rULSpace.GetUpper();
1957  rHTMLWrt.m_nHeaderFooterSpace = nSize;
1958 
1959  OString aSpacer;
1960  if( rHTMLWrt.IsHTMLMode(HTMLMODE_VERT_SPACER) &&
1962  {
1963  nSize -= HTML_PARSPACE;
1964  nSize = static_cast<sal_Int16>(Application::GetDefaultDevice()
1965  ->LogicToPixel( Size(nSize,0), MapMode(MapUnit::MapTwip) ).Width());
1966 
1967  aSpacer = OStringBuffer(OOO_STRING_SVTOOLS_HTML_spacer).
1968  append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type).
1969  append("=\"").append(OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical).append("\"").
1970  append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
1971  append("=\"").append(static_cast<sal_Int32>(nSize)).append("\"").
1972  makeStringAndClear();
1973  }
1974 
1975  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1976  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex();
1977  const SwStartNode* pSttNd = rWrt.m_pDoc->GetNodes()[nStt]->GetStartNode();
1978  OSL_ENSURE( pSttNd, "Where is the start node" );
1979 
1980  if( !bHeader && !aSpacer.isEmpty() )
1981  {
1982  rHTMLWrt.OutNewLine();
1983  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aSpacer.getStr() );
1984  }
1985 
1986  {
1987  // in a block, so that the old state can be restored in time
1988  // before the end. pFlyFormat doesn't need to be set here, because
1989  // PageDesc attributes cannot occur here
1990  HTMLSaveData aSaveData( rHTMLWrt, nStt+1,
1991  pSttNd->EndOfSectionIndex() );
1992 
1993  if( bHeader )
1994  rHTMLWrt.m_bOutHeader = true;
1995  else
1996  rHTMLWrt.m_bOutFooter = true;
1997 
1998  rHTMLWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
1999  }
2000 
2001  if( bHeader && !aSpacer.isEmpty() )
2002  {
2003  rHTMLWrt.OutNewLine();
2004  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + aSpacer.getStr() );
2005  }
2006 
2007  rHTMLWrt.DecIndentLevel(); // indent the content of Multicol;
2008  rHTMLWrt.OutNewLine();
2010 
2011  rHTMLWrt.m_nHeaderFooterSpace = 0;
2012 
2013  return rWrt;
2014 }
2015 
2016 void SwHTMLWriter::AddLinkTarget( const OUString& rURL )
2017 {
2018  if( rURL.isEmpty() || rURL[0] != '#' )
2019  return;
2020 
2021  // There might be a '|' as delimiter (if the link has been inserted
2022  // freshly) or a '%7c' or a '%7C' if the document has been saved and
2023  // loaded already.
2024  sal_Int32 nPos = rURL.getLength();
2025  bool bFound = false, bEncoded = false;
2026  while( !bFound && nPos > 0 )
2027  {
2028  sal_Unicode c = rURL[ --nPos ];
2029  switch( c )
2030  {
2031  case cMarkSeparator:
2032  bFound = true;
2033  break;
2034  case '%':
2035  bFound = (rURL.getLength() - nPos) >=3 && rURL[ nPos+1 ] == '7';
2036  if(bFound)
2037  {
2038  c = rURL[ nPos+2 ];
2039  bFound = (c == 'C' || c == 'c');
2040  }
2041  if( bFound )
2042  bEncoded = true;
2043  }
2044  }
2045  if( !bFound || nPos < 2 ) // at least "#a|..."
2046  return;
2047 
2048  OUString aURL( rURL.copy( 1 ) );
2049 
2050  // nPos-1+1/3 (-1 because of Erase)
2051  OUString sCmp = aURL.copy(bEncoded ? nPos+2 : nPos).replaceAll(" ","");
2052  if( sCmp.isEmpty() )
2053  return;
2054 
2055  sCmp = sCmp.toAsciiLowerCase();
2056 
2057  if( sCmp == "region" ||
2058  sCmp == "frame" ||
2059  sCmp == "graphic" ||
2060  sCmp == "ole" ||
2061  sCmp == "table" )
2062  {
2063  // Just remember it in a sorted array
2064  if( bEncoded )
2065  {
2066  aURL = aURL.replaceAt( nPos - 1, 3, OUString(cMarkSeparator) );
2067  }
2068  m_aImplicitMarks.insert( aURL );
2069  }
2070  else if( sCmp == "outline" )
2071  {
2072  // Here, we need position and name. That's why we sort a
2073  // sal_uInt16 and a string array ourselves.
2074  OUString aOutline( aURL.copy( 0, nPos-1 ) );
2075  SwPosition aPos( *m_pCurrentPam->GetPoint() );
2076  if( m_pDoc->GotoOutline( aPos, aOutline ) )
2077  {
2078  sal_uInt32 nIdx = aPos.nNode.GetIndex();
2079 
2080  decltype(m_aOutlineMarkPoss)::size_type nIns=0;
2081  while( nIns < m_aOutlineMarkPoss.size() &&
2082  m_aOutlineMarkPoss[nIns] < nIdx )
2083  nIns++;
2084 
2085  m_aOutlineMarkPoss.insert( m_aOutlineMarkPoss.begin()+nIns, nIdx );
2086  if( bEncoded )
2087  {
2088  aURL = aURL.replaceAt( nPos - 1, 3, OUString(cMarkSeparator) );
2089  }
2090  m_aOutlineMarks.insert( m_aOutlineMarks.begin()+nIns, aURL );
2091  }
2092  }
2093 }
2094 
2096 {
2097  const SwTextINetFormat* pTextAttr;
2098 
2100  {
2101  auto pINetFormat = dynamic_cast<const SwFormatINetFormat*>(pItem);
2102  const SwTextNode* pTextNd;
2103 
2104  if( pINetFormat &&
2105  nullptr != ( pTextAttr = pINetFormat->GetTextINetFormat()) &&
2106  nullptr != ( pTextNd = pTextAttr->GetpTextNode() ) &&
2107  pTextNd->GetNodes().IsDocNodes() )
2108  {
2109  AddLinkTarget( pINetFormat->GetValue() );
2110  }
2111  }
2112 
2113  for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_URL))
2114  {
2115  auto pURL = dynamic_cast<const SwFormatURL*>(pItem);
2116  if( pURL )
2117  {
2118  AddLinkTarget( pURL->GetURL() );
2119  const ImageMap *pIMap = pURL->GetMap();
2120  if( pIMap )
2121  {
2122  for( size_t i=0; i<pIMap->GetIMapObjectCount(); ++i )
2123  {
2124  const IMapObject* pObj = pIMap->GetIMapObject( i );
2125  if( pObj )
2126  {
2127  AddLinkTarget( pObj->GetURL() );
2128  }
2129  }
2130  }
2131  }
2132  }
2133 }
2134 
2135 /* 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:303
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)
void OutImplicitMark(const OUString &rMark, const char *pMarkType)
Definition: wrthtml.cxx:1216
URL aURL
sal_uInt16 GuessFrameType(const SwFrameFormat &rFrameFormat, const SdrObject *&rpStrObj)
sal_uLong GetIndex() const
Definition: node.hxx:282
#define RES_FRM_SIZE
Definition: hintids.hxx:289
const OUString & GetBaseURL() const
Definition: shellio.hxx:445
#define RES_COL
Definition: hintids.hxx:309
#define OOO_STRING_SVTOOLS_HTML_VA_texttop
#define RES_URL
Definition: hintids.hxx:311
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:656
#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:210
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
#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
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:273
sal_uIntPtr sal_uLong
#define RES_SURROUND
Definition: hintids.hxx:301
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:162
#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
static 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
SwPosFlyFrames GetAllFlyFormats(const SwPaM *, bool bDrawAlso, bool bAsCharAlso=false) const
Returns positions of all FlyFrames in the document.
Definition: doclay.cxx:498
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()
SwDoc * m_pDoc
Definition: docbm.cxx:1190
#define OOO_STRING_SVTOOLS_HTML_O_onmouseout
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1426
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
const sal_uInt16 MAX_BROWSERS
Definition: htmlfly.hxx:82
#define RES_CHRATR_END
Definition: hintids.hxx:208
bool m_bLFPossible
Definition: wrthtml.hxx:379
#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:599
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:3210
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:1409
#define RES_UL_SPACE
Definition: hintids.hxx:292
#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:479
if(nullptr==pCandidateA||nullptr==pCandidateB)
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
void ChangeParaToken(HtmlTokenId nNew)
Definition: htmlatr.cxx:157
bool IsOLENode() const
Definition: node.hxx:652
#define OOO_STRING_SVTOOLS_HTML_O_data
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
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
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()
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
bool OutFlyFrame(sal_uLong nNdIdx, sal_Int32 nContentIdx, HtmlPosition nPos, HTMLOutContext *pContext=nullptr)
#define RES_VERT_ORIENT
Definition: hintids.hxx:302
static SVT_DLLPUBLIC SvStream & FlushToAscii(SvStream &, HTMLOutContext &rContext)
sal_uInt16 GetGutterWidth(bool bMin=false) const
Definition: atrfrm.cxx:894
int i
SwContentNode * GetContentNode()
Definition: node.hxx:615
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
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:782
#define OOO_STRING_SVTOOLS_HTML_O_onmouseover
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:162
#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:693
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
DocumentType const eType
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:137
Writer & OutHTML_DrawFrameFormatAsMarquee(Writer &rWrt, const SwDrawFrameFormat &rFormat, const SdrObject &rSdrObject)
#define RES_TXTATR_INETFMT
Definition: hintids.hxx:235
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:797
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:419
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
#define RES_LR_SPACE
Definition: hintids.hxx:291
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:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
const SvxMacroTableDtor & GetMacroTable() const
XOutFlags
Writer & OutHTML_DrawFrameFormatAsControl(Writer &rWrt, const SwDrawFrameFormat &rFormat, const SdrUnoObj &rFormObj, bool bInCntnr)
Definition: htmlforw.cxx:677
#define HTMLMODE_ABS_POS_FLY
Definition: wrthtml.hxx:121
#define OOO_STRING_SVTOOLS_HTML_AL_right
bool GotoOutline(SwPosition &rPos, const OUString &rName, SwRootFrame const *=nullptr) const
Definition: docnum.cxx:722
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 RES_DRAWFRMFMT
Definition: hintids.hxx:372
#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:253
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:440
SwNodes & GetNodes()
Definition: doc.hxx:404
const HtmlFrmOpts HTML_FRMOPTS_DIV
#define HTMLMODE_VERT_SPACER
Definition: wrthtml.hxx:116
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
static HTMLOutEvent const aIMapEventTable[]
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
Definition: wrthtml.cxx:1475
#define OOO_STRING_SVTOOLS_HTML_spacer
const HtmlFrmOpts HTML_FRMOPTS_IMG_ALL
bool makeAvailable()
Writer & OutHTML_HeaderFooter(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bHeader)
#define OOO_STRING_SVTOOLS_HTML_image
SvStream & WriteChar(char nChar)
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:723
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:411
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
#define RES_BOX
Definition: hintids.hxx:306
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:2313
RndStdIds
static void GetEEAttrsFromDrwObj(SfxItemSet &rItemSet, const SdrObject *pObj)
bool IsTableNode() const
Definition: node.hxx:640
bool m_bTextAttr
Definition: wrthtml.hxx:357
#define OOO_STRING_SVTOOLS_HTML_VA_absbottom
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 RES_FRMMACRO
Definition: hintids.hxx:308
#define OOO_STRING_SVTOOLS_HTML_object
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
SS for PoolItems: hard attributation.
Definition: node.hxx:730
void OutAndSetDefList(sal_uInt16 nNewLvl)
Definition: htmlatr.cxx:119
OUString convertHyperlinkHRefValue(const OUString &rURL)
Definition: wrthtml.cxx:1229
Writer & OutHTML_INetFormat(Writer &rWrt, const SwFormatINetFormat &rINetFormat, bool bOn)
Definition: htmlatr.cxx:2940
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:636
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
#define OOO_STRING_SVTOOLS_HTML_O_width
const Graphic & GetGrf(bool bWait=false) const
Definition: ndgrf.cxx:359
#define HTML_PARSPACE
#define SAL_NEWLINE_STRING
SwDoc * m_pDoc
Definition: shellio.hxx:409
const Size & GetSize() const
sal_uInt16 nPos
OString OutFrameFormatOptions(const SwFrameFormat &rFrameFormat, const OUString &rAltText, HtmlFrmOpts nFrameOpts)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315
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:842
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:1887
EnumT GetValue() const
Base class of the Writer document model elements.
Definition: node.hxx:79
void setHeight(long nHeight)