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 
83 using namespace com::sun::star;
84 
85 #define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
86 #define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
87 
88 #define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
89 #define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
90 
91 
108 
120 
133 
137 
138 namespace
139 {
144 OUString lcl_CalculateFileName(const OUString* pOrigFileName, const Graphic& rGraphic,
145  const OUString& rExtension)
146 {
147  OUString aFileName;
148 
149  if (pOrigFileName)
150  aFileName = *pOrigFileName;
151  INetURLObject aURL(aFileName);
152  OUString aName = aURL.getBase() + "_" +
153  aURL.getExtension() + "_" +
154  OUString::number(rGraphic.GetChecksum(), 16);
155  aURL.setBase(aName);
156  aURL.setExtension(rExtension);
158 
159  return aFileName;
160 }
161 }
162 
163 void SwHTMLParser::SetFixSize( const Size& rPixSize,
164  const Size& rTwipDfltSize,
165  bool bPercentWidth, bool bPercentHeight,
166  SvxCSS1PropertyInfo const & rCSS1PropInfo,
167  SfxItemSet& rFlyItemSet )
168 {
169  // convert absolute size values into Twip
170  sal_uInt8 nPercentWidth = 0, nPercentHeight = 0;
171  Size aTwipSz( bPercentWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
172  bPercentHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
173  if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
174  {
175  aTwipSz =
177  MapMode(MapUnit::MapTwip) );
178  }
179 
180  // process width
181  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eWidthType )
182  {
183  nPercentWidth = static_cast<sal_uInt8>(rCSS1PropInfo.m_nWidth);
184  aTwipSz.setWidth( rTwipDfltSize.Width() );
185  }
186  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eWidthType )
187  {
188  aTwipSz.setWidth( rCSS1PropInfo.m_nWidth );
189  }
190  else if( bPercentWidth && rPixSize.Width() )
191  {
192  nPercentWidth = static_cast<sal_uInt8>(rPixSize.Width());
193  if( nPercentWidth > 100 )
194  nPercentWidth = 100;
195 
196  aTwipSz.setWidth( rTwipDfltSize.Width() );
197  }
198  else if( USHRT_MAX==rPixSize.Width() )
199  {
200  aTwipSz.setWidth( rTwipDfltSize.Width() );
201  }
202  if( aTwipSz.Width() < MINFLY )
203  {
204  aTwipSz.setWidth( MINFLY );
205  }
206 
207  // process height
208  if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.m_eHeightType )
209  {
210  nPercentHeight = static_cast<sal_uInt8>(rCSS1PropInfo.m_nHeight);
211  aTwipSz.setHeight( rTwipDfltSize.Height() );
212  }
213  else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.m_eHeightType )
214  {
215  aTwipSz.setHeight( rCSS1PropInfo.m_nHeight );
216  }
217  else if( bPercentHeight && rPixSize.Height() )
218  {
219  nPercentHeight = static_cast<sal_uInt8>(rPixSize.Height());
220  if( nPercentHeight > 100 )
221  nPercentHeight = 100;
222 
223  aTwipSz.setHeight( rTwipDfltSize.Height() );
224  }
225  else if( USHRT_MAX==rPixSize.Height() )
226  {
227  aTwipSz.setHeight( rTwipDfltSize.Height() );
228  }
229  if( aTwipSz.Height() < MINFLY )
230  {
231  aTwipSz.setHeight( MINFLY );
232  }
233 
234  // set size
235  SwFormatFrameSize aFrameSize( SwFrameSize::Fixed, aTwipSz.Width(), aTwipSz.Height() );
236  aFrameSize.SetWidthPercent( nPercentWidth );
237  aFrameSize.SetHeightPercent( nPercentHeight );
238  rFlyItemSet.Put( aFrameSize );
239 }
240 
241 void SwHTMLParser::SetSpace( const Size& rPixSpace,
242  SfxItemSet& rCSS1ItemSet,
243  SvxCSS1PropertyInfo& rCSS1PropInfo,
244  SfxItemSet& rFlyItemSet )
245 {
246  sal_Int32 nLeftSpace = 0, nRightSpace = 0;
247  sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
248  if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
249  {
250  Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
251  aTwipSpc =
253  MapMode(MapUnit::MapTwip) );
254  nLeftSpace = nRightSpace = aTwipSpc.Width();
255  nUpperSpace = nLowerSpace = static_cast<sal_uInt16>(aTwipSpc.Height());
256  }
257 
258  // set left/right margin
259  const SfxPoolItem *pItem;
260  if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
261  {
262  // if applicable remove the first line indent
263  const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
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( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
299  {
300  // if applicable remove the first line indent
301  const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
302  if( rCSS1PropInfo.m_bTopMargin )
303  {
304  nUpperSpace = pULItem->GetUpper();
305  rCSS1PropInfo.m_bTopMargin = false;
306  }
307  if( rCSS1PropInfo.m_bBottomMargin )
308  {
309  nLowerSpace = pULItem->GetLower();
310  rCSS1PropInfo.m_bBottomMargin = false;
311  }
312  rCSS1ItemSet.ClearItem( RES_UL_SPACE );
313  }
314  if( !(nUpperSpace || nLowerSpace) )
315  return;
316 
317  SvxULSpaceItem aULItem( RES_UL_SPACE );
318  aULItem.SetUpper( nUpperSpace );
319  aULItem.SetLower( nLowerSpace );
320  rFlyItemSet.Put( aULItem );
321  if( nUpperSpace )
322  {
323  const SwFormatVertOrient& rVertOri =
324  rFlyItemSet.Get( RES_VERT_ORIENT );
325  if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
326  {
327  SwFormatVertOrient aVertOri( rVertOri );
328  aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
329  rFlyItemSet.Put( aVertOri );
330  }
331  }
332 }
333 
334 OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
335 {
336  if (!comphelper::isFileUrl(rBase))
337  return rPath;
338 
339  sal_Int32 nIndex = rPath.indexOf('?');
340 
341  if (nIndex != -1)
342  return rPath.copy(0, nIndex);
343 
344  return rPath;
345 }
346 
348 {
349  OUString aURL, aType, aName, aAlt, aId, aStyle, aClass;
350  OUString aData;
351  Size aSize( USHRT_MAX, USHRT_MAX );
352  Size aSpace( USHRT_MAX, USHRT_MAX );
353  bool bPercentWidth = false, bPercentHeight = false, bHidden = false;
354  sal_Int16 eVertOri = text::VertOrientation::NONE;
355  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
356  SvCommandList aCmdLst;
357  const HTMLOptions& rHTMLOptions = GetOptions();
358 
359  // The options are read forwards, because the plug-ins expect them in this
360  // order. Still only the first value of an option may be regarded.
361  for (const auto & rOption : rHTMLOptions)
362  {
363  switch( rOption.GetToken() )
364  {
365  case HtmlOptionId::ID:
366  aId = rOption.GetString();
367  break;
368  case HtmlOptionId::STYLE:
369  aStyle = rOption.GetString();
370  break;
371  case HtmlOptionId::CLASS:
372  aClass = rOption.GetString();
373  break;
374  case HtmlOptionId::NAME:
375  aName = rOption.GetString();
376  break;
377  case HtmlOptionId::SRC:
378  if( aURL.isEmpty() )
379  aURL = rOption.GetString();
380  break;
381  case HtmlOptionId::ALT:
382  aAlt = rOption.GetString();
383  break;
384  case HtmlOptionId::TYPE:
385  if( aType.isEmpty() )
386  aType = rOption.GetString();
387  break;
388  case HtmlOptionId::ALIGN:
389  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
390  {
391  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
392  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
393  }
394  break;
395  case HtmlOptionId::WIDTH:
396  if( USHRT_MAX==aSize.Width() )
397  {
398  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
399  aSize.setWidth( static_cast<long>(rOption.GetNumber()) );
400  }
401  break;
402  case HtmlOptionId::HEIGHT:
403  if( USHRT_MAX==aSize.Height() )
404  {
405  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
406  aSize.setHeight( static_cast<long>(rOption.GetNumber()) );
407  }
408  break;
409  case HtmlOptionId::HSPACE:
410  if( USHRT_MAX==aSpace.Width() )
411  aSpace.setWidth( static_cast<long>(rOption.GetNumber()) );
412  break;
413  case HtmlOptionId::VSPACE:
414  if( USHRT_MAX==aSpace.Height() )
415  aSpace.setHeight( static_cast<long>(rOption.GetNumber()) );
416  break;
417  case HtmlOptionId::DATA:
418  if (m_bXHTML && aURL.isEmpty())
419  aData = rOption.GetString();
420  break;
421  case HtmlOptionId::UNKNOWN:
422  if (rOption.GetTokenString().equalsIgnoreAsciiCase(
424  {
425  bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
426  "FALSE");
427  }
428  break;
429  default: break;
430  }
431 
432  // All parameters are passed to the plug-in.
433  aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
434  }
435 
436  if (aType == "image/png" && m_aEmbeds.empty())
437  // Toplevel <object> for PNG -> that's an image, not an OLE object.
438  return false;
439 
440  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
441  SvxCSS1PropertyInfo aPropInfo;
442  if( HasStyleOptions( aStyle, aId, aClass ) )
443  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
444 
445  // Convert the default values (except height/width, which is done by SetFrameSize())
446  if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
447  eVertOri = text::VertOrientation::TOP;
448  if( USHRT_MAX==aSpace.Width() )
449  aSpace.setWidth( 0 );
450  if( USHRT_MAX==aSpace.Height() )
451  aSpace.setHeight( 0 );
452  if( bHidden )
453  {
454  // Size (0,0) will be changed to (MINFLY, MINFLY) in SetFrameSize()
455  aSize.setWidth( 0 ); aSize.setHeight( 0 );
456  aSpace.setWidth( 0 ); aSpace.setHeight( 0 );
457  bPercentWidth = bPercentHeight = false;
458  }
459 
460  // prepare the URL
461  INetURLObject aURLObj;
462  bool bHasURL = !aURL.isEmpty() &&
463  aURLObj.SetURL(
465  INetURLObject(m_sBaseURL), aURL,
467  bool bHasData = !aData.isEmpty();
468 
469  try
470  {
471  // Strip query and everything after that for file:// URLs, browsers do
472  // the same.
473  aURLObj.SetURL(rtl::Uri::convertRelToAbs(
474  m_sBaseURL, SwHTMLParser::StripQueryFromPath(m_sBaseURL, aData)));
475  }
476  catch (const rtl::MalformedUriException& /*rException*/)
477  {
478  bHasData = false;
479  }
480 
481  // do not insert plugin if it has neither URL nor type
482  bool bHasType = !aType.isEmpty();
483  if( !bHasURL && !bHasType && !bHasData )
484  return true;
485 
486  if (!m_aEmbeds.empty())
487  {
488  // Nested XHTML <object> element: points to replacement graphic.
489  SwOLENode* pOLENode = m_aEmbeds.top();
490  svt::EmbeddedObjectRef& rObj = pOLENode->GetOLEObj().GetObject();
491  Graphic aGraphic;
492  if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
493  return true;
494 
495  rObj.SetGraphic(aGraphic, aType);
496 
497  // Set the size of the OLE frame to the size of the graphic.
499  if (aSize.getHeight() == USHRT_MAX || aSize.getWidth() == USHRT_MAX)
500  {
501  Size aPixelSize = aGraphic.GetSizePixel(pDevice);
502  if (aSize.getWidth() == USHRT_MAX)
503  aSize.setWidth(aPixelSize.getWidth());
504  if (aSize.getHeight() == USHRT_MAX)
505  aSize.setHeight(aPixelSize.getHeight());
506  }
507 
508  SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
509  if (!pFormat)
510  return true;
511 
512  SwAttrSet aAttrSet(pFormat->GetAttrSet());
513  aAttrSet.ClearItem(RES_CNTNT);
514  Size aTwipSize(pDevice->PixelToLogic(aSize, MapMode(MapUnit::MapTwip)));
515  SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, aTwipSize.Width(), aTwipSize.Height());
516  aAttrSet.Put(aFrameSize);
517  pOLENode->GetDoc()->SetFlyFrameAttr(*pFormat, aAttrSet);
518  return true;
519  }
520 
521  // create the plug-in
523  OUString aObjName;
524  uno::Reference < embed::XEmbeddedObject > xObj;
525  if (!bHasData)
526  {
527  xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
529  {
530  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
531  if ( xSet.is() )
532  {
533  if( bHasURL )
534  xSet->setPropertyValue("PluginURL", uno::makeAny( aURL ) );
535  if( bHasType )
536  xSet->setPropertyValue("PluginMimeType", uno::makeAny( aType ) );
537 
538  uno::Sequence < beans::PropertyValue > aProps;
539  aCmdLst.FillSequence( aProps );
540  xSet->setPropertyValue("PluginCommands", uno::makeAny( aProps ) );
541 
542  }
543  }
544  }
545  else if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
546  {
547  // Has non-empty data attribute in XHTML: map that to an OLE object.
548  uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
549  aCnt.SwitchPersistence(xStorage);
550  aObjName = aCnt.CreateUniqueObjectName();
551  {
553  StreamMode::READ);
554  uno::Reference<io::XInputStream> xInStream;
555  SvMemoryStream aMemoryStream;
556 
557  // Allow any MIME type that starts with magic, unless a set of allowed types are
558  // specified.
559  auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
560  if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
561  {
562  OString aMagic("{\\object");
563  OString aHeader(read_uInt8s_ToOString(aFileStream, aMagic.getLength()));
564  aFileStream.Seek(0);
565  if (aHeader == aMagic)
566  {
567  // OLE2 wrapped in RTF: either own format or real OLE2 embedding.
568  bool bOwnFormat = false;
569  if (SwReqIfReader::ExtractOleFromRtf(aFileStream, aMemoryStream, bOwnFormat))
570  {
571  xInStream.set(new utl::OStreamWrapper(aMemoryStream));
572  }
573 
574  if (bOwnFormat)
575  {
576  uno::Sequence<beans::PropertyValue> aMedium = comphelper::InitPropertySequence(
577  { { "InputStream", uno::makeAny(xInStream) },
578  { "URL", uno::makeAny(OUString("private:stream")) },
579  { "DocumentBaseURL", uno::makeAny(m_sBaseURL) } });
580  xObj = aCnt.InsertEmbeddedObject(aMedium, aName, &m_sBaseURL);
581  }
582  else
583  {
584  // The type is now an OLE2 container, not the original XHTML type.
585  aType = "application/vnd.sun.star.oleobject";
586  }
587  }
588  }
589 
590  if (!xInStream.is())
591  // Non-RTF case.
592  xInStream.set(new utl::OStreamWrapper(aFileStream));
593 
594  if (!xObj.is())
595  {
596  uno::Reference<io::XStream> xOutStream
597  = xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
598  if (aFileStream.IsOpen())
600  xOutStream->getOutputStream());
601 
602  if (!aType.isEmpty())
603  {
604  // Set media type of the native data.
605  uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
606  if (xOutStreamProps.is())
607  xOutStreamProps->setPropertyValue("MediaType", uno::makeAny(aType));
608  }
609  }
610  xObj = aCnt.GetEmbeddedObject(aObjName);
611  }
612  }
613 
614  SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
616  if( !IsNewDoc() )
617  Reader::ResetFrameFormatAttrs( aFrameSet );
618 
619  // set the anchor
620  if( !bHidden )
621  {
622  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
623  }
624  else
625  {
626  SwFormatAnchor aAnchor( RndStdIds::FLY_AT_PARA );
627  aAnchor.SetAnchor( m_pPam->GetPoint() );
628  aFrameSet.Put( aAnchor );
629  aFrameSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
630  aFrameSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
631  aFrameSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
632  }
633 
634  // and the size of the frame
636  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
637  SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
638 
639  // and insert into the document
640  uno::Reference<lang::XInitialization> xObjInitialization(xObj, uno::UNO_QUERY);
641  if (xObjInitialization.is())
642  {
643  // Request that the native data of the embedded object is not modified
644  // during parsing.
645  uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
646  true) };
647  uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
648  xObjInitialization->initialize(aArguments);
649  }
650  SwFrameFormat* pFlyFormat =
651  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
652  ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
653  &aFrameSet);
654  if (xObjInitialization.is())
655  {
656  uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
657  false) };
658  uno::Sequence<uno::Any> aArguments{ uno::makeAny(aValues) };
659  xObjInitialization->initialize(aArguments);
660  }
661 
662  // set name at FrameFormat
663  if( !aName.isEmpty() )
664  pFlyFormat->SetName( aName );
665 
666  // set the alternative text
667  SwNoTextNode *pNoTextNd =
668  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
669  ->GetIndex()+1 ]->GetNoTextNode();
670  pNoTextNd->SetTitle( aAlt );
671 
672  // if applicable create frames and register auto-bound frames
673  if( !bHidden )
674  {
675  // HIDDEN plug-ins should stay paragraph-bound. Since RegisterFlyFrame()
676  // will change paragraph-bound frames with wrap-through into a
677  // character-bound frame, here we must create the frames by hand.
678  RegisterFlyFrame( pFlyFormat );
679  }
680 
681  if (!bHasData)
682  return true;
683 
684  SwOLENode* pOLENode = pNoTextNd->GetOLENode();
685  if (!pOLENode)
686  return true;
687 
688  m_aEmbeds.push(pOLENode);
689 
690  return true;
691 }
692 
693 #if HAVE_FEATURE_JAVA
694 void SwHTMLParser::NewObject()
695 {
696  OUString aClassID;
697  OUString aStandBy, aId, aStyle, aClass;
698  Size aSize( USHRT_MAX, USHRT_MAX );
699  Size aSpace( 0, 0 );
700  sal_Int16 eVertOri = text::VertOrientation::TOP;
701  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
702 
703  bool bPercentWidth = false, bPercentHeight = false,
704  bDeclare = false;
705  // create a new Command list
706  m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
707 
708  const HTMLOptions& rHTMLOptions = GetOptions();
709  for (size_t i = rHTMLOptions.size(); i; )
710  {
711  const HTMLOption& rOption = rHTMLOptions[--i];
712  switch( rOption.GetToken() )
713  {
714  case HtmlOptionId::ID:
715  aId = rOption.GetString();
716  break;
717  case HtmlOptionId::STYLE:
718  aStyle = rOption.GetString();
719  break;
720  case HtmlOptionId::CLASS:
721  aClass = rOption.GetString();
722  break;
723  case HtmlOptionId::DECLARE:
724  bDeclare = true;
725  break;
726  case HtmlOptionId::CLASSID:
727  aClassID = rOption.GetString();
728  break;
729  case HtmlOptionId::CODEBASE:
730  break;
731  case HtmlOptionId::DATA:
732  break;
733  case HtmlOptionId::TYPE:
734  break;
735  case HtmlOptionId::CODETYPE:
736  break;
737  case HtmlOptionId::ARCHIVE:
738  case HtmlOptionId::UNKNOWN:
739  break;
740  case HtmlOptionId::STANDBY:
741  aStandBy = rOption.GetString();
742  break;
743  case HtmlOptionId::WIDTH:
744  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
745  aSize.setWidth( static_cast<long>(rOption.GetNumber()) );
746  break;
747  case HtmlOptionId::HEIGHT:
748  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
749  aSize.setHeight( static_cast<long>(rOption.GetNumber()) );
750  break;
751  case HtmlOptionId::ALIGN:
752  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
753  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
754  break;
755  case HtmlOptionId::USEMAP:
756  break;
757  case HtmlOptionId::NAME:
758  break;
759  case HtmlOptionId::HSPACE:
760  aSpace.setWidth( static_cast<long>(rOption.GetNumber()) );
761  break;
762  case HtmlOptionId::VSPACE:
763  aSpace.setHeight( static_cast<long>(rOption.GetNumber()) );
764  break;
765  case HtmlOptionId::BORDER:
766  break;
767 
768  case HtmlOptionId::SDONCLICK:
769  case HtmlOptionId::ONCLICK:
770  case HtmlOptionId::SDONMOUSEOVER:
771  case HtmlOptionId::ONMOUSEOVER:
772  case HtmlOptionId::SDONMOUSEOUT:
773  case HtmlOptionId::ONMOUSEOUT:
774  break;
775  default: break;
776  }
777  // All parameters are passed to the applet.
778  m_pAppletImpl->AppendParam( rOption.GetTokenString(),
779  rOption.GetString() );
780 
781  }
782 
783  // Objects that are declared only are not evaluated. Moreover, only
784  // Java applets are supported.
785  bool bIsApplet = false;
786 
787  if( !bDeclare && aClassID.getLength() == 42 &&
788  aClassID.startsWith("clsid:") )
789  {
790  aClassID = aClassID.copy(6);
791  SvGlobalName aCID;
792  if( aCID.MakeId( aClassID ) )
793  {
794  SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
795  0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
796 
797  bIsApplet = aJavaCID == aCID;
798  }
799  }
800 
801  if( !bIsApplet )
802  {
803  m_pAppletImpl.reset();
804  return;
805  }
806 
807  m_pAppletImpl->SetAltText( aStandBy );
808 
809  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
810  SvxCSS1PropertyInfo aPropInfo;
811  if( HasStyleOptions( aStyle, aId, aClass ) )
812  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
813 
814  SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
815  if( !IsNewDoc() )
816  Reader::ResetFrameFormatAttrs( rFrameSet );
817 
818  // set the anchor and the adjustment
819  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
820 
821  // and still the size of the frame
823  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
824  SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
825 }
826 #endif
827 
829 {
830 #if HAVE_FEATURE_JAVA
831  if( !m_pAppletImpl )
832  return;
833  if( !m_pAppletImpl->CreateApplet( m_sBaseURL ) )
834  return;
835 
836  m_pAppletImpl->FinishApplet();
837 
838  // and insert into the document
839  SwFrameFormat* pFlyFormat =
840  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
841  ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
842  &m_pAppletImpl->GetItemSet() );
843 
844  // set the alternative name
845  SwNoTextNode *pNoTextNd =
846  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
847  ->GetIndex()+1 ]->GetNoTextNode();
848  pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
849 
850  // if applicable create frames and register auto-bound frames
851  RegisterFlyFrame( pFlyFormat );
852 
853  m_pAppletImpl.reset();
854 #else
855  (void) this; // Silence loplugin:staticmethods
856 #endif
857 }
858 
859 #if HAVE_FEATURE_JAVA
860 void SwHTMLParser::InsertApplet()
861 {
862  OUString aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
863  Size aSize( USHRT_MAX, USHRT_MAX );
864  Size aSpace( 0, 0 );
865  bool bPercentWidth = false, bPercentHeight = false, bMayScript = false;
866  sal_Int16 eVertOri = text::VertOrientation::TOP;
867  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
868 
869  // create a new Command list
870  m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
871 
872  const HTMLOptions& rHTMLOptions = GetOptions();
873  for (size_t i = rHTMLOptions.size(); i; )
874  {
875  const HTMLOption& rOption = rHTMLOptions[--i];
876  switch( rOption.GetToken() )
877  {
878  case HtmlOptionId::ID:
879  aId = rOption.GetString();
880  break;
881  case HtmlOptionId::STYLE:
882  aStyle = rOption.GetString();
883  break;
884  case HtmlOptionId::CLASS:
885  aClass = rOption.GetString();
886  break;
887  case HtmlOptionId::CODEBASE:
888  aCodeBase = rOption.GetString();
889  break;
890  case HtmlOptionId::CODE:
891  aCode = rOption.GetString();
892  break;
893  case HtmlOptionId::NAME:
894  aName = rOption.GetString();
895  break;
896  case HtmlOptionId::ALT:
897  aAlt = rOption.GetString();
898  break;
899  case HtmlOptionId::ALIGN:
900  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
901  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
902  break;
903  case HtmlOptionId::WIDTH:
904  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
905  aSize.setWidth( static_cast<long>(rOption.GetNumber()) );
906  break;
907  case HtmlOptionId::HEIGHT:
908  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
909  aSize.setHeight( static_cast<long>(rOption.GetNumber()) );
910  break;
911  case HtmlOptionId::HSPACE:
912  aSpace.setWidth( static_cast<long>(rOption.GetNumber()) );
913  break;
914  case HtmlOptionId::VSPACE:
915  aSpace.setHeight( static_cast<long>(rOption.GetNumber()) );
916  break;
917  case HtmlOptionId::MAYSCRIPT:
918  bMayScript = true;
919  break;
920  default: break;
921  }
922 
923  // All parameters are passed to the applet.
924  m_pAppletImpl->AppendParam( rOption.GetTokenString(),
925  rOption.GetString() );
926  }
927 
928  if( aCode.isEmpty() )
929  {
930  m_pAppletImpl.reset();
931  return;
932  }
933 
934  if ( !aCodeBase.isEmpty() )
935  aCodeBase = INetURLObject::GetAbsURL( m_sBaseURL, aCodeBase );
936  m_pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, m_sBaseURL );//, aAlt );
937  m_pAppletImpl->SetAltText( aAlt );
938 
939  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
940  SvxCSS1PropertyInfo aPropInfo;
941  if( HasStyleOptions( aStyle, aId, aClass ) )
942  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
943 
944  SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
945  if( !IsNewDoc() )
946  Reader::ResetFrameFormatAttrs( rFrameSet );
947 
948  // set the anchor and the adjustment
949  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
950 
951  // and still the size or the frame
953  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
954  SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
955 }
956 #endif
957 
959 {
960 #if HAVE_FEATURE_JAVA
961  if( !m_pAppletImpl )
962  return;
963 
964  m_pAppletImpl->FinishApplet();
965 
966  // and insert into the document
967  SwFrameFormat* pFlyFormat =
968  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
969  ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
970  &m_pAppletImpl->GetItemSet());
971 
972  // set the alternative name
973  SwNoTextNode *pNoTextNd =
974  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
975  ->GetIndex()+1 ]->GetNoTextNode();
976  pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
977 
978  // if applicable create frames and register auto-bound frames
979  RegisterFlyFrame( pFlyFormat );
980 
981  m_pAppletImpl.reset();
982 #else
983  (void) this;
984 #endif
985 }
986 
988 {
989 #if HAVE_FEATURE_JAVA
990  if( !m_pAppletImpl )
991  return;
992 
993  OUString aName, aValue;
994 
995  const HTMLOptions& rHTMLOptions = GetOptions();
996  for (size_t i = rHTMLOptions.size(); i; )
997  {
998  const HTMLOption& rOption = rHTMLOptions[--i];
999  switch( rOption.GetToken() )
1000  {
1001  case HtmlOptionId::NAME:
1002  aName = rOption.GetString();
1003  break;
1004  case HtmlOptionId::VALUE:
1005  aValue = rOption.GetString();
1006  break;
1007  default: break;
1008  }
1009  }
1010 
1011  if( aName.isEmpty() )
1012  return;
1013 
1014  m_pAppletImpl->AppendParam( aName, aValue );
1015 #else
1016  (void) this;
1017 #endif
1018 }
1019 
1021 {
1022  OUString aAlt, aId, aStyle, aClass;
1023  Size aSize( USHRT_MAX, USHRT_MAX );
1024  Size aSpace( 0, 0 );
1025  bool bPercentWidth = false, bPercentHeight = false;
1026  sal_Int16 eVertOri = text::VertOrientation::TOP;
1027  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1028 
1029  const HTMLOptions& rHTMLOptions = GetOptions();
1030 
1031  // First fetch the options of the Writer-Frame-Format
1032  for (const auto & rOption : rHTMLOptions)
1033  {
1034  switch( rOption.GetToken() )
1035  {
1036  case HtmlOptionId::ID:
1037  aId = rOption.GetString();
1038  break;
1039  case HtmlOptionId::STYLE:
1040  aStyle = rOption.GetString();
1041  break;
1042  case HtmlOptionId::CLASS:
1043  aClass = rOption.GetString();
1044  break;
1045  case HtmlOptionId::ALT:
1046  aAlt = rOption.GetString();
1047  break;
1048  case HtmlOptionId::ALIGN:
1049  eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1050  eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1051  break;
1052  case HtmlOptionId::WIDTH:
1053  bPercentWidth = (rOption.GetString().indexOf('%') != -1);
1054  aSize.setWidth( static_cast<long>(rOption.GetNumber()) );
1055  break;
1056  case HtmlOptionId::HEIGHT:
1057  bPercentHeight = (rOption.GetString().indexOf('%') != -1);
1058  aSize.setHeight( static_cast<long>(rOption.GetNumber()) );
1059  break;
1060  case HtmlOptionId::HSPACE:
1061  aSpace.setWidth( static_cast<long>(rOption.GetNumber()) );
1062  break;
1063  case HtmlOptionId::VSPACE:
1064  aSpace.setHeight( static_cast<long>(rOption.GetNumber()) );
1065  break;
1066  default: break;
1067  }
1068  }
1069 
1070  // and now the ones for the SfxFrame
1071  SfxFrameDescriptor aFrameDesc;
1072 
1073  SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, rHTMLOptions, m_sBaseURL );
1074 
1075  // create a floating frame
1077  OUString aObjName;
1078  uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
1079 
1080  try
1081  {
1082  // TODO/MBA: testing
1084  {
1085  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1086  if ( xSet.is() )
1087  {
1088  const OUString& aName = aFrameDesc.GetName();
1089  ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
1090  bool bHasBorder = aFrameDesc.HasFrameBorder();
1091  Size aMargin = aFrameDesc.GetMargin();
1092 
1093  xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
1094  xSet->setPropertyValue("FrameName", uno::makeAny( aName ) );
1095 
1096  if ( eScroll == ScrollingMode::Auto )
1097  xSet->setPropertyValue("FrameIsAutoScroll",
1098  uno::makeAny( true ) );
1099  else
1100  xSet->setPropertyValue("FrameIsScrollingMode",
1101  uno::makeAny( eScroll == ScrollingMode::Yes ) );
1102 
1103  xSet->setPropertyValue("FrameIsBorder",
1104  uno::makeAny( bHasBorder ) );
1105 
1106  xSet->setPropertyValue("FrameMarginWidth",
1107  uno::makeAny( sal_Int32( aMargin.Width() ) ) );
1108 
1109  xSet->setPropertyValue("FrameMarginHeight",
1110  uno::makeAny( sal_Int32( aMargin.Height() ) ) );
1111  }
1112  }
1113  }
1114  catch ( uno::Exception& )
1115  {
1116  }
1117 
1118  SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1119  SvxCSS1PropertyInfo aPropInfo;
1120  if( HasStyleOptions( aStyle, aId, aClass ) )
1121  ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
1122 
1123  // fetch the ItemSet
1124  SfxItemSet aFrameSet( m_xDoc->GetAttrPool(),
1126  if( !IsNewDoc() )
1127  Reader::ResetFrameFormatAttrs( aFrameSet );
1128 
1129  // set the anchor and the adjustment
1130  SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
1131 
1132  // and still the size of the frame
1134  SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
1135  SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
1136 
1137  // and insert into the document
1138  SwFrameFormat* pFlyFormat =
1139  m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
1140  ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
1141  &aFrameSet);
1142 
1143  // set the alternative name
1144  SwNoTextNode *pNoTextNd =
1145  m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
1146  ->GetIndex()+1 ]->GetNoTextNode();
1147  pNoTextNd->SetTitle( aAlt );
1148 
1149  // if applicable create frames and register auto-bound frames
1150  RegisterFlyFrame( pFlyFormat );
1151 
1152  m_bInFloatingFrame = true;
1153 }
1154 
1156 {
1157  SwOLEObj& rObj = const_cast<SwOLENode*>(rNode.GetOLENode())->GetOLEObj();
1158 
1160 
1161  uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
1162  SvGlobalName aClass( xClass->getClassID() );
1163  if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1164  {
1165  eType = HTML_FRMTYPE_PLUGIN;
1166  }
1167  else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1168  {
1169  eType = HTML_FRMTYPE_IFRAME;
1170  }
1171 #if HAVE_FEATURE_JAVA
1172  else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1173  {
1174  eType = HTML_FRMTYPE_APPLET;
1175  }
1176 #endif
1177 
1178  return static_cast< sal_uInt16 >(eType);
1179 }
1180 
1182  bool bInCntnr )
1183 {
1184  SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1185 
1186  const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1187  sal_uLong nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1188  SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1189 
1190  OSL_ENSURE( pOLENd, "OLE-Node expected" );
1191  if( !pOLENd )
1192  return rWrt;
1193 
1194  SwOLEObj &rObj = pOLENd->GetOLEObj();
1195 
1196  uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1198  return rWrt;
1199 
1200  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1201  bool bHiddenEmbed = false;
1202 
1203  if( !xSet.is() )
1204  {
1205  OSL_FAIL("Unknown Object" );
1206  return rWrt;
1207  }
1208 
1209  HtmlFrmOpts nFrameOpts;
1210 
1211  // if possible output a line break before the "object"
1212  if( rHTMLWrt.m_bLFPossible )
1213  rHTMLWrt.OutNewLine( true );
1214 
1215  if( !rFrameFormat.GetName().isEmpty() )
1216  rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
1217  "ole" );
1218  uno::Any aAny;
1219  SvGlobalName aGlobName( xObj->getClassID() );
1220  OStringBuffer sOut;
1221  sOut.append('<');
1222  if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1223  {
1224  // first the plug-in specifics
1225  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
1226 
1227  OUString aStr;
1228  OUString aURL;
1229  aAny = xSet->getPropertyValue("PluginURL");
1230  if( (aAny >>= aStr) && !aStr.isEmpty() )
1231  {
1233  aStr);
1234  }
1235 
1236  if( !aURL.isEmpty() )
1237  {
1238  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src)
1239  .append("=\"");
1240  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1241  HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1242  sOut.append('\"');
1243  }
1244 
1245  OUString aType;
1246  aAny = xSet->getPropertyValue("PluginMimeType");
1247  if( (aAny >>= aType) && !aType.isEmpty() )
1248  {
1249  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_type)
1250  .append("=\"");
1251  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1252  HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1253  sOut.append('\"');
1254  }
1255 
1256  if ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) &&
1257  css::text::WrapTextMode_THROUGH == rFrameFormat.GetSurround().GetSurround() )
1258  {
1259  // A HIDDEN plug-in
1260  sOut.append(' ').append(OOO_STRING_SW_HTML_O_Hidden);
1261  nFrameOpts = HTML_FRMOPTS_HIDDEN_EMBED;
1262  bHiddenEmbed = true;
1263  }
1264  else
1265  {
1266  nFrameOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
1268  }
1269  }
1270  else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1271  {
1272  // or the applet specifics
1273 
1274  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
1275 
1276  // CODEBASE
1277  OUString aCd;
1278  aAny = xSet->getPropertyValue("AppletCodeBase");
1279  if( (aAny >>= aCd) && !aCd.isEmpty() )
1280  {
1281  OUString sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
1282  if( !sCodeBase.isEmpty() )
1283  {
1284  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_codebase)
1285  .append("=\"");
1286  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1287  HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1288  sOut.append('\"');
1289  }
1290  }
1291 
1292  // CODE
1293  OUString aClass;
1294  aAny = xSet->getPropertyValue("AppletCode");
1295  aAny >>= aClass;
1296  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_code)
1297  .append("=\"");
1298  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1299  HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1300  sOut.append('\"');
1301 
1302  // NAME
1303  OUString aAppletName;
1304  aAny = xSet->getPropertyValue("AppletName");
1305  aAny >>= aAppletName;
1306  if( !aAppletName.isEmpty() )
1307  {
1308  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
1309  .append("=\"");
1310  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1311  HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1312  sOut.append('\"');
1313  }
1314 
1315  bool bScript = false;
1316  aAny = xSet->getPropertyValue("AppletIsScript");
1317  aAny >>= bScript;
1318  if( bScript )
1319  sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_mayscript);
1320 
1321  nFrameOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
1323  }
1324  else
1325  {
1326  // or the Floating-Frame specifics
1327 
1328  sOut.append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
1329  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1330 
1332  xSet,
1333  rHTMLWrt.m_eDestEnc,
1334  &rHTMLWrt.m_aNonConvertableCharacters );
1335 
1336  nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
1338  }
1339 
1340  rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
1341 
1342  // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
1343  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1344  nFrameOpts |= HTML_FRMOPTS_OLE_CSS1;
1345  OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
1346  if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1347  rHTMLWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
1348 
1349  if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1350  {
1351  // output the parameters of applets as separate tags
1352  // and write a </APPLET>
1353 
1354  uno::Sequence < beans::PropertyValue > aProps;
1355  aAny = xSet->getPropertyValue("AppletCommands");
1356  aAny >>= aProps;
1357 
1358  SvCommandList aCommands;
1359  aCommands.FillFromSequence( aProps );
1360  std::vector<sal_uLong> aParams;
1361  size_t i = aCommands.size();
1362  while( i > 0 )
1363  {
1364  const SvCommand& rCommand = aCommands[ --i ];
1365  const OUString& rName = rCommand.GetCommand();
1367  if( SwHtmlOptType::TAG == nType )
1368  {
1369  const OUString& rValue = rCommand.GetArgument();
1370  rWrt.Strm().WriteChar( ' ' );
1371  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1372  rWrt.Strm().WriteCharPtr( "=\"" );
1373  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteChar( '\"' );
1374  }
1375  else if( SwHtmlOptType::PARAM == nType )
1376  {
1377  aParams.push_back( i );
1378  }
1379  }
1380 
1381  rHTMLWrt.Strm().WriteChar( '>' );
1382 
1383  rHTMLWrt.IncIndentLevel(); // indent the applet content
1384 
1385  size_t ii = aParams.size();
1386  while( ii > 0 )
1387  {
1388  const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1389  const OUString& rName = rCommand.GetCommand();
1390  const OUString& rValue = rCommand.GetArgument();
1391  rHTMLWrt.OutNewLine();
1392  OStringBuffer sBuf;
1393  sBuf.append('<').append(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param)
1394  .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
1395  .append("=\"");
1396  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1397  HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1398  sBuf.append("\" ").append(OOO_STRING_SVTOOLS_HTML_O_value)
1399  .append("=\"");
1400  rWrt.Strm().WriteOString( sBuf.makeStringAndClear() );
1401  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
1402  }
1403 
1404  rHTMLWrt.DecIndentLevel(); // indent the applet content
1405  if( aCommands.size() )
1406  rHTMLWrt.OutNewLine();
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, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
1429  rWrt.Strm().WriteCharPtr( "=\"" );
1430  HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters ).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( '>' );
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  sal_uLong 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'
1498  rWrt.Strm().WriteOString(aData);
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, "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))
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))
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("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object);
1612  rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\"");
1613  if (!aFileType.isEmpty())
1614  rWrt.Strm().WriteOString(" 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, "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  OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic,
1665  pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1666  nFlags, "ole", nullptr, aMimeType );
1667 
1668  if (bObjectOpened)
1669  // Close native data.
1671  ">");
1672 
1673  return rWrt;
1674 }
1675 
1676 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
#define OOO_STRING_SVTOOLS_HTML_O_src
long Width() const
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:241
const char *const aClassID
void OutImplicitMark(const OUString &rMark, const char *pMarkType)
Definition: wrthtml.cxx:1222
const HtmlFrmOpts HTML_FRMOPTS_IFRAME
Definition: htmlplug.cxx:127
URL aURL
const OUString & GetBaseURL() const
Definition: shellio.hxx:439
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
bool mbXHTML
If XHTML markup should be written instead of HTML.
Definition: wrthtml.hxx:394
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
#define HTML_DFLT_APPLET_HEIGHT
Definition: htmlplug.cxx:89
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
const char aData[]
Definition: ww8scan.hxx:47
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
void InsertParam()
Definition: htmlplug.cxx:987
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
long Height() const
BitmapChecksum GetChecksum() const
#define HTML_DFLT_EMBED_HEIGHT
Definition: htmlplug.cxx:86
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool WrapOleInRtf(SvStream &rOle2, SvStream &rRtf, SwOLENode &rOLENode)
Wraps an OLE2 container binary in an RTF fragment.
const HtmlFrmOpts HTML_FRMOPTS_EMBED
Definition: htmlplug.cxx:99
const HtmlFrmOpts HTML_FRMOPTS_HIDDEN_EMBED
Definition: htmlplug.cxx:105
#define SO3_IFRAME_CLASSID
Writer & OutHTML_FrameFormatOLENodeGrf(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1449
#define MINFLY
Definition: swtypes.hxx:65
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_uIntPtr sal_uLong
size_t size() const
void SetTitle(const OUString &rTitle)
Definition: ndnotxt.cxx:244
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:913
const OUString & GetString() const
void DecIndentLevel()
Definition: wrthtml.hxx:500
OUString m_aNonConvertableCharacters
Definition: wrthtml.hxx:293
#define OOO_STRING_SVTOOLS_HTML_iframe
sal_uInt64 Seek(sal_uInt64 nPos)
bool InsertEmbed()
Definition: htmlplug.cxx:347
OUString aId
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
SvStream & WriteOString(const OString &rStr)
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
SvStream & WriteCharPtr(const char *pBuf)
bool Commit()
ErrCode m_nWarn
Definition: wrthtml.hxx:306
static OutputDevice * GetDefaultDevice()
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1432
css::uno::Any const & rValue
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
SvxCSS1LengthType m_eHeightType
Definition: svxcss1.hxx:138
bool m_bLFPossible
Definition: wrthtml.hxx:379
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
Definition: shellio.cxx:612
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, const OString &rStr, bool bOn=true)
void SetLeft(const long nL, const sal_uInt16 nProp=100)
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
bool setExtension(OUString const &rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
#define HTML_DFLT_APPLET_WIDTH
Definition: htmlplug.cxx:88
void SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &)
#define WARN_SWG_POOR_LOAD
Definition: swerror.h:40
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:965
const OUString & GetName() const
Definition: format.hxx:111
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:2493
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:334
bool IsHTMLMode(sal_uInt32 nMode) const
Definition: wrthtml.hxx:569
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
void EndApplet()
Definition: htmlplug.cxx:958
DocumentType eType
void SetRight(const long nR, const sal_uInt16 nProp=100)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:57
#define TOOLS_WARN_EXCEPTION(area, stream)
The graphic frame is a replacement image of an OLE object.
rtl_TextEncoding m_eDestEnc
Definition: wrthtml.hxx:334
#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
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void FillFromSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
void InsertFloatingFrame()
Definition: htmlplug.cxx:1020
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
const HtmlFrmOpts HTML_FRMOPTS_OLE_CSS1
Definition: htmlplug.cxx:134
const INetURLObject & GetURL() const
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
const Graphic * GetGraphic()
Definition: ndole.cxx:242
sal_uInt64 GetSize()
FlyAnchors.
Definition: fmtanchr.hxx:34
SwDoc * GetDoc()
Definition: node.hxx:702
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
#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:693
const HtmlFrmOpts HTML_FRMOPTS_APPLET
Definition: htmlplug.cxx:115
bool mbEmbedImages
Definition: wrthtml.hxx:390
#define SO3_APPLET_CLASSID
virtual Size GetTwipSize() const override
Definition: ndole.cxx:420
Writer & OutHTML_Image(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)
SwHTMLFrameType
Definition: htmlfly.hxx:32
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:112
HTMLOptionEnum< sal_Int16 > const aHTMLImgVAlignTable[]
Definition: htmlgrin.cxx:82
sal_uInt32 GetNumber() const
bool setBase(OUString const &rTheBase, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool HasFrameBorder() const
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
Point PixelToLogic(const Point &rDevicePt) const
OUString m_aRTFOLEMimeType
Definition: wrthtml.hxx:408
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:74
#define OOO_STRING_SVTOOLS_HTML_O_codebase
const Size & GetMargin() const
void EndObject()
Definition: htmlplug.cxx:828
constexpr sal_uInt16 RES_FRMATR_END(131)
const HtmlFrmOpts HTML_FRMOPTS_APPLET_ALL
Definition: htmlplug.cxx:109
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_ALL
Definition: htmlplug.cxx:121
#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:121
Any makeAny(Color const &value)
#define HTML_DFLT_EMBED_WIDTH
Definition: htmlplug.cxx:85
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
unsigned char sal_uInt8
SwTwips GetPos() const
Definition: fmtornt.hxx:59
OUString GetTitle() const
Definition: ndnotxt.cxx:257
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
void IncIndentLevel()
Definition: wrthtml.hxx:496
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:434
SwNodes & GetNodes()
Definition: doc.hxx:403
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:1481
#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
long GetRight() const
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
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
long getHeight() const
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL
Definition: htmlplug.cxx:92
#define OOO_STRING_SVTOOLS_HTML_object
static sal_uInt16 GuessOLENodeFrameType(const SwNode &rNd)
Definition: htmlplug.cxx:1155
long getWidth() const
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
#define OOO_STRING_SVTOOLS_HTML_span
void setWidth(long nWidth)
#define SO3_PLUGIN_CLASSID
bool mbSkipImages
Definition: wrthtml.hxx:387
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:714
aStr
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool MakeId(const OUString &rId)
const HtmlFrmOpts HTML_FRMOPTS_EMBED_CNTNR
Definition: htmlplug.cxx:96
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_CNTNR
Definition: htmlplug.cxx:124
SwDoc * m_pDoc
Definition: shellio.hxx:403
static void SetFixSize(const Size &rPixSize, const Size &rTwipDfltSize, bool bPercentWidth, bool bPercentHeight, SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet)
Definition: htmlplug.cxx:163
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:1181
const void * GetData()
sal_uInt16 GetUpper() const
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1516
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:1893
Base class of the Writer document model elements.
Definition: node.hxx:79
void setHeight(long nHeight)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo