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