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