LibreOffice Module sw (master)  1
htmlplug.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 <config_java.h>
21 
22 #include <hintids.hxx>
23 #include <rtl/strbuf.hxx>
24 #include <sal/log.hxx>
25 #include <svl/urihelper.hxx>
26 #include <vcl/svapp.hxx>
27 #include <sfx2/frmhtml.hxx>
28 #include <sfx2/frmhtmlw.hxx>
29 #include <sfx2/frmdescr.hxx>
30 #include <sot/storage.hxx>
31 #include <svx/xoutbmp.hxx>
32 #include <editeng/ulspitem.hxx>
33 #include <editeng/lrspitem.hxx>
34 #include <svtools/htmlout.hxx>
35 #include <svtools/htmlkywd.hxx>
36 #include <svtools/htmltokn.h>
37 #include <tools/diagnose_ex.h>
39 #include <SwAppletImpl.hxx>
40 #include <fmtornt.hxx>
41 #include <fmtfsize.hxx>
42 #include <fmtsrnd.hxx>
43 #include <fmtanchr.hxx>
44 #include <fmtcntnt.hxx>
45 #include <frmfmt.hxx>
46 
47 #include <svl/ownlist.hxx>
49 #include <unotools/streamwrap.hxx>
50 #include <pam.hxx>
51 #include <doc.hxx>
52 #include <swerror.h>
53 #include <ndole.hxx>
54 #include <docsh.hxx>
55 #include "swhtml.hxx"
56 #include "wrthtml.hxx"
57 #include "htmlfly.hxx"
58 #include "swcss1.hxx"
59 #include "htmlreqifreader.hxx"
60 #include <unoframe.hxx>
61 #include <com/sun/star/embed/XClassifiedObject.hpp>
62 #include <com/sun/star/embed/Aspects.hpp>
63 #include <com/sun/star/beans/XPropertySet.hpp>
64 #include <com/sun/star/frame/XStorable.hpp>
65 #include <com/sun/star/embed/ElementModes.hpp>
66 #include <com/sun/star/io/XActiveDataStreamer.hpp>
67 #include <com/sun/star/embed/XEmbedPersist2.hpp>
68 #include <com/sun/star/lang/XInitialization.hpp>
69 
71 #include <comphelper/classids.hxx>
72 #include <rtl/uri.hxx>
74 #include <vcl/graphicfilter.hxx>
78 #include <comphelper/fileurl.hxx>
79 #include <o3tl/safeint.hxx>
80 #include <osl/file.hxx>
82 #include <svtools/HtmlWriter.hxx>
83 
84 using namespace com::sun::star;
85 
86 #define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
87 #define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
88 
89 #define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
90 #define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
91 
92 
109 
121 
134 
138 
139 namespace
140 {
145 OUString lcl_CalculateFileName(const OUString* pOrigFileName, const Graphic& rGraphic,
146  std::u16string_view rExtension)
147 {
148  OUString aFileName;
149 
150  if (pOrigFileName)
151  aFileName = *pOrigFileName;
152  INetURLObject aURL(aFileName);
153  OUString aName = aURL.getBase() + "_" +
154  aURL.getExtension() + "_" +
155  OUString::number(rGraphic.GetChecksum(), 16);
156  aURL.setBase(aName);
157  aURL.setExtension(rExtension);
159 
160  return aFileName;
161 }
162 }
163 
164 void SwHTMLParser::SetFixSize( const Size& rPixSize,
165  const Size& rTwipDfltSize,
166  bool bPercentWidth, bool bPercentHeight,
167  SvxCSS1PropertyInfo const & rCSS1PropInfo,
168  SfxItemSet& rFlyItemSet )
169 {
170  // convert absolute size values into Twip
171  sal_uInt8 nPercentWidth = 0, nPercentHeight = 0;
172  Size aTwipSz( bPercentWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
173  bPercentHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
174  if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
175  {
176  aTwipSz =
178  MapMode(MapUnit::MapTwip) );
179  }
180 
181  // process width
182  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eWidthType )
183  {
184  nPercentWidth = static_cast<sal_uInt8>(rCSS1PropInfo.m_nWidth);
185  aTwipSz.setWidth( rTwipDfltSize.Width() );
186  }
187  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eWidthType )
188  {
189  aTwipSz.setWidth( rCSS1PropInfo.m_nWidth );
190  }
191  else if( bPercentWidth && rPixSize.Width() )
192  {
193  nPercentWidth = static_cast<sal_uInt8>(rPixSize.Width());
194  if( nPercentWidth > 100 )
195  nPercentWidth = 100;
196 
197  aTwipSz.setWidth( rTwipDfltSize.Width() );
198  }
199  else if( USHRT_MAX==rPixSize.Width() )
200  {
201  aTwipSz.setWidth( rTwipDfltSize.Width() );
202  }
203  if( aTwipSz.Width() < MINFLY )
204  {
205  aTwipSz.setWidth( MINFLY );
206  }
207 
208  // process height
209  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eHeightType )
210  {
211  nPercentHeight = static_cast<sal_uInt8>(rCSS1PropInfo.m_nHeight);
212  aTwipSz.setHeight( rTwipDfltSize.Height() );
213  }
214  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eHeightType )
215  {
216  aTwipSz.setHeight( rCSS1PropInfo.m_nHeight );
217  }
218  else if( bPercentHeight && rPixSize.Height() )
219  {
220  nPercentHeight = static_cast<sal_uInt8>(rPixSize.Height());
221  if( nPercentHeight > 100 )
222  nPercentHeight = 100;
223 
224  aTwipSz.setHeight( rTwipDfltSize.Height() );
225  }
226  else if( USHRT_MAX==rPixSize.Height() )
227  {
228  aTwipSz.setHeight( rTwipDfltSize.Height() );
229  }
230  if( aTwipSz.Height() < MINFLY )
231  {
232  aTwipSz.setHeight( MINFLY );
233  }
234 
235  // set size
236  SwFormatFrameSize aFrameSize( SwFrameSize::Fixed, aTwipSz.Width(), aTwipSz.Height() );
237  aFrameSize.SetWidthPercent( nPercentWidth );
238  aFrameSize.SetHeightPercent( nPercentHeight );
239  rFlyItemSet.Put( aFrameSize );
240 }
241 
242 void SwHTMLParser::SetSpace( const Size& rPixSpace,
243  SfxItemSet& rCSS1ItemSet,
244  SvxCSS1PropertyInfo& rCSS1PropInfo,
245  SfxItemSet& rFlyItemSet )
246 {
247  sal_Int32 nLeftSpace = 0, nRightSpace = 0;
248  sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
249  if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
250  {
251  Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
252  aTwipSpc =
254  MapMode(MapUnit::MapTwip) );
255  nLeftSpace = nRightSpace = aTwipSpc.Width();
256  nUpperSpace = nLowerSpace = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
257  }
258 
259  // set left/right margin
260  const SfxPoolItem *pItem;
261  if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
262  {
263  // if applicable remove the first line indent
264  const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
265  SvxLRSpaceItem aLRItem( *pLRItem );
266  aLRItem.SetTextFirstLineOffset( 0 );
267  if( rCSS1PropInfo.m_bLeftMargin )
268  {
269  nLeftSpace = aLRItem.GetLeft();
270  rCSS1PropInfo.m_bLeftMargin = false;
271  }
272  if( rCSS1PropInfo.m_bRightMargin )
273  {
274  nRightSpace = aLRItem.GetRight();
275  rCSS1PropInfo.m_bRightMargin = false;
276  }
277  rCSS1ItemSet.ClearItem( RES_LR_SPACE );
278  }
279  if( nLeftSpace > 0 || nRightSpace > 0 )
280  {
281  SvxLRSpaceItem aLRItem( RES_LR_SPACE );
282  aLRItem.SetLeft( std::max<sal_Int32>(nLeftSpace, 0) );
283  aLRItem.SetRight( std::max<sal_Int32>(nRightSpace, 0) );
284  rFlyItemSet.Put( aLRItem );
285  if( nLeftSpace )
286  {
287  const SwFormatHoriOrient& rHoriOri =
288  rFlyItemSet.Get( RES_HORI_ORIENT );
289  if( text::HoriOrientation::NONE == rHoriOri.GetHoriOrient() )
290  {
291  SwFormatHoriOrient aHoriOri( rHoriOri );
292  aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
293  rFlyItemSet.Put( aHoriOri );
294  }
295  }
296  }
297 
298  // set top/bottom margin
299  if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
300  {
301  // if applicable remove the first line indent
302  const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
303  if( rCSS1PropInfo.m_bTopMargin )
304  {
305  nUpperSpace = pULItem->GetUpper();
306  rCSS1PropInfo.m_bTopMargin = false;
307  }
308  if( rCSS1PropInfo.m_bBottomMargin )
309  {
310  nLowerSpace = pULItem->GetLower();
311  rCSS1PropInfo.m_bBottomMargin = false;
312  }
313  rCSS1ItemSet.ClearItem( RES_UL_SPACE );
314  }
315  if( !(nUpperSpace || nLowerSpace) )
316  return;
317 
318  SvxULSpaceItem aULItem( RES_UL_SPACE );
319  aULItem.SetUpper( nUpperSpace );
320  aULItem.SetLower( nLowerSpace );
321  rFlyItemSet.Put( aULItem );
322  if( nUpperSpace )
323  {
324  const SwFormatVertOrient& rVertOri =
325  rFlyItemSet.Get( RES_VERT_ORIENT );
326  if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
327  {
328  SwFormatVertOrient aVertOri( rVertOri );
329  aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
330  rFlyItemSet.Put( aVertOri );
331  }
332  }
333 }
334 
335 OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
336 {
337  if (!comphelper::isFileUrl(rBase))
338  return rPath;
339 
340  sal_Int32 nIndex = rPath.indexOf('?');
341 
342  if (nIndex != -1)
343  return rPath.copy(0, nIndex);
344 
345  return rPath;
346 }
347 
349 {
350  OUString aURL, aType, aName, aAlt, aId, aStyle, aClass;
351  OUString aData;
352  Size aSize( USHRT_MAX, USHRT_MAX );
353  Size aSpace( USHRT_MAX, USHRT_MAX );
354  bool bPercentWidth = false, bPercentHeight = false, bHidden = false;
355  sal_Int16 eVertOri = text::VertOrientation::NONE;
356  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
357  SvCommandList aCmdLst;
358  const HTMLOptions& rHTMLOptions = GetOptions();
359 
360  // The options are read forwards, because the plug-ins expect them in this
361  // order. Still only the first value of an option may be regarded.
362  for (const auto & rOption : rHTMLOptions)
363  {
364  switch( rOption.GetToken() )
365  {
366  case HtmlOptionId::ID:
367  aId = rOption.GetString();
368  break;
369  case HtmlOptionId::STYLE:
370  aStyle = rOption.GetString();
371  break;
372  case HtmlOptionId::CLASS:
373  aClass = rOption.GetString();
374  break;
375  case HtmlOptionId::NAME:
376  aName = rOption.GetString();
377  break;
378  case HtmlOptionId::SRC:
379  if( aURL.isEmpty() )
380  aURL = rOption.GetString();
381  break;
382  case HtmlOptionId::ALT:
383  aAlt = rOption.GetString();
384  break;
385  case HtmlOptionId::TYPE:
386  if( aType.isEmpty() )
387  aType = rOption.GetString();
388  break;
389  case HtmlOptionId::ALIGN:
390  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
391  {
392  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
393  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
394  }
395  break;
396  case HtmlOptionId::WIDTH:
397  if( USHRT_MAX==aSize.Width() )
398  {
399  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
400  aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
401  }
402  break;
403  case HtmlOptionId::HEIGHT:
404  if( USHRT_MAX==aSize.Height() )
405  {
406  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
407  aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
408  }
409  break;
410  case HtmlOptionId::HSPACE:
411  if( USHRT_MAX==aSpace.Width() )
412  aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
413  break;
414  case HtmlOptionId::VSPACE:
415  if( USHRT_MAX==aSpace.Height() )
416  aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
417  break;
418  case HtmlOptionId::DATA:
419  if (m_bXHTML && aURL.isEmpty())
420  aData = rOption.GetString();
421  break;
422  case HtmlOptionId::UNKNOWN:
423  if (rOption.GetTokenString().equalsIgnoreAsciiCase(
425  {
426  bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
427  "FALSE");
428  }
429  break;
430  default: break;
431  }
432 
433  // All parameters are passed to the plug-in.
434  aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
435  }
436 
437  static const std::set<std::u16string_view> vAllowlist = {
438  u"image/png",
439  u"image/gif",
440  u"image/x-MS-bmp",
441  u"image/jpeg",
442  u"image/x-wmf",
443  u"image/svg+xml",
444  u"image/tiff",
445  u"image/x-emf",
446  };
447 
448  if (vAllowlist.find(aType) != vAllowlist.end() && m_aEmbeds.empty())
449  {
450  // Toplevel <object> for an image format -> that's an image, not an OLE object.
451  m_aEmbeds.push(nullptr);
452  return false;
453  }
454 
455  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
456  SvxCSS1PropertyInfo aPropInfo;
457  if( HasStyleOptions( aStyle, aId, aClass ) )
458  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
459 
460  // Convert the default values (except height/width, which is done by SetFrameSize())
461  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
462  eVertOri = text::VertOrientation::TOP;
463  if( USHRT_MAX==aSpace.Width() )
464  aSpace.setWidth( 0 );
465  if( USHRT_MAX==aSpace.Height() )
466  aSpace.setHeight( 0 );
467  if( bHidden )
468  {
469  // Size (0,0) will be changed to (MINFLY, MINFLY) in SetFrameSize()
470  aSize.setWidth( 0 ); aSize.setHeight( 0 );
471  aSpace.setWidth( 0 ); aSpace.setHeight( 0 );
472  bPercentWidth = bPercentHeight = false;
473  }
474 
475  // prepare the URL
476  INetURLObject aURLObj;
477  bool bHasURL = !aURL.isEmpty() &&
478  aURLObj.SetURL(
480  INetURLObject(m_sBaseURL), aURL,
482  bool bHasData = !aData.isEmpty();
483 
484  try
485  {
486  // Strip query and everything after that for file:// URLs, browsers do
487  // the same.
488  aURLObj.SetURL(rtl::Uri::convertRelToAbs(
489  m_sBaseURL, SwHTMLParser::StripQueryFromPath(m_sBaseURL, aData)));
490  }
491  catch (const rtl::MalformedUriException& /*rException*/)
492  {
493  bHasData = false;
494  }
495 
496  // do not insert plugin if it has neither URL nor type
497  bool bHasType = !aType.isEmpty();
498  if( !bHasURL && !bHasType && !bHasData )
499  return true;
500 
501  if (!m_aEmbeds.empty())
502  {
503  // Nested XHTML <object> element: points to replacement graphic.
504  SwOLENode* pOLENode = m_aEmbeds.top();
505  if (!pOLENode)
506  {
507  // <object> is mapped to an image -> ignore replacement graphic.
508  return true;
509  }
510 
511  svt::EmbeddedObjectRef& rObj = pOLENode->GetOLEObj().GetObject();
512  Graphic aGraphic;
513  if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
514  return true;
515 
516  rObj.SetGraphic(aGraphic, aType);
517 
518  // Set the size of the OLE frame to the size of the graphic.
519  SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
520  if (!pFormat)
521  return true;
522  SwAttrSet aAttrSet(pFormat->GetAttrSet());
523  aAttrSet.ClearItem(RES_CNTNT);
525  Size aDefaultTwipSize(pDevice->PixelToLogic(aGraphic.GetSizePixel(pDevice), MapMode(MapUnit::MapTwip)));
526  SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet);
527  pOLENode->GetDoc().SetFlyFrameAttr(*pFormat, aAttrSet);
528  return true;
529  }
530 
531  // create the plug-in
533  OUString aObjName;
534  uno::Reference < embed::XEmbeddedObject > xObj;
535  if (!bHasData)
536  {
537  xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
539  {
540  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
541  if ( xSet.is() )
542  {
543  if( bHasURL )
544  xSet->setPropertyValue("PluginURL", uno::makeAny( aURL ) );
545  if( bHasType )
546  xSet->setPropertyValue("PluginMimeType", uno::makeAny( aType ) );
547 
548  uno::Sequence < beans::PropertyValue > aProps;
549  aCmdLst.FillSequence( aProps );
550  xSet->setPropertyValue("PluginCommands", uno::makeAny( aProps ) );
551 
552  }
553  }
554  }
555  else if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
556  {
557  // Has non-empty data attribute in XHTML: map that to an OLE object.
558  uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
559  aCnt.SwitchPersistence(xStorage);
560  aObjName = aCnt.CreateUniqueObjectName();
561  {
563  StreamMode::READ);
564  uno::Reference<io::XInputStream> xInStream;
565  SvMemoryStream aMemoryStream;
566 
567  // Allow any MIME type that starts with magic, unless a set of allowed types are
568  // specified.
569  auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
570  if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
571  {
572  OString aMagic("{\\object");
573  OString aHeader(read_uInt8s_ToOString(aFileStream, aMagic.getLength()));
574  aFileStream.Seek(0);
575  if (aHeader == aMagic)
576  {
577  // OLE2 wrapped in RTF: either own format or real OLE2 embedding.
578  bool bOwnFormat = false;
579  if (SwReqIfReader::ExtractOleFromRtf(aFileStream, aMemoryStream, bOwnFormat))
580  {
581  xInStream.set(new utl::OStreamWrapper(aMemoryStream));
582  }
583 
584  if (bOwnFormat)
585  {
586  uno::Sequence<beans::PropertyValue> aMedium = comphelper::InitPropertySequence(
587  { { "InputStream", uno::makeAny(xInStream) },
588  { "URL", uno::makeAny(OUString("private:stream")) },
589  { "DocumentBaseURL", uno::makeAny(m_sBaseURL) } });
590  xObj = aCnt.InsertEmbeddedObject(aMedium, aName, &m_sBaseURL);
591  }
592  else
593  {
594  // The type is now an OLE2 container, not the original XHTML type.
595  aType = "application/vnd.sun.star.oleobject";
596  }
597  }
598  }
599 
600  if (!xInStream.is())
601  // Non-RTF case.
602  xInStream.set(new utl::OStreamWrapper(aFileStream));
603 
604  if (!xObj.is())
605  {
606  uno::Reference<io::XStream> xOutStream
607  = xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
608  if (aFileStream.IsOpen())
610  xOutStream->getOutputStream());
611 
612  if (!aType.isEmpty())
613  {
614  // Set media type of the native data.
615  uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
616  if (xOutStreamProps.is())
617  xOutStreamProps->setPropertyValue("MediaType", uno::makeAny(aType));
618  }
619  }
620  xObj = aCnt.GetEmbeddedObject(aObjName);
621  }
622  }
623 
624  SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
626  if( !IsNewDoc() )
627  Reader::ResetFrameFormatAttrs( aFrameSet );
628 
629  // set the anchor
630  if( !bHidden )
631  {
632  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
633  }
634  else
635  {
636  SwFormatAnchor aAnchor( RndStdIds::FLY_AT_PARA );
637  aAnchor.SetAnchor( m_pPam->GetPoint() );
638  aFrameSet.Put( aAnchor );
639  aFrameSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
640  aFrameSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
641  aFrameSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
642  }
643 
644  // and the size of the frame
646  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
647  SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
648 
649  // and insert into the document
650  uno::Reference<lang::XInitialization> xObjInitialization(xObj, uno::UNO_QUERY);
651  if (xObjInitialization.is())
652  {
653  // Request that the native data of the embedded object is not modified
654  // during parsing.
655  uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
656  true) };
657  uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
658  xObjInitialization->initialize(aArguments);
659  }
660  SwFrameFormat* pFlyFormat =
661  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
662  ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
663  &aFrameSet);
664  if (xObjInitialization.is())
665  {
666  uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
667  false) };
668  uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
669  xObjInitialization->initialize(aArguments);
670  }
671 
672  // set name at FrameFormat
673  if( !aName.isEmpty() )
674  pFlyFormat->SetName( aName );
675 
676  // set the alternative text
677  SwNoTextNode *pNoTextNd =
678  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
679  ->GetIndex()+1 ]->GetNoTextNode();
680  pNoTextNd->SetTitle( aAlt );
681 
682  // if applicable create frames and register auto-bound frames
683  if( !bHidden )
684  {
685  // HIDDEN plug-ins should stay paragraph-bound. Since RegisterFlyFrame()
686  // will change paragraph-bound frames with wrap-through into a
687  // character-bound frame, here we must create the frames by hand.
688  RegisterFlyFrame( pFlyFormat );
689  }
690 
691  if (!bHasData)
692  return true;
693 
694  SwOLENode* pOLENode = pNoTextNd->GetOLENode();
695  if (!pOLENode)
696  return true;
697 
698  m_aEmbeds.push(pOLENode);
699 
700  return true;
701 }
702 
703 #if HAVE_FEATURE_JAVA
704 void SwHTMLParser::NewObject()
705 {
706  OUString aClassID;
707  OUString aStandBy, aId, aStyle, aClass;
708  Size aSize( USHRT_MAX, USHRT_MAX );
709  Size aSpace( 0, 0 );
710  sal_Int16 eVertOri = text::VertOrientation::TOP;
711  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
712 
713  bool bPercentWidth = false, bPercentHeight = false,
714  bDeclare = false;
715  // create a new Command list
716  m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
717 
718  const HTMLOptions& rHTMLOptions = GetOptions();
719  for (size_t i = rHTMLOptions.size(); i; )
720  {
721  const HTMLOption& rOption = rHTMLOptions[--i];
722  switch( rOption.GetToken() )
723  {
724  case HtmlOptionId::ID:
725  aId = rOption.GetString();
726  break;
727  case HtmlOptionId::STYLE:
728  aStyle = rOption.GetString();
729  break;
730  case HtmlOptionId::CLASS:
731  aClass = rOption.GetString();
732  break;
733  case HtmlOptionId::DECLARE:
734  bDeclare = true;
735  break;
736  case HtmlOptionId::CLASSID:
737  aClassID = rOption.GetString();
738  break;
739  case HtmlOptionId::CODEBASE:
740  break;
741  case HtmlOptionId::DATA:
742  break;
743  case HtmlOptionId::TYPE:
744  break;
745  case HtmlOptionId::CODETYPE:
746  break;
747  case HtmlOptionId::ARCHIVE:
748  case HtmlOptionId::UNKNOWN:
749  break;
750  case HtmlOptionId::STANDBY:
751  aStandBy = rOption.GetString();
752  break;
753  case HtmlOptionId::WIDTH:
754  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
755  aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
756  break;
757  case HtmlOptionId::HEIGHT:
758  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
759  aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
760  break;
761  case HtmlOptionId::ALIGN:
762  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
763  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
764  break;
765  case HtmlOptionId::USEMAP:
766  break;
767  case HtmlOptionId::NAME:
768  break;
769  case HtmlOptionId::HSPACE:
770  aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
771  break;
772  case HtmlOptionId::VSPACE:
773  aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
774  break;
775  case HtmlOptionId::BORDER:
776  break;
777 
778  case HtmlOptionId::SDONCLICK:
779  case HtmlOptionId::ONCLICK:
780  case HtmlOptionId::SDONMOUSEOVER:
781  case HtmlOptionId::ONMOUSEOVER:
782  case HtmlOptionId::SDONMOUSEOUT:
783  case HtmlOptionId::ONMOUSEOUT:
784  break;
785  default: break;
786  }
787  // All parameters are passed to the applet.
788  m_pAppletImpl->AppendParam( rOption.GetTokenString(),
789  rOption.GetString() );
790 
791  }
792 
793  // Objects that are declared only are not evaluated. Moreover, only
794  // Java applets are supported.
795  bool bIsApplet = false;
796 
797  if( !bDeclare && aClassID.getLength() == 42 &&
798  aClassID.startsWith("clsid:") )
799  {
800  aClassID = aClassID.copy(6);
801  SvGlobalName aCID;
802  if( aCID.MakeId( aClassID ) )
803  {
804  SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
805  0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
806 
807  bIsApplet = aJavaCID == aCID;
808  }
809  }
810 
811  if( !bIsApplet )
812  {
813  m_pAppletImpl.reset();
814  return;
815  }
816 
817  m_pAppletImpl->SetAltText( aStandBy );
818 
819  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
820  SvxCSS1PropertyInfo aPropInfo;
821  if( HasStyleOptions( aStyle, aId, aClass ) )
822  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
823 
824  SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
825  if( !IsNewDoc() )
826  Reader::ResetFrameFormatAttrs( rFrameSet );
827 
828  // set the anchor and the adjustment
829  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
830 
831  // and still the size of the frame
833  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
834  SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
835 }
836 #endif
837 
839 {
840 #if HAVE_FEATURE_JAVA
841  if( !m_pAppletImpl )
842  return;
843  if( !m_pAppletImpl->CreateApplet( m_sBaseURL ) )
844  return;
845 
846  m_pAppletImpl->FinishApplet();
847 
848  // and insert into the document
849  SwFrameFormat* pFlyFormat =
850  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
851  ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
852  &m_pAppletImpl->GetItemSet() );
853 
854  // set the alternative name
855  SwNoTextNode *pNoTextNd =
856  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
857  ->GetIndex()+1 ]->GetNoTextNode();
858  pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
859 
860  // if applicable create frames and register auto-bound frames
861  RegisterFlyFrame( pFlyFormat );
862 
863  m_pAppletImpl.reset();
864 #else
865  (void) this; // Silence loplugin:staticmethods
866 #endif
867 }
868 
869 #if HAVE_FEATURE_JAVA
870 void SwHTMLParser::InsertApplet()
871 {
872  OUString aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
873  Size aSize( USHRT_MAX, USHRT_MAX );
874  Size aSpace( 0, 0 );
875  bool bPercentWidth = false, bPercentHeight = false, bMayScript = false;
876  sal_Int16 eVertOri = text::VertOrientation::TOP;
877  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
878 
879  // create a new Command list
880  m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
881 
882  const HTMLOptions& rHTMLOptions = GetOptions();
883  for (size_t i = rHTMLOptions.size(); i; )
884  {
885  const HTMLOption& rOption = rHTMLOptions[--i];
886  switch( rOption.GetToken() )
887  {
888  case HtmlOptionId::ID:
889  aId = rOption.GetString();
890  break;
891  case HtmlOptionId::STYLE:
892  aStyle = rOption.GetString();
893  break;
894  case HtmlOptionId::CLASS:
895  aClass = rOption.GetString();
896  break;
897  case HtmlOptionId::CODEBASE:
898  aCodeBase = rOption.GetString();
899  break;
900  case HtmlOptionId::CODE:
901  aCode = rOption.GetString();
902  break;
903  case HtmlOptionId::NAME:
904  aName = rOption.GetString();
905  break;
906  case HtmlOptionId::ALT:
907  aAlt = rOption.GetString();
908  break;
909  case HtmlOptionId::ALIGN:
910  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
911  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
912  break;
913  case HtmlOptionId::WIDTH:
914  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
915  aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
916  break;
917  case HtmlOptionId::HEIGHT:
918  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
919  aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
920  break;
921  case HtmlOptionId::HSPACE:
922  aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
923  break;
924  case HtmlOptionId::VSPACE:
925  aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
926  break;
927  case HtmlOptionId::MAYSCRIPT:
928  bMayScript = true;
929  break;
930  default: break;
931  }
932 
933  // All parameters are passed to the applet.
934  m_pAppletImpl->AppendParam( rOption.GetTokenString(),
935  rOption.GetString() );
936  }
937 
938  if( aCode.isEmpty() )
939  {
940  m_pAppletImpl.reset();
941  return;
942  }
943 
944  if ( !aCodeBase.isEmpty() )
945  aCodeBase = INetURLObject::GetAbsURL( m_sBaseURL, aCodeBase );
946  m_pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, m_sBaseURL );//, aAlt );
947  m_pAppletImpl->SetAltText( aAlt );
948 
949  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
950  SvxCSS1PropertyInfo aPropInfo;
951  if( HasStyleOptions( aStyle, aId, aClass ) )
952  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
953 
954  SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
955  if( !IsNewDoc() )
956  Reader::ResetFrameFormatAttrs( rFrameSet );
957 
958  // set the anchor and the adjustment
959  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
960 
961  // and still the size or the frame
963  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
964  SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
965 }
966 #endif
967 
969 {
970 #if HAVE_FEATURE_JAVA
971  if( !m_pAppletImpl )
972  return;
973 
974  m_pAppletImpl->FinishApplet();
975 
976  // and insert into the document
977  SwFrameFormat* pFlyFormat =
978  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
979  ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
980  &m_pAppletImpl->GetItemSet());
981 
982  // set the alternative name
983  SwNoTextNode *pNoTextNd =
984  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
985  ->GetIndex()+1 ]->GetNoTextNode();
986  pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
987 
988  // if applicable create frames and register auto-bound frames
989  RegisterFlyFrame( pFlyFormat );
990 
991  m_pAppletImpl.reset();
992 #else
993  (void) this;
994 #endif
995 }
996 
998 {
999 #if HAVE_FEATURE_JAVA
1000  if( !m_pAppletImpl )
1001  return;
1002 
1003  OUString aName, aValue;
1004 
1005  const HTMLOptions& rHTMLOptions = GetOptions();
1006  for (size_t i = rHTMLOptions.size(); i; )
1007  {
1008  const HTMLOption& rOption = rHTMLOptions[--i];
1009  switch( rOption.GetToken() )
1010  {
1011  case HtmlOptionId::NAME:
1012  aName = rOption.GetString();
1013  break;
1014  case HtmlOptionId::VALUE:
1015  aValue = rOption.GetString();
1016  break;
1017  default: break;
1018  }
1019  }
1020 
1021  if( aName.isEmpty() )
1022  return;
1023 
1024  m_pAppletImpl->AppendParam( aName, aValue );
1025 #else
1026  (void) this;
1027 #endif
1028 }
1029 
1031 {
1032  OUString aAlt, aId, aStyle, aClass;
1033  Size aSize( USHRT_MAX, USHRT_MAX );
1034  Size aSpace( 0, 0 );
1035  bool bPercentWidth = false, bPercentHeight = false;
1036  sal_Int16 eVertOri = text::VertOrientation::TOP;
1037  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1038 
1039  const HTMLOptions& rHTMLOptions = GetOptions();
1040 
1041  // First fetch the options of the Writer-Frame-Format
1042  for (const auto & rOption : rHTMLOptions)
1043  {
1044  switch( rOption.GetToken() )
1045  {
1046  case HtmlOptionId::ID:
1047  aId = rOption.GetString();
1048  break;
1049  case HtmlOptionId::STYLE:
1050  aStyle = rOption.GetString();
1051  break;
1052  case HtmlOptionId::CLASS:
1053  aClass = rOption.GetString();
1054  break;
1055  case HtmlOptionId::ALT:
1056  aAlt = rOption.GetString();
1057  break;
1058  case HtmlOptionId::ALIGN:
1059  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1060  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1061  break;
1062  case HtmlOptionId::WIDTH:
1063  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
1064  aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
1065  break;
1066  case HtmlOptionId::HEIGHT:
1067  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
1068  aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
1069  break;
1070  case HtmlOptionId::HSPACE:
1071  aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
1072  break;
1073  case HtmlOptionId::VSPACE:
1074  aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
1075  break;
1076  default: break;
1077  }
1078  }
1079 
1080  // and now the ones for the SfxFrame
1081  SfxFrameDescriptor aFrameDesc;
1082 
1083  SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, rHTMLOptions, m_sBaseURL );
1084 
1085  // create a floating frame
1087  OUString aObjName;
1088  uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
1089 
1090  try
1091  {
1092  // TODO/MBA: testing
1094  {
1095  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1096  if ( xSet.is() )
1097  {
1098  const OUString& aName = aFrameDesc.GetName();
1099  ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
1100  bool bHasBorder = aFrameDesc.HasFrameBorder();
1101  Size aMargin = aFrameDesc.GetMargin();
1102 
1103  xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
1104  xSet->setPropertyValue("FrameName", uno::makeAny( aName ) );
1105 
1106  if ( eScroll == ScrollingMode::Auto )
1107  xSet->setPropertyValue("FrameIsAutoScroll",
1108  uno::makeAny( true ) );
1109  else
1110  xSet->setPropertyValue("FrameIsScrollingMode",
1111  uno::makeAny( eScroll == ScrollingMode::Yes ) );
1112 
1113  xSet->setPropertyValue("FrameIsBorder",
1114  uno::makeAny( bHasBorder ) );
1115 
1116  xSet->setPropertyValue("FrameMarginWidth",
1117  uno::makeAny( sal_Int32( aMargin.Width() ) ) );
1118 
1119  xSet->setPropertyValue("FrameMarginHeight",
1120  uno::makeAny( sal_Int32( aMargin.Height() ) ) );
1121  }
1122  }
1123  }
1124  catch ( uno::Exception& )
1125  {
1126  }
1127 
1128  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1129  SvxCSS1PropertyInfo aPropInfo;
1130  if( HasStyleOptions( aStyle, aId, aClass ) )
1131  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
1132 
1133  // fetch the ItemSet
1134  SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
1136  if( !IsNewDoc() )
1137  Reader::ResetFrameFormatAttrs( aFrameSet );
1138 
1139  // set the anchor and the adjustment
1140  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
1141 
1142  // and still the size of the frame
1144  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
1145  SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
1146 
1147  // and insert into the document
1148  SwFrameFormat* pFlyFormat =
1149  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
1150  ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
1151  &aFrameSet);
1152 
1153  // set the alternative name
1154  SwNoTextNode *pNoTextNd =
1155  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
1156  ->GetIndex()+1 ]->GetNoTextNode();
1157  pNoTextNd->SetTitle( aAlt );
1158 
1159  // if applicable create frames and register auto-bound frames
1160  RegisterFlyFrame( pFlyFormat );
1161 
1162  m_bInFloatingFrame = true;
1163 }
1164 
1166 {
1167  SwOLEObj& rObj = const_cast<SwOLENode*>(rNode.GetOLENode())->GetOLEObj();
1168 
1170 
1171  uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
1172  SvGlobalName aClass( xClass->getClassID() );
1173  if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1174  {
1175  eType = HTML_FRMTYPE_PLUGIN;
1176  }
1177  else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1178  {
1179  eType = HTML_FRMTYPE_IFRAME;
1180  }
1181 #if HAVE_FEATURE_JAVA
1182  else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1183  {
1184  eType = HTML_FRMTYPE_APPLET;
1185  }
1186 #endif
1187 
1188  return static_cast< sal_uInt16 >(eType);
1189 }
1190 
1192  bool bInCntnr )
1193 {
1194  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1195 
1196  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1197  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1198  SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1199 
1200  OSL_ENSURE( pOLENd, "OLE-Node expected" );
1201  if( !pOLENd )
1202  return rWrt;
1203 
1204  SwOLEObj &rObj = pOLENd->GetOLEObj();
1205 
1206  uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1208  return rWrt;
1209 
1210  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1211  bool bHiddenEmbed = false;
1212 
1213  if( !xSet.is() )
1214  {
1215  OSL_FAIL("Unknown Object" );
1216  return rWrt;
1217  }
1218 
1219  HtmlFrmOpts nFrameOpts;
1220 
1221  // if possible output a line break before the "object"
1222  if( rHTMLWrt.m_bLFPossible )
1223  rHTMLWrt.OutNewLine( true );
1224 
1225  if( !rFrameFormat.GetName().isEmpty() )
1226  rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
1227  "ole" );
1228  uno::Any aAny;
1229  SvGlobalName aGlobName( xObj->getClassID() );
1230  OStringBuffer sOut;
1231  sOut.append('<');
1232  if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1233  {
1234  // first the plug-in specifics
1235  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
1236 
1237  OUString aStr;
1238  OUString aURL;
1239  aAny = xSet->getPropertyValue("PluginURL");
1240  if( (aAny >>= aStr) && !aStr.isEmpty() )
1241  {
1243  aStr);
1244  }
1245 
1246  if( !aURL.isEmpty() )
1247  {
1248  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_src "=\"");
1249  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1250  HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1251  sOut.append('\"');
1252  }
1253 
1254  OUString aType;
1255  aAny = xSet->getPropertyValue("PluginMimeType");
1256  if( (aAny >>= aType) && !aType.isEmpty() )
1257  {
1258  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"");
1259  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1260  HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1261  sOut.append('\"');
1262  }
1263 
1264  if ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) &&
1265  css::text::WrapTextMode_THROUGH == rFrameFormat.GetSurround().GetSurround() )
1266  {
1267  // A HIDDEN plug-in
1268  sOut.append(' ').append(OOO_STRING_SW_HTML_O_Hidden);
1269  nFrameOpts = HTML_FRMOPTS_HIDDEN_EMBED;
1270  bHiddenEmbed = true;
1271  }
1272  else
1273  {
1274  nFrameOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
1276  }
1277  }
1278  else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1279  {
1280  // or the applet specifics
1281 
1282  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
1283 
1284  // CODEBASE
1285  OUString aCd;
1286  aAny = xSet->getPropertyValue("AppletCodeBase");
1287  if( (aAny >>= aCd) && !aCd.isEmpty() )
1288  {
1289  OUString sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
1290  if( !sCodeBase.isEmpty() )
1291  {
1292  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_codebase "=\"");
1293  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1294  HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1295  sOut.append('\"');
1296  }
1297  }
1298 
1299  // CODE
1300  OUString aClass;
1301  aAny = xSet->getPropertyValue("AppletCode");
1302  aAny >>= aClass;
1303  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_code "=\"");
1304  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1305  HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1306  sOut.append('\"');
1307 
1308  // NAME
1309  OUString aAppletName;
1310  aAny = xSet->getPropertyValue("AppletName");
1311  aAny >>= aAppletName;
1312  if( !aAppletName.isEmpty() )
1313  {
1314  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
1315  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1316  HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1317  sOut.append('\"');
1318  }
1319 
1320  bool bScript = false;
1321  aAny = xSet->getPropertyValue("AppletIsScript");
1322  aAny >>= bScript;
1323  if( bScript )
1324  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_mayscript);
1325 
1326  nFrameOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
1328  }
1329  else
1330  {
1331  // or the Floating-Frame specifics
1332 
1333  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
1334  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1335 
1337  xSet,
1338  rHTMLWrt.m_eDestEnc,
1339  &rHTMLWrt.m_aNonConvertableCharacters );
1340 
1341  nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
1343  }
1344 
1345  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1346 
1347  // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
1348  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1349  nFrameOpts |= HTML_FRMOPTS_OLE_CSS1;
1350  OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
1351  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1352  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
1353 
1354  if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1355  {
1356  // output the parameters of applets as separate tags
1357  // and write a </APPLET>
1358 
1359  uno::Sequence < beans::PropertyValue > aProps;
1360  aAny = xSet->getPropertyValue("AppletCommands");
1361  aAny >>= aProps;
1362 
1363  SvCommandList aCommands;
1364  aCommands.FillFromSequence( aProps );
1365  std::vector<sal_uLong> aParams;
1366  size_t i = aCommands.size();
1367  while( i > 0 )
1368  {
1369  const SvCommand& rCommand = aCommands[ --i ];
1370  const OUString& rName = rCommand.GetCommand();
1372  if( SwHtmlOptType::TAG == nType )
1373  {
1374  const OUString& rValue = rCommand.GetArgument();
1375  rWrt.Strm().WriteChar( ' ' );
1376  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1377  rWrt.Strm().WriteCharPtr( "=\"" );
1378  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
1379  }
1380  else if( SwHtmlOptType::PARAM == nType )
1381  {
1382  aParams.push_back( i );
1383  }
1384  }
1385 
1386  rHTMLWrt.Strm().WriteChar( '>' );
1387 
1388  rHTMLWrt.IncIndentLevel(); // indent the applet content
1389 
1390  size_t ii = aParams.size();
1391  while( ii > 0 )
1392  {
1393  const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1394  const OUString& rName = rCommand.GetCommand();
1395  const OUString& rValue = rCommand.GetArgument();
1396  rHTMLWrt.OutNewLine();
1397  OStringBuffer sBuf;
1398  sBuf.append("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param
1400  "=\"");
1401  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1402  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1403  sBuf.append("\" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
1404  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1405  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
1406  }
1407 
1408  rHTMLWrt.DecIndentLevel(); // indent the applet content
1409  if( aCommands.size() )
1410  rHTMLWrt.OutNewLine();
1411  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OString(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet), false );
1412  }
1413  else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1414  {
1415  // write plug-ins parameters as options
1416 
1417  uno::Sequence < beans::PropertyValue > aProps;
1418  aAny = xSet->getPropertyValue("PluginCommands");
1419  aAny >>= aProps;
1420 
1421  SvCommandList aCommands;
1422  aCommands.FillFromSequence( aProps );
1423  for( size_t i = 0; i < aCommands.size(); i++ )
1424  {
1425  const SvCommand& rCommand = aCommands[ i ];
1426  const OUString& rName = rCommand.GetCommand();
1427 
1428  if( SwApplet_Impl::GetOptionType( rName, false ) == SwHtmlOptType::TAG )
1429  {
1430  const OUString& rValue = rCommand.GetArgument();
1431  rWrt.Strm().WriteChar( ' ' );
1432  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1433  rWrt.Strm().WriteCharPtr( "=\"" );
1434  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
1435  }
1436  }
1437  rHTMLWrt.Strm().WriteChar( '>' );
1438  }
1439  else
1440  {
1441  // and for Floating-Frames just output another </IFRAME>
1442 
1443  rHTMLWrt.Strm().WriteChar( '>' );
1444  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OString(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe), false );
1445  }
1446 
1447  if( !aEndTags.isEmpty() )
1448  rWrt.Strm().WriteOString( aEndTags );
1449 
1450  return rWrt;
1451 }
1452 
1454  bool bInCntnr )
1455 {
1456  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1457 
1458  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1459  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1460  SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1461 
1462  OSL_ENSURE( pOLENd, "OLE-Node expected" );
1463  if( !pOLENd )
1464  return rWrt;
1465 
1466  if (rHTMLWrt.mbSkipImages)
1467  {
1468  // If we skip images, embedded objects would be completely lost.
1469  // Instead, try to use the HTML export of the embedded object.
1470  uno::Reference<text::XTextContent> xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rHTMLWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
1471  uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
1472  uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
1473  SAL_WARN_IF(!xStorable.is(), "sw.html", "OutHTML_FrameFormatOLENodeGrf: no embedded object");
1474 
1475  // Figure out what is the filter name of the embedded object.
1476  uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
1477  OUString aFilter;
1478  if (xServiceInfo.is())
1479  {
1480  if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
1481  aFilter = "HTML (StarCalc)";
1482  else if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
1483  aFilter = "HTML (StarWriter)";
1484  }
1485 
1486  if (xStorable.is() && !aFilter.isEmpty())
1487  {
1488  try
1489  {
1490  // FIXME: exception for the simplest test document, too
1491  SvMemoryStream aStream;
1492  uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
1493  utl::MediaDescriptor aMediaDescriptor;
1494  aMediaDescriptor["FilterName"] <<= aFilter;
1495  aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter");
1496  aMediaDescriptor["OutputStream"] <<= xOutputStream;
1497  xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList());
1498  SAL_WARN_IF(aStream.GetSize()>=o3tl::make_unsigned(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString");
1499  OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize()));
1500  // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p'
1502  rWrt.Strm().WriteOString(aData);
1503  HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OString(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
1504  }
1505  catch ( uno::Exception& )
1506  {
1507  }
1508  }
1509 
1510  return rWrt;
1511  }
1512 
1513  if ( !pOLENd->GetGraphic() )
1514  {
1515  SAL_WARN("sw.html", "Unexpected missing OLE fallback graphic");
1516  return rWrt;
1517  }
1518 
1519  Graphic aGraphic( *pOLENd->GetGraphic() );
1520 
1521  SwDocShell* pDocSh = rHTMLWrt.m_pDoc->GetDocShell();
1522  bool bObjectOpened = false;
1523  OUString aRTFType = "text/rtf";
1524  if (!rHTMLWrt.m_aRTFOLEMimeType.isEmpty())
1525  {
1526  aRTFType = rHTMLWrt.m_aRTFOLEMimeType;
1527  }
1528 
1529  if (rHTMLWrt.mbXHTML && pDocSh)
1530  {
1531  // Map native data to an outer <object> element.
1532 
1533  // Calculate the file name, which is meant to be the same as the
1534  // replacement image, just with a .ole extension.
1535  OUString aFileName = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"ole");
1536 
1537  // Write the data.
1538  SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
1539  uno::Reference<embed::XEmbeddedObject> xEmbeddedObject = rOLEObj.GetOleRef();
1540  OUString aFileType;
1541  SvFileStream aOutStream(aFileName, StreamMode::WRITE);
1542  uno::Reference<io::XActiveDataStreamer> xStreamProvider;
1543  uno::Reference<embed::XEmbedPersist2> xOwnEmbedded;
1544  if (xEmbeddedObject.is())
1545  {
1546  xStreamProvider.set(xEmbeddedObject, uno::UNO_QUERY);
1547  xOwnEmbedded.set(xEmbeddedObject, uno::UNO_QUERY);
1548  }
1549  if (xStreamProvider.is())
1550  {
1551  // Real OLE2 case: OleEmbeddedObject.
1552  uno::Reference<io::XInputStream> xStream(xStreamProvider->getStream(), uno::UNO_QUERY);
1553  if (xStream.is())
1554  {
1555  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream));
1556  if (SwReqIfReader::WrapOleInRtf(*pStream, aOutStream, *pOLENd, rFrameFormat))
1557  {
1558  // Data always wrapped in RTF.
1559  aFileType = aRTFType;
1560  }
1561  }
1562  }
1563  else if (xOwnEmbedded.is())
1564  {
1565  // Our own embedded object: OCommonEmbeddedObject.
1566  SvxMSExportOLEObjects aOLEExp(0);
1567  // Trigger the load of the OLE object if needed, otherwise we can't
1568  // export it.
1569  pOLENd->GetTwipSize();
1570  SvMemoryStream aMemory;
1571  tools::SvRef<SotStorage> pStorage = new SotStorage(aMemory);
1572  aOLEExp.ExportOLEObject(rOLEObj.GetObject(), *pStorage);
1573  pStorage->Commit();
1574  aMemory.Seek(0);
1575  if (SwReqIfReader::WrapOleInRtf(aMemory, aOutStream, *pOLENd, rFrameFormat))
1576  {
1577  // Data always wrapped in RTF.
1578  aFileType = aRTFType;
1579  }
1580  }
1581  else
1582  {
1583  // Otherwise the native data is just a grab-bag: ODummyEmbeddedObject.
1584  const OUString& aStreamName = rOLEObj.GetCurrentPersistName();
1585  uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
1586  uno::Reference<io::XStream> xInStream;
1587  try
1588  {
1589  // Even the native data may be missing.
1590  xInStream = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
1591  } catch (const uno::Exception&)
1592  {
1593  TOOLS_WARN_EXCEPTION("sw.html", "OutHTML_FrameFormatOLENodeGrf: failed to open stream element");
1594  }
1595  if (xInStream.is())
1596  {
1597  uno::Reference<io::XStream> xOutStream(new utl::OStreamWrapper(aOutStream));
1598  comphelper::OStorageHelper::CopyInputToOutput(xInStream->getInputStream(),
1599  xOutStream->getOutputStream());
1600  }
1601 
1602  uno::Reference<beans::XPropertySet> xOutStreamProps(xInStream, uno::UNO_QUERY);
1603  if (xOutStreamProps.is())
1604  xOutStreamProps->getPropertyValue("MediaType") >>= aFileType;
1605  if (!aRTFType.isEmpty())
1606  {
1607  aFileType = aRTFType;
1608  }
1609  }
1610  aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
1611 
1612  // Refer to this data.
1613  if (rHTMLWrt.m_bLFPossible)
1614  rHTMLWrt.OutNewLine();
1615  rWrt.Strm().WriteOString(OString("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
1616  rWrt.Strm().WriteOString(OString(" data=\"" + aFileName.toUtf8() + "\""));
1617  if (!aFileType.isEmpty())
1618  rWrt.Strm().WriteOString(OString(" type=\"" + aFileType.toUtf8() + "\""));
1619  rWrt.Strm().WriteOString(">");
1620  bObjectOpened = true;
1621  rHTMLWrt.m_bLFPossible = true;
1622  }
1623 
1624  OUString aGraphicURL;
1625  OUString aMimeType;
1626  if(!rHTMLWrt.mbEmbedImages)
1627  {
1628  const OUString* pTempFileName = rHTMLWrt.GetOrigFileName();
1629  if(pTempFileName)
1630  aGraphicURL = *pTempFileName;
1631 
1632  OUString aFilterName("JPG");
1633  XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
1634 
1635  if (bObjectOpened)
1636  {
1637  aFilterName = "PNG";
1638  nFlags = XOutFlags::NONE;
1639  aMimeType = "image/png";
1640 
1641  if (aGraphic.GetType() == GraphicType::NONE)
1642  {
1643  // The OLE Object has no replacement image, write a stub.
1644  aGraphicURL = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"png");
1645  osl::File aFile(aGraphicURL);
1646  aFile.open(osl_File_OpenFlag_Create);
1647  aFile.close();
1648  }
1649  }
1650 
1651  ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL,
1652  aFilterName,
1653  nFlags );
1654  if( nErr ) // error, don't write anything
1655  {
1656  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1657  return rWrt;
1658  }
1659  aGraphicURL = URIHelper::SmartRel2Abs(
1660  INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
1662 
1663  }
1664  HtmlFrmOpts nFlags = bInCntnr ? HtmlFrmOpts::GenImgAllMask
1666  if (bObjectOpened)
1667  nFlags |= HtmlFrmOpts::Replacement;
1668  HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
1669  OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, aGraphicURL, aGraphic,
1670  pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1671  nFlags, "ole", nullptr, aMimeType );
1672  OutHTML_ImageEnd(aHtml, rWrt);
1673 
1674  if (bObjectOpened)
1675  // Close native data.
1676  rWrt.Strm().WriteOString(OString("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object
1677  ">"));
1678 
1679  return rWrt;
1680 }
1681 
1682 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OOO_STRING_SVTOOLS_HTML_O_src
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
static SwHtmlOptType GetOptionType(const OUString &rName, bool bApplet)
static void SetSpace(const Size &rPixSpace, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFlyItemSet)
Definition: htmlplug.cxx:242
const char *const aClassID
const HtmlFrmOpts HTML_FRMOPTS_IFRAME
Definition: htmlplug.cxx:128
URL aURL
const OUString & GetBaseURL() const
Definition: shellio.hxx:444
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
#define OOO_STRING_SW_HTML_O_Hidden
sal_Int32 nIndex
const OUString & GetName() const
HtmlOptionId GetToken() const
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
bool mbXHTML
If XHTML markup should be written instead of HTML.
Definition: wrthtml.hxx:395
bool WrapOleInRtf(SvStream &rOle2, SvStream &rRtf, SwOLENode &rOLENode, const SwFrameFormat &rFormat)
Wraps an OLE2 container binary in an RTF fragment.
sal_uInt16 GetLower() const
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars=nullptr)
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
void setWidth(tools::Long nWidth)
#define HTML_DFLT_APPLET_HEIGHT
Definition: htmlplug.cxx:90
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
static constexpr auto Items
SwDocShell * GetDocShell()
Definition: doc.hxx:1352
void InsertParam()
Definition: htmlplug.cxx:997
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
BitmapChecksum GetChecksum() const
#define HTML_DFLT_EMBED_HEIGHT
Definition: htmlplug.cxx:87
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const HtmlFrmOpts HTML_FRMOPTS_EMBED
Definition: htmlplug.cxx:100
const HtmlFrmOpts HTML_FRMOPTS_HIDDEN_EMBED
Definition: htmlplug.cxx:106
#define SO3_IFRAME_CLASSID
Writer & OutHTML_FrameFormatOLENodeGrf(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1453
#define MINFLY
Definition: swtypes.hxx:60
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_uIntPtr sal_uLong
tools::Long GetRight() const
size_t size() const
void SetTitle(const OUString &rTitle)
Definition: ndnotxt.cxx:245
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:915
tools::Long m_nHeight
Definition: svxcss1.hxx:134
const OUString & GetString() const
constexpr sal_uInt16 RES_FRMATR_END(133)
void DecIndentLevel()
Definition: wrthtml.hxx:507
OUString m_aNonConvertableCharacters
Definition: wrthtml.hxx:294
tools::Long m_nWidth
Definition: svxcss1.hxx:134
#define OOO_STRING_SVTOOLS_HTML_iframe
Writer & OutHTML_ImageEnd(HtmlWriter &rHtml, Writer &rWrt)
sal_uInt64 Seek(sal_uInt64 nPos)
bool InsertEmbed()
Definition: htmlplug.cxx:348
OUString aId
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, std::string_view rStr, bool bOn=true)
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
SvStream & WriteCharPtr(const char *pBuf)
OString maNamespace
XML namespace, in case of XHTML.
Definition: wrthtml.hxx:397
bool Commit()
ErrCode m_nWarn
Definition: wrthtml.hxx:307
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1442
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
SvxCSS1LengthType m_eHeightType
Definition: svxcss1.hxx:138
bool m_bLFPossible
Definition: wrthtml.hxx:380
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
Definition: shellio.cxx:613
Sequence< PropertyValue > aArguments
Reference< XInputStream > xStream
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
ScrollingMode
#define HTML_DFLT_APPLET_WIDTH
Definition: htmlplug.cxx:89
void SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &)
#define WARN_SWG_POOR_LOAD
Definition: swerror.h:40
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:967
const OUString & GetName() const
Definition: format.hxx:115
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
#define OOO_STRING_SVTOOLS_HTML_O_mayscript
static OUString GetAbsURL(OUString const &rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
static void Out_FrameDescriptor(SvStream &, const OUString &rBaseURL, const css::uno::Reference< css::beans::XPropertySet > &xSet, rtl_TextEncoding eDestEnc=RTL_TEXTENCODING_MS_1252, OUString *pNonConvertableChars=nullptr)
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
void FillSequence(css::uno::Sequence< css::beans::PropertyValue > &) const
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)
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
#define OOO_STRING_SVTOOLS_HTML_O_code
static OUString StripQueryFromPath(const OUString &rBase, const OUString &rPath)
Strips query and fragment from a URL path if base URL is a file:// one.
Definition: htmlplug.cxx:335
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:576
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
void EndApplet()
Definition: htmlplug.cxx:968
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
DocumentType eType
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
Definition: wrthtml.cxx:1234
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:58
#define TOOLS_WARN_EXCEPTION(area, stream)
The graphic frame is a replacement image of an OLE object.
rtl_TextEncoding m_eDestEnc
Definition: wrthtml.hxx:335
#define SAL_MAX_INT32
const OUString & GetArgument() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
SwDoc & GetDoc()
Definition: node.hxx:212
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void FillFromSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
void InsertFloatingFrame()
Definition: htmlplug.cxx:1030
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
const HtmlFrmOpts HTML_FRMOPTS_OLE_CSS1
Definition: htmlplug.cxx:135
const INetURLObject & GetURL() const
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
const Graphic * GetGraphic()
Definition: ndole.cxx:244
sal_uInt64 GetSize()
FlyAnchors.
Definition: fmtanchr.hxx:34
tools::Long GetLeft() const
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
const char *const aMimeType[]
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void Append(const OUString &rCommand, const OUString &rArg)
SwHtmlOptType
float u
#define OOO_STRING_SVTOOLS_HTML_O_name
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
#define OOO_STRING_SVTOOLS_HTML_embed
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:694
const HtmlFrmOpts HTML_FRMOPTS_APPLET
Definition: htmlplug.cxx:116
bool mbEmbedImages
Definition: wrthtml.hxx:391
#define SO3_APPLET_CLASSID
virtual Size GetTwipSize() const override
Definition: ndole.cxx:422
SwHTMLFrameType
Definition: htmlfly.hxx:34
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:558
Frame cannot be moved in Var-direction.
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
const HtmlFrmOpts HTML_FRMOPTS_APPLET_CNTNR
Definition: htmlplug.cxx:113
HTMLOptionEnum< sal_Int16 > const aHTMLImgVAlignTable[]
Definition: htmlgrin.cxx:82
sal_uInt32 GetNumber() const
bool HasFrameBorder() const
bool setBase(std::u16string_view rTheBase, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
OUString m_aRTFOLEMimeType
Definition: wrthtml.hxx:409
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
const OUString & GetCommand() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
HtmlFrmOpts
Definition: wrthtml.hxx:75
#define OOO_STRING_SVTOOLS_HTML_O_codebase
const Size & GetMargin() const
void EndObject()
Definition: htmlplug.cxx:838
const HtmlFrmOpts HTML_FRMOPTS_APPLET_ALL
Definition: htmlplug.cxx:110
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_ALL
Definition: htmlplug.cxx:122
#define OOO_STRING_SVTOOLS_HTML_applet
SvxCSS1LengthType m_eWidthType
Definition: svxcss1.hxx:138
ScrollingMode GetScrollingMode() const
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
XOutFlags
void ParseFrameOptions(SfxFrameDescriptor *pFrame, const HTMLOptions &rOptions, const OUString &rBaseURL)
#define HTMLMODE_ABS_POS_FLY
Definition: wrthtml.hxx:122
Any makeAny(Color const &value)
#define HTML_DFLT_EMBED_WIDTH
Definition: htmlplug.cxx:86
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
Writer & OutHTML_ImageStart(HtmlWriter &rHtml, Writer &rWrt, const SwFrameFormat &rFrameFormat, const OUString &rGraphicURL, Graphic const &rGraphic, const OUString &rAlternateText, const Size &rRealSize, HtmlFrmOpts nFrameOpts, const char *pMarkType, const ImageMap *pAltImgMap, const OUString &rMimeType)
#define SAL_WARN_IF(condition, area, stream)
SvStream & WriteOString(std::string_view rStr)
#define ERRCODE_NONE
constexpr tools::Long Height() const
unsigned char sal_uInt8
SwTwips GetPos() const
Definition: fmtornt.hxx:59
OUString GetTitle() const
Definition: ndnotxt.cxx:258
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
void IncIndentLevel()
Definition: wrthtml.hxx:503
void ExportOLEObject(svt::EmbeddedObjectRef const &rObj, SotStorage &rDestStg)
::std::vector< HTMLOption > HTMLOptions
COMPHELPER_DLLPUBLIC bool isFileUrl(OUString const &url)
bool ExtractOleFromRtf(SvStream &rRtf, SvStream &rOle, bool &bOwnFormat)
Extracts an OLE2 container binary from an RTF fragment.
OUString aName
const OUString * GetOrigFileName() const
Definition: shellio.hxx:439
SwNodes & GetNodes()
Definition: doc.hxx:409
void SetGraphic(const Graphic &rGraphic, const OUString &rMediaType)
QPRO_FUNC_TYPE nType
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
Definition: wrthtml.cxx:1491
#define OOO_STRING_SVTOOLS_HTML_param
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
SvStream & WriteChar(char nChar)
const OUString & GetTokenString() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:93
#define OOO_STRING_SVTOOLS_HTML_O_value
void setHeight(tools::Long nHeight)
SvStream & Strm()
Definition: writer.cxx:215
#define OOO_STRING_SVTOOLS_HTML_O_type
static GraphicFilter & GetGraphicFilter()
#define SAL_WARN(area, stream)
bool SetURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
HTMLOptionEnum< sal_Int16 > const aHTMLImgHAlignTable[]
Definition: htmlgrin.cxx:75
static css::uno::Reference< css::text::XTextContent > CreateXTextEmbeddedObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3473
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL
Definition: htmlplug.cxx:93
#define OOO_STRING_SVTOOLS_HTML_object
static sal_uInt16 GuessOLENodeFrameType(const SwNode &rNd)
Definition: htmlplug.cxx:1165
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
#define OOO_STRING_SVTOOLS_HTML_span
#define SO3_PLUGIN_CLASSID
bool mbSkipImages
Definition: wrthtml.hxx:388
OString read_uInt8s_ToOString(SvStream &rStrm, std::size_t nLen)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:719
aStr
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool MakeId(const OUString &rId)
const HtmlFrmOpts HTML_FRMOPTS_EMBED_CNTNR
Definition: htmlplug.cxx:97
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_CNTNR
Definition: htmlplug.cxx:125
SwDoc * m_pDoc
Definition: shellio.hxx:408
static void SetFixSize(const Size &rPixSize, const Size &rTwipDfltSize, bool bPercentWidth, bool bPercentHeight, SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet)
Definition: htmlplug.cxx:164
OString OutFrameFormatOptions(const SwFrameFormat &rFrameFormat, const OUString &rAltText, HtmlFrmOpts nFrameOpts)
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:1191
const void * GetData()
sal_uInt16 GetUpper() const
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1583
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:1848
Base class of the Writer document model elements.
Definition: node.hxx:80
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo