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