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 
87 #define HTML_DFLT_EMBED_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
88 #define HTML_DFLT_EMBED_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
89 
90 #define HTML_DFLT_APPLET_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
91 #define HTML_DFLT_APPLET_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
92 
93 
110 
122 
135 
139 
140 namespace
141 {
146 OUString lcl_CalculateFileName(const OUString* pOrigFileName, const Graphic& rGraphic,
147  std::u16string_view rExtension)
148 {
149  OUString aFileName;
150 
151  if (pOrigFileName)
152  aFileName = *pOrigFileName;
153  INetURLObject aURL(aFileName);
154  OUString aName = aURL.getBase() + "_" +
155  aURL.getExtension() + "_" +
156  OUString::number(rGraphic.GetChecksum(), 16);
157  aURL.setBase(aName);
158  aURL.setExtension(rExtension);
160 
161  return aFileName;
162 }
163 }
164 
165 void SwHTMLParser::SetFixSize( const Size& rPixSize,
166  const Size& rTwipDfltSize,
167  bool bPercentWidth, bool bPercentHeight,
168  SvxCSS1PropertyInfo const & rCSS1PropInfo,
169  SfxItemSet& rFlyItemSet )
170 {
171  // convert absolute size values into Twip
172  sal_uInt8 nPercentWidth = 0, nPercentHeight = 0;
173  Size aTwipSz( bPercentWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
174  bPercentHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
175  if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
176  {
177  aTwipSz =
179  MapMode(MapUnit::MapTwip) );
180  }
181 
182  // process width
183  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eWidthType )
184  {
185  nPercentWidth = static_cast<sal_uInt8>(rCSS1PropInfo.m_nWidth);
186  aTwipSz.setWidth( rTwipDfltSize.Width() );
187  }
188  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eWidthType )
189  {
190  aTwipSz.setWidth( rCSS1PropInfo.m_nWidth );
191  }
192  else if( bPercentWidth && rPixSize.Width() )
193  {
194  nPercentWidth = static_cast<sal_uInt8>(rPixSize.Width());
195  if( nPercentWidth > 100 )
196  nPercentWidth = 100;
197 
198  aTwipSz.setWidth( rTwipDfltSize.Width() );
199  }
200  else if( USHRT_MAX==rPixSize.Width() )
201  {
202  aTwipSz.setWidth( rTwipDfltSize.Width() );
203  }
204  if( aTwipSz.Width() < MINFLY )
205  {
206  aTwipSz.setWidth( MINFLY );
207  }
208 
209  // process height
210  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eHeightType )
211  {
212  nPercentHeight = static_cast<sal_uInt8>(rCSS1PropInfo.m_nHeight);
213  aTwipSz.setHeight( rTwipDfltSize.Height() );
214  }
215  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eHeightType )
216  {
217  aTwipSz.setHeight( rCSS1PropInfo.m_nHeight );
218  }
219  else if( bPercentHeight && rPixSize.Height() )
220  {
221  nPercentHeight = static_cast<sal_uInt8>(rPixSize.Height());
222  if( nPercentHeight > 100 )
223  nPercentHeight = 100;
224 
225  aTwipSz.setHeight( rTwipDfltSize.Height() );
226  }
227  else if( USHRT_MAX==rPixSize.Height() )
228  {
229  aTwipSz.setHeight( rTwipDfltSize.Height() );
230  }
231  if( aTwipSz.Height() < MINFLY )
232  {
233  aTwipSz.setHeight( MINFLY );
234  }
235 
236  // set size
237  SwFormatFrameSize aFrameSize( SwFrameSize::Fixed, aTwipSz.Width(), aTwipSz.Height() );
238  aFrameSize.SetWidthPercent( nPercentWidth );
239  aFrameSize.SetHeightPercent( nPercentHeight );
240  rFlyItemSet.Put( aFrameSize );
241 }
242 
243 void SwHTMLParser::SetSpace( const Size& rPixSpace,
244  SfxItemSet& rCSS1ItemSet,
245  SvxCSS1PropertyInfo& rCSS1PropInfo,
246  SfxItemSet& rFlyItemSet )
247 {
248  sal_Int32 nLeftSpace = 0, nRightSpace = 0;
249  sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
250  if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
251  {
252  Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
253  aTwipSpc =
255  MapMode(MapUnit::MapTwip) );
256  nLeftSpace = nRightSpace = aTwipSpc.Width();
257  nUpperSpace = nLowerSpace = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
258  }
259 
260  // set left/right margin
261  const SfxPoolItem *pItem;
262  if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
263  {
264  // if applicable remove the first line indent
265  const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
266  SvxLRSpaceItem aLRItem( *pLRItem );
267  aLRItem.SetTextFirstLineOffset( 0 );
268  if( rCSS1PropInfo.m_bLeftMargin )
269  {
270  nLeftSpace = aLRItem.GetLeft();
271  rCSS1PropInfo.m_bLeftMargin = false;
272  }
273  if( rCSS1PropInfo.m_bRightMargin )
274  {
275  nRightSpace = aLRItem.GetRight();
276  rCSS1PropInfo.m_bRightMargin = false;
277  }
278  rCSS1ItemSet.ClearItem( RES_LR_SPACE );
279  }
280  if( nLeftSpace > 0 || nRightSpace > 0 )
281  {
282  SvxLRSpaceItem aLRItem( RES_LR_SPACE );
283  aLRItem.SetLeft( std::max<sal_Int32>(nLeftSpace, 0) );
284  aLRItem.SetRight( std::max<sal_Int32>(nRightSpace, 0) );
285  rFlyItemSet.Put( aLRItem );
286  if( nLeftSpace )
287  {
288  const SwFormatHoriOrient& rHoriOri =
289  rFlyItemSet.Get( RES_HORI_ORIENT );
290  if( text::HoriOrientation::NONE == rHoriOri.GetHoriOrient() )
291  {
292  SwFormatHoriOrient aHoriOri( rHoriOri );
293  aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
294  rFlyItemSet.Put( aHoriOri );
295  }
296  }
297  }
298 
299  // set top/bottom margin
300  if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
301  {
302  // if applicable remove the first line indent
303  const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
304  if( rCSS1PropInfo.m_bTopMargin )
305  {
306  nUpperSpace = pULItem->GetUpper();
307  rCSS1PropInfo.m_bTopMargin = false;
308  }
309  if( rCSS1PropInfo.m_bBottomMargin )
310  {
311  nLowerSpace = pULItem->GetLower();
312  rCSS1PropInfo.m_bBottomMargin = false;
313  }
314  rCSS1ItemSet.ClearItem( RES_UL_SPACE );
315  }
316  if( !(nUpperSpace || nLowerSpace) )
317  return;
318 
319  SvxULSpaceItem aULItem( RES_UL_SPACE );
320  aULItem.SetUpper( nUpperSpace );
321  aULItem.SetLower( nLowerSpace );
322  rFlyItemSet.Put( aULItem );
323  if( nUpperSpace )
324  {
325  const SwFormatVertOrient& rVertOri =
326  rFlyItemSet.Get( RES_VERT_ORIENT );
327  if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
328  {
329  SwFormatVertOrient aVertOri( rVertOri );
330  aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
331  rFlyItemSet.Put( aVertOri );
332  }
333  }
334 }
335 
336 OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
337 {
338  if (!comphelper::isFileUrl(rBase))
339  return rPath;
340 
341  sal_Int32 nIndex = rPath.indexOf('?');
342 
343  if (nIndex != -1)
344  return rPath.copy(0, nIndex);
345 
346  return rPath;
347 }
348 
350 {
351  OUString aURL, aType, aName, aAlt, aId, aStyle, aClass;
352  OUString aData;
353  Size aSize( USHRT_MAX, USHRT_MAX );
354  Size aSpace( USHRT_MAX, USHRT_MAX );
355  bool bPercentWidth = false, bPercentHeight = false, bHidden = false;
356  sal_Int16 eVertOri = text::VertOrientation::NONE;
357  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
358  SvCommandList aCmdLst;
359  const HTMLOptions& rHTMLOptions = GetOptions();
360 
361  // The options are read forwards, because the plug-ins expect them in this
362  // order. Still only the first value of an option may be regarded.
363  for (const auto & rOption : rHTMLOptions)
364  {
365  switch( rOption.GetToken() )
366  {
367  case HtmlOptionId::ID:
368  aId = rOption.GetString();
369  break;
370  case HtmlOptionId::STYLE:
371  aStyle = rOption.GetString();
372  break;
373  case HtmlOptionId::CLASS:
374  aClass = rOption.GetString();
375  break;
376  case HtmlOptionId::NAME:
377  aName = rOption.GetString();
378  break;
379  case HtmlOptionId::SRC:
380  if( aURL.isEmpty() )
381  aURL = rOption.GetString();
382  break;
383  case HtmlOptionId::ALT:
384  aAlt = rOption.GetString();
385  break;
386  case HtmlOptionId::TYPE:
387  if( aType.isEmpty() )
388  aType = rOption.GetString();
389  break;
390  case HtmlOptionId::ALIGN:
391  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
392  {
393  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
394  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
395  }
396  break;
397  case HtmlOptionId::WIDTH:
398  if( USHRT_MAX==aSize.Width() )
399  {
400  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
401  aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
402  }
403  break;
404  case HtmlOptionId::HEIGHT:
405  if( USHRT_MAX==aSize.Height() )
406  {
407  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
408  aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
409  }
410  break;
411  case HtmlOptionId::HSPACE:
412  if( USHRT_MAX==aSpace.Width() )
413  aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
414  break;
415  case HtmlOptionId::VSPACE:
416  if( USHRT_MAX==aSpace.Height() )
417  aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
418  break;
419  case HtmlOptionId::DATA:
420  if (m_bXHTML && aURL.isEmpty())
421  aData = rOption.GetString();
422  break;
423  case HtmlOptionId::UNKNOWN:
424  if (rOption.GetTokenString().equalsIgnoreAsciiCase(
426  {
427  bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
428  "FALSE");
429  }
430  break;
431  default: break;
432  }
433 
434  // All parameters are passed to the plug-in.
435  aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
436  }
437 
438  static const std::set<std::u16string_view> vAllowlist = {
439  u"image/png",
440  u"image/gif",
441  u"image/x-MS-bmp",
442  u"image/jpeg",
443  u"image/x-wmf",
444  u"image/svg+xml",
445  u"image/tiff",
446  u"image/x-emf",
447  };
448 
449  if (vAllowlist.find(aType) != vAllowlist.end() && m_aEmbeds.empty())
450  {
451  // Toplevel <object> for an image format -> that's an image, not an OLE object.
452  m_aEmbeds.push(nullptr);
453  return false;
454  }
455 
456  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
457  SvxCSS1PropertyInfo aPropInfo;
458  if( HasStyleOptions( aStyle, aId, aClass ) )
459  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
460 
461  // Convert the default values (except height/width, which is done by SetFrameSize())
462  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
463  eVertOri = text::VertOrientation::TOP;
464  if( USHRT_MAX==aSpace.Width() )
465  aSpace.setWidth( 0 );
466  if( USHRT_MAX==aSpace.Height() )
467  aSpace.setHeight( 0 );
468  if( bHidden )
469  {
470  // Size (0,0) will be changed to (MINFLY, MINFLY) in SetFrameSize()
471  aSize.setWidth( 0 ); aSize.setHeight( 0 );
472  aSpace.setWidth( 0 ); aSpace.setHeight( 0 );
473  bPercentWidth = bPercentHeight = false;
474  }
475 
476  // prepare the URL
477  INetURLObject aURLObj;
478  bool bHasURL = !aURL.isEmpty() &&
479  aURLObj.SetURL(
481  INetURLObject(m_sBaseURL), aURL,
483  bool bHasData = !aData.isEmpty();
484 
485  try
486  {
487  // Strip query and everything after that for file:// URLs, browsers do
488  // the same.
489  aURLObj.SetURL(rtl::Uri::convertRelToAbs(
490  m_sBaseURL, SwHTMLParser::StripQueryFromPath(m_sBaseURL, aData)));
491  }
492  catch (const rtl::MalformedUriException& /*rException*/)
493  {
494  bHasData = false;
495  }
496 
497  // do not insert plugin if it has neither URL nor type
498  bool bHasType = !aType.isEmpty();
499  if( !bHasURL && !bHasType && !bHasData )
500  return true;
501 
502  if (!m_aEmbeds.empty())
503  {
504  // Nested XHTML <object> element: points to replacement graphic.
505  SwOLENode* pOLENode = m_aEmbeds.top();
506  if (!pOLENode)
507  {
508  // <object> is mapped to an image -> ignore replacement graphic.
509  return true;
510  }
511 
512  svt::EmbeddedObjectRef& rObj = pOLENode->GetOLEObj().GetObject();
513  Graphic aGraphic;
514  if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
515  return true;
516 
517  rObj.SetGraphic(aGraphic, aType);
518 
519  // Set the size of the OLE frame to the size of the graphic.
520  SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
521  if (!pFormat)
522  return true;
523  SwAttrSet aAttrSet(pFormat->GetAttrSet());
524  aAttrSet.ClearItem(RES_CNTNT);
526  Size aDefaultTwipSize(pDevice->PixelToLogic(aGraphic.GetSizePixel(pDevice), MapMode(MapUnit::MapTwip)));
527  SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet);
528  pOLENode->GetDoc().SetFlyFrameAttr(*pFormat, aAttrSet);
529  return true;
530  }
531 
532  // create the plug-in
534  OUString aObjName;
535  uno::Reference < embed::XEmbeddedObject > xObj;
536  if (!bHasData)
537  {
538  xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
540  {
541  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
542  if ( xSet.is() )
543  {
544  if( bHasURL )
545  xSet->setPropertyValue("PluginURL", uno::makeAny( aURL ) );
546  if( bHasType )
547  xSet->setPropertyValue("PluginMimeType", uno::makeAny( aType ) );
548 
549  uno::Sequence < beans::PropertyValue > aProps;
550  aCmdLst.FillSequence( aProps );
551  xSet->setPropertyValue("PluginCommands", uno::makeAny( aProps ) );
552 
553  }
554  }
555  }
556  else if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
557  {
558  // Has non-empty data attribute in XHTML: map that to an OLE object.
559  uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
560  aCnt.SwitchPersistence(xStorage);
561  aObjName = aCnt.CreateUniqueObjectName();
562  {
564  StreamMode::READ);
565  uno::Reference<io::XInputStream> xInStream;
566  SvMemoryStream aMemoryStream;
567 
568  // Allow any MIME type that starts with magic, unless a set of allowed types are
569  // specified.
570  auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
571  if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
572  {
573  OString aMagic("{\\object");
574  OString aHeader(read_uInt8s_ToOString(aFileStream, aMagic.getLength()));
575  aFileStream.Seek(0);
576  if (aHeader == aMagic)
577  {
578  // OLE2 wrapped in RTF: either own format or real OLE2 embedding.
579  bool bOwnFormat = false;
580  if (SwReqIfReader::ExtractOleFromRtf(aFileStream, aMemoryStream, bOwnFormat))
581  {
582  xInStream.set(new utl::OStreamWrapper(aMemoryStream));
583  }
584 
585  if (bOwnFormat)
586  {
587  uno::Sequence<beans::PropertyValue> aMedium = comphelper::InitPropertySequence(
588  { { "InputStream", uno::makeAny(xInStream) },
589  { "URL", uno::makeAny(OUString("private:stream")) },
590  { "DocumentBaseURL", uno::makeAny(m_sBaseURL) } });
591  xObj = aCnt.InsertEmbeddedObject(aMedium, aName, &m_sBaseURL);
592  }
593  else
594  {
595  // The type is now an OLE2 container, not the original XHTML type.
596  aType = "application/vnd.sun.star.oleobject";
597  }
598  }
599  }
600 
601  if (!xInStream.is())
602  // Non-RTF case.
603  xInStream.set(new utl::OStreamWrapper(aFileStream));
604 
605  if (!xObj.is())
606  {
607  uno::Reference<io::XStream> xOutStream
608  = xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
609  if (aFileStream.IsOpen())
611  xOutStream->getOutputStream());
612 
613  if (!aType.isEmpty())
614  {
615  // Set media type of the native data.
616  uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
617  if (xOutStreamProps.is())
618  xOutStreamProps->setPropertyValue("MediaType", uno::makeAny(aType));
619  }
620  }
621  xObj = aCnt.GetEmbeddedObject(aObjName);
622  }
623  }
624 
625  SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> 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  SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
1135  if( !IsNewDoc() )
1136  Reader::ResetFrameFormatAttrs( aFrameSet );
1137 
1138  // set the anchor and the adjustment
1139  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
1140 
1141  // and still the size of the frame
1143  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
1144  SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
1145 
1146  // and insert into the document
1147  SwFrameFormat* pFlyFormat =
1148  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
1149  ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
1150  &aFrameSet);
1151 
1152  // set the alternative name
1153  SwNoTextNode *pNoTextNd =
1154  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
1155  ->GetIndex()+1 ]->GetNoTextNode();
1156  pNoTextNd->SetTitle( aAlt );
1157 
1158  // if applicable create frames and register auto-bound frames
1159  RegisterFlyFrame( pFlyFormat );
1160 
1161  m_bInFloatingFrame = true;
1162 
1163  ++m_nFloatingFrames;
1164 }
1165 
1167 {
1168  SwOLEObj& rObj = const_cast<SwOLENode*>(rNode.GetOLENode())->GetOLEObj();
1169 
1171 
1172  uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
1173  SvGlobalName aClass( xClass->getClassID() );
1174  if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1175  {
1176  eType = HTML_FRMTYPE_PLUGIN;
1177  }
1178  else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1179  {
1180  eType = HTML_FRMTYPE_IFRAME;
1181  }
1182 #if HAVE_FEATURE_JAVA
1183  else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1184  {
1185  eType = HTML_FRMTYPE_APPLET;
1186  }
1187 #endif
1188 
1189  return static_cast< sal_uInt16 >(eType);
1190 }
1191 
1193  bool bInCntnr )
1194 {
1195  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1196 
1197  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1198  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1199  SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1200 
1201  OSL_ENSURE( pOLENd, "OLE-Node expected" );
1202  if( !pOLENd )
1203  return rWrt;
1204 
1205  SwOLEObj &rObj = pOLENd->GetOLEObj();
1206 
1207  uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1209  return rWrt;
1210 
1211  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1212  bool bHiddenEmbed = false;
1213 
1214  if( !xSet.is() )
1215  {
1216  OSL_FAIL("Unknown Object" );
1217  return rWrt;
1218  }
1219 
1220  HtmlFrmOpts nFrameOpts;
1221 
1222  // if possible output a line break before the "object"
1223  if( rHTMLWrt.m_bLFPossible )
1224  rHTMLWrt.OutNewLine( true );
1225 
1226  if( !rFrameFormat.GetName().isEmpty() )
1227  rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
1228  "ole" );
1229  uno::Any aAny;
1230  SvGlobalName aGlobName( xObj->getClassID() );
1231  OStringBuffer sOut;
1232  sOut.append('<');
1233  if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1234  {
1235  // first the plug-in specifics
1236  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
1237 
1238  OUString aStr;
1239  OUString aURL;
1240  aAny = xSet->getPropertyValue("PluginURL");
1241  if( (aAny >>= aStr) && !aStr.isEmpty() )
1242  {
1244  aStr);
1245  }
1246 
1247  if( !aURL.isEmpty() )
1248  {
1249  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_src "=\"");
1250  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1251  HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1252  sOut.append('\"');
1253  }
1254 
1255  OUString aType;
1256  aAny = xSet->getPropertyValue("PluginMimeType");
1257  if( (aAny >>= aType) && !aType.isEmpty() )
1258  {
1259  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"");
1260  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1261  HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1262  sOut.append('\"');
1263  }
1264 
1265  if ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) &&
1266  css::text::WrapTextMode_THROUGH == rFrameFormat.GetSurround().GetSurround() )
1267  {
1268  // A HIDDEN plug-in
1269  sOut.append(' ').append(OOO_STRING_SW_HTML_O_Hidden);
1270  nFrameOpts = HTML_FRMOPTS_HIDDEN_EMBED;
1271  bHiddenEmbed = true;
1272  }
1273  else
1274  {
1275  nFrameOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
1277  }
1278  }
1279  else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1280  {
1281  // or the applet specifics
1282 
1283  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
1284 
1285  // CODEBASE
1286  OUString aCd;
1287  aAny = xSet->getPropertyValue("AppletCodeBase");
1288  if( (aAny >>= aCd) && !aCd.isEmpty() )
1289  {
1290  OUString sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
1291  if( !sCodeBase.isEmpty() )
1292  {
1293  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_codebase "=\"");
1294  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1295  HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1296  sOut.append('\"');
1297  }
1298  }
1299 
1300  // CODE
1301  OUString aClass;
1302  aAny = xSet->getPropertyValue("AppletCode");
1303  aAny >>= aClass;
1304  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_code "=\"");
1305  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1306  HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1307  sOut.append('\"');
1308 
1309  // NAME
1310  OUString aAppletName;
1311  aAny = xSet->getPropertyValue("AppletName");
1312  aAny >>= aAppletName;
1313  if( !aAppletName.isEmpty() )
1314  {
1315  sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
1316  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1317  HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1318  sOut.append('\"');
1319  }
1320 
1321  bool bScript = false;
1322  aAny = xSet->getPropertyValue("AppletIsScript");
1323  aAny >>= bScript;
1324  if( bScript )
1325  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_mayscript);
1326 
1327  nFrameOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
1329  }
1330  else
1331  {
1332  // or the Floating-Frame specifics
1333 
1334  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
1335  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1336 
1338  xSet,
1339  rHTMLWrt.m_eDestEnc,
1340  &rHTMLWrt.m_aNonConvertableCharacters );
1341 
1342  nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
1344  }
1345 
1346  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1347 
1348  // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
1349  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1350  nFrameOpts |= HTML_FRMOPTS_OLE_CSS1;
1351  OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
1352  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1353  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
1354 
1355  if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1356  {
1357  // output the parameters of applets as separate tags
1358  // and write a </APPLET>
1359 
1360  uno::Sequence < beans::PropertyValue > aProps;
1361  aAny = xSet->getPropertyValue("AppletCommands");
1362  aAny >>= aProps;
1363 
1364  SvCommandList aCommands;
1365  aCommands.FillFromSequence( aProps );
1366  std::vector<sal_uLong> aParams;
1367  size_t i = aCommands.size();
1368  while( i > 0 )
1369  {
1370  const SvCommand& rCommand = aCommands[ --i ];
1371  const OUString& rName = rCommand.GetCommand();
1373  if( SwHtmlOptType::TAG == nType )
1374  {
1375  const OUString& rValue = rCommand.GetArgument();
1376  rWrt.Strm().WriteChar( ' ' );
1377  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1378  rWrt.Strm().WriteCharPtr( "=\"" );
1379  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
1380  }
1381  else if( SwHtmlOptType::PARAM == nType )
1382  {
1383  aParams.push_back( i );
1384  }
1385  }
1386 
1387  rHTMLWrt.Strm().WriteChar( '>' );
1388 
1389  rHTMLWrt.IncIndentLevel(); // indent the applet content
1390 
1391  size_t ii = aParams.size();
1392  while( ii > 0 )
1393  {
1394  const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1395  const OUString& rName = rCommand.GetCommand();
1396  const OUString& rValue = rCommand.GetArgument();
1397  rHTMLWrt.OutNewLine();
1398  OStringBuffer sBuf;
1399  sBuf.append("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param
1401  "=\"");
1402  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1403  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1404  sBuf.append("\" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
1405  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1406  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
1407  }
1408 
1409  rHTMLWrt.DecIndentLevel(); // indent the applet content
1410  if( aCommands.size() )
1411  rHTMLWrt.OutNewLine();
1412  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet), false );
1413  }
1414  else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1415  {
1416  // write plug-ins parameters as options
1417 
1418  uno::Sequence < beans::PropertyValue > aProps;
1419  aAny = xSet->getPropertyValue("PluginCommands");
1420  aAny >>= aProps;
1421 
1422  SvCommandList aCommands;
1423  aCommands.FillFromSequence( aProps );
1424  for( size_t i = 0; i < aCommands.size(); i++ )
1425  {
1426  const SvCommand& rCommand = aCommands[ i ];
1427  const OUString& rName = rCommand.GetCommand();
1428 
1429  if( SwApplet_Impl::GetOptionType( rName, false ) == SwHtmlOptType::TAG )
1430  {
1431  const OUString& rValue = rCommand.GetArgument();
1432  rWrt.Strm().WriteChar( ' ' );
1433  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1434  rWrt.Strm().WriteCharPtr( "=\"" );
1435  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
1436  }
1437  }
1438  rHTMLWrt.Strm().WriteChar( '>' );
1439  }
1440  else
1441  {
1442  // and for Floating-Frames just output another </IFRAME>
1443 
1444  rHTMLWrt.Strm().WriteChar( '>' );
1445  HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe), false );
1446  }
1447 
1448  if( !aEndTags.isEmpty() )
1449  rWrt.Strm().WriteOString( aEndTags );
1450 
1451  return rWrt;
1452 }
1453 
1455  bool bInCntnr )
1456 {
1457  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1458 
1459  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1460  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1461  SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1462 
1463  OSL_ENSURE( pOLENd, "OLE-Node expected" );
1464  if( !pOLENd )
1465  return rWrt;
1466 
1467  if (rHTMLWrt.mbSkipImages)
1468  {
1469  // If we skip images, embedded objects would be completely lost.
1470  // Instead, try to use the HTML export of the embedded object.
1471  uno::Reference<text::XTextContent> xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rHTMLWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
1472  uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
1473  uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
1474  SAL_WARN_IF(!xStorable.is(), "sw.html", "OutHTML_FrameFormatOLENodeGrf: no embedded object");
1475 
1476  // Figure out what is the filter name of the embedded object.
1477  uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
1478  OUString aFilter;
1479  if (xServiceInfo.is())
1480  {
1481  if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
1482  aFilter = "HTML (StarCalc)";
1483  else if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
1484  aFilter = "HTML (StarWriter)";
1485  }
1486 
1487  if (xStorable.is() && !aFilter.isEmpty())
1488  {
1489  try
1490  {
1491  // FIXME: exception for the simplest test document, too
1492  SvMemoryStream aStream;
1493  uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
1494  utl::MediaDescriptor aMediaDescriptor;
1495  aMediaDescriptor["FilterName"] <<= aFilter;
1496  aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter");
1497  aMediaDescriptor["OutputStream"] <<= xOutputStream;
1498  xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList());
1499  SAL_WARN_IF(aStream.GetSize()>=o3tl::make_unsigned(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString");
1500  OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize()));
1501  // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p'
1502  HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span));
1503  rWrt.Strm().WriteOString(aData);
1504  HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
1505  }
1506  catch ( uno::Exception& )
1507  {
1508  }
1509  }
1510 
1511  return rWrt;
1512  }
1513 
1514  if ( !pOLENd->GetGraphic() )
1515  {
1516  SAL_WARN("sw.html", "Unexpected missing OLE fallback graphic");
1517  return rWrt;
1518  }
1519 
1520  Graphic aGraphic( *pOLENd->GetGraphic() );
1521 
1522  SwDocShell* pDocSh = rHTMLWrt.m_pDoc->GetDocShell();
1523  bool bObjectOpened = false;
1524  OUString aRTFType = "text/rtf";
1525  if (!rHTMLWrt.m_aRTFOLEMimeType.isEmpty())
1526  {
1527  aRTFType = rHTMLWrt.m_aRTFOLEMimeType;
1528  }
1529 
1530  if (rHTMLWrt.mbXHTML && pDocSh)
1531  {
1532  // Map native data to an outer <object> element.
1533 
1534  // Calculate the file name, which is meant to be the same as the
1535  // replacement image, just with a .ole extension.
1536  OUString aFileName = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"ole");
1537 
1538  // Write the data.
1539  SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
1540  uno::Reference<embed::XEmbeddedObject> xEmbeddedObject = rOLEObj.GetOleRef();
1541  OUString aFileType;
1542  SvFileStream aOutStream(aFileName, StreamMode::WRITE);
1543  uno::Reference<io::XActiveDataStreamer> xStreamProvider;
1544  uno::Reference<embed::XEmbedPersist2> xOwnEmbedded;
1545  if (xEmbeddedObject.is())
1546  {
1547  xStreamProvider.set(xEmbeddedObject, uno::UNO_QUERY);
1548  xOwnEmbedded.set(xEmbeddedObject, uno::UNO_QUERY);
1549  }
1550  if (xStreamProvider.is())
1551  {
1552  // Real OLE2 case: OleEmbeddedObject.
1553  uno::Reference<io::XInputStream> xStream(xStreamProvider->getStream(), uno::UNO_QUERY);
1554  if (xStream.is())
1555  {
1556  std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream));
1557  if (SwReqIfReader::WrapOleInRtf(*pStream, aOutStream, *pOLENd, rFrameFormat))
1558  {
1559  // Data always wrapped in RTF.
1560  aFileType = aRTFType;
1561  }
1562  }
1563  }
1564  else if (xOwnEmbedded.is())
1565  {
1566  // Our own embedded object: OCommonEmbeddedObject.
1567  SvxMSExportOLEObjects aOLEExp(0);
1568  // Trigger the load of the OLE object if needed, otherwise we can't
1569  // export it.
1570  pOLENd->GetTwipSize();
1571  SvMemoryStream aMemory;
1572  tools::SvRef<SotStorage> pStorage = new SotStorage(aMemory);
1573  aOLEExp.ExportOLEObject(rOLEObj.GetObject(), *pStorage);
1574  pStorage->Commit();
1575  aMemory.Seek(0);
1576  if (SwReqIfReader::WrapOleInRtf(aMemory, aOutStream, *pOLENd, rFrameFormat))
1577  {
1578  // Data always wrapped in RTF.
1579  aFileType = aRTFType;
1580  }
1581  }
1582  else
1583  {
1584  // Otherwise the native data is just a grab-bag: ODummyEmbeddedObject.
1585  const OUString& aStreamName = rOLEObj.GetCurrentPersistName();
1586  uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
1587  uno::Reference<io::XStream> xInStream;
1588  try
1589  {
1590  // Even the native data may be missing.
1591  xInStream = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
1592  } catch (const uno::Exception&)
1593  {
1594  TOOLS_WARN_EXCEPTION("sw.html", "OutHTML_FrameFormatOLENodeGrf: failed to open stream element");
1595  }
1596  if (xInStream.is())
1597  {
1598  uno::Reference<io::XStream> xOutStream(new utl::OStreamWrapper(aOutStream));
1599  comphelper::OStorageHelper::CopyInputToOutput(xInStream->getInputStream(),
1600  xOutStream->getOutputStream());
1601  }
1602 
1603  uno::Reference<beans::XPropertySet> xOutStreamProps(xInStream, uno::UNO_QUERY);
1604  if (xOutStreamProps.is())
1605  xOutStreamProps->getPropertyValue("MediaType") >>= aFileType;
1606  if (!aRTFType.isEmpty())
1607  {
1608  aFileType = aRTFType;
1609  }
1610  }
1611  aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
1612 
1613  // Refer to this data.
1614  if (rHTMLWrt.m_bLFPossible)
1615  rHTMLWrt.OutNewLine();
1616  rWrt.Strm().WriteOString(OStringConcatenation("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
1617  rWrt.Strm().WriteOString(OStringConcatenation(" data=\"" + aFileName.toUtf8() + "\""));
1618  if (!aFileType.isEmpty())
1619  rWrt.Strm().WriteOString(OStringConcatenation(" type=\"" + aFileType.toUtf8() + "\""));
1620  rWrt.Strm().WriteOString(">");
1621  bObjectOpened = true;
1622  rHTMLWrt.m_bLFPossible = true;
1623  }
1624 
1625  OUString aGraphicURL;
1626  OUString aMimeType;
1627  if(!rHTMLWrt.mbEmbedImages)
1628  {
1629  const OUString* pTempFileName = rHTMLWrt.GetOrigFileName();
1630  if(pTempFileName)
1631  aGraphicURL = *pTempFileName;
1632 
1633  OUString aFilterName("JPG");
1634  XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
1635 
1636  if (bObjectOpened)
1637  {
1638  aFilterName = "PNG";
1639  nFlags = XOutFlags::NONE;
1640  aMimeType = "image/png";
1641 
1642  if (aGraphic.GetType() == GraphicType::NONE)
1643  {
1644  // The OLE Object has no replacement image, write a stub.
1645  aGraphicURL = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"png");
1646  osl::File aFile(aGraphicURL);
1647  aFile.open(osl_File_OpenFlag_Create);
1648  aFile.close();
1649  }
1650  }
1651 
1652  ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL,
1653  aFilterName,
1654  nFlags );
1655  if( nErr ) // error, don't write anything
1656  {
1657  rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1658  return rWrt;
1659  }
1660  aGraphicURL = URIHelper::SmartRel2Abs(
1661  INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
1663 
1664  }
1665  HtmlFrmOpts nFlags = bInCntnr ? HtmlFrmOpts::GenImgAllMask
1667  if (bObjectOpened)
1668  nFlags |= HtmlFrmOpts::Replacement;
1669  HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
1670  OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, aGraphicURL, aGraphic,
1671  pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1672  nFlags, "ole", nullptr, aMimeType );
1673  OutHTML_ImageEnd(aHtml, rWrt);
1674 
1675  if (bObjectOpened)
1676  // Close native data.
1677  rWrt.Strm().WriteOString(OStringConcatenation("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object
1678  ">"));
1679 
1680  return rWrt;
1681 }
1682 
1683 /* 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:243
const char *const aClassID
const HtmlFrmOpts HTML_FRMOPTS_IFRAME
Definition: htmlplug.cxx:129
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:396
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:91
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
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:88
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:101
const HtmlFrmOpts HTML_FRMOPTS_HIDDEN_EMBED
Definition: htmlplug.cxx:107
#define SO3_IFRAME_CLASSID
Writer & OutHTML_FrameFormatOLENodeGrf(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1454
#define MINFLY
Definition: swtypes.hxx:62
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:909
tools::Long m_nHeight
Definition: svxcss1.hxx:134
const OUString & GetString() const
constexpr sal_uInt16 RES_FRMATR_END(133)
void DecIndentLevel()
Definition: wrthtml.hxx:508
OUString m_aNonConvertableCharacters
Definition: wrthtml.hxx:295
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:349
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:398
bool Commit()
ErrCode m_nWarn
Definition: wrthtml.hxx:308
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1441
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
SvxCSS1LengthType m_eHeightType
Definition: svxcss1.hxx:138
bool m_bLFPossible
Definition: wrthtml.hxx:381
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:90
void SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &)
#define WARN_SWG_POOR_LOAD
Definition: swerror.h:40
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:961
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:2570
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:336
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:577
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:1233
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:59
#define TOOLS_WARN_EXCEPTION(area, stream)
The graphic frame is a replacement image of an OLE object.
rtl_TextEncoding m_eDestEnc
Definition: wrthtml.hxx:336
#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:136
const INetURLObject & GetURL() const
OUString aId
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:117
bool mbEmbedImages
Definition: wrthtml.hxx:392
#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:114
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:410
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:76
#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:111
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_ALL
Definition: htmlplug.cxx:123
#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:123
Any makeAny(Color const &value)
#define HTML_DFLT_EMBED_WIDTH
Definition: htmlplug.cxx:87
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:504
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:1490
#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:3466
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL
Definition: htmlplug.cxx:94
#define OOO_STRING_SVTOOLS_HTML_object
static sal_uInt16 GuessOLENodeFrameType(const SwNode &rNd)
Definition: htmlplug.cxx:1166
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:389
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:98
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_CNTNR
Definition: htmlplug.cxx:126
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:165
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:1192
const void * GetData()
sal_uInt16 GetUpper() const
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1584
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:1846
Base class of the Writer document model elements.
Definition: node.hxx:80
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo