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