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