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