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