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 if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) )
262 {
263 // if applicable remove the first line indent
264 SvxLRSpaceItem aLRItem( *pLRItem );
265 aLRItem.SetTextFirstLineOffset( 0 );
266 if( rCSS1PropInfo.m_bLeftMargin )
267 {
268 nLeftSpace = aLRItem.GetLeft();
269 rCSS1PropInfo.m_bLeftMargin = false;
270 }
271 if( rCSS1PropInfo.m_bRightMargin )
272 {
273 nRightSpace = aLRItem.GetRight();
274 rCSS1PropInfo.m_bRightMargin = false;
275 }
276 rCSS1ItemSet.ClearItem( RES_LR_SPACE );
277 }
278 if( nLeftSpace > 0 || nRightSpace > 0 )
279 {
280 SvxLRSpaceItem aLRItem( RES_LR_SPACE );
281 aLRItem.SetLeft( std::max<sal_Int32>(nLeftSpace, 0) );
282 aLRItem.SetRight( std::max<sal_Int32>(nRightSpace, 0) );
283 rFlyItemSet.Put( aLRItem );
284 if( nLeftSpace )
285 {
286 const SwFormatHoriOrient& rHoriOri =
287 rFlyItemSet.Get( RES_HORI_ORIENT );
289 {
290 SwFormatHoriOrient aHoriOri( rHoriOri );
291 aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
292 rFlyItemSet.Put( aHoriOri );
293 }
294 }
295 }
296
297 // set top/bottom margin
298 if( const SvxULSpaceItem *pULItem = rCSS1ItemSet.GetItemIfSet( RES_UL_SPACE ) )
299 {
300 // if applicable remove the first line indent
301 if( rCSS1PropInfo.m_bTopMargin )
302 {
303 nUpperSpace = pULItem->GetUpper();
304 rCSS1PropInfo.m_bTopMargin = false;
305 }
306 if( rCSS1PropInfo.m_bBottomMargin )
307 {
308 nLowerSpace = pULItem->GetLower();
309 rCSS1PropInfo.m_bBottomMargin = false;
310 }
311 rCSS1ItemSet.ClearItem( RES_UL_SPACE );
312 }
313 if( !(nUpperSpace || nLowerSpace) )
314 return;
315
316 SvxULSpaceItem aULItem( RES_UL_SPACE );
317 aULItem.SetUpper( nUpperSpace );
318 aULItem.SetLower( nLowerSpace );
319 rFlyItemSet.Put( aULItem );
320 if( nUpperSpace )
321 {
322 const SwFormatVertOrient& rVertOri =
323 rFlyItemSet.Get( RES_VERT_ORIENT );
325 {
326 SwFormatVertOrient aVertOri( rVertOri );
327 aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
328 rFlyItemSet.Put( aVertOri );
329 }
330 }
331}
332
333OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
334{
335 if (!comphelper::isFileUrl(rBase))
336 return rPath;
337
338 sal_Int32 nIndex = rPath.indexOf('?');
339
340 if (nIndex != -1)
341 return rPath.copy(0, nIndex);
342
343 return rPath;
344}
345
347{
348 OUString aURL, aType, aName, aAlt, aId, aStyle, aClass;
349 OUString aData;
350 Size aSize( USHRT_MAX, USHRT_MAX );
351 Size aSpace( USHRT_MAX, USHRT_MAX );
352 bool bPercentWidth = false, bPercentHeight = false, bHidden = false;
353 sal_Int16 eVertOri = text::VertOrientation::NONE;
354 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
355 SvCommandList aCmdLst;
356 const HTMLOptions& rHTMLOptions = GetOptions();
357
358 // The options are read forwards, because the plug-ins expect them in this
359 // order. Still only the first value of an option may be regarded.
360 for (const auto & rOption : rHTMLOptions)
361 {
362 switch( rOption.GetToken() )
363 {
364 case HtmlOptionId::ID:
365 aId = rOption.GetString();
366 break;
367 case HtmlOptionId::STYLE:
368 aStyle = rOption.GetString();
369 break;
370 case HtmlOptionId::CLASS:
371 aClass = rOption.GetString();
372 break;
373 case HtmlOptionId::NAME:
374 aName = rOption.GetString();
375 break;
376 case HtmlOptionId::SRC:
377 if( aURL.isEmpty() )
378 aURL = rOption.GetString();
379 break;
380 case HtmlOptionId::ALT:
381 aAlt = rOption.GetString();
382 break;
383 case HtmlOptionId::TYPE:
384 if( aType.isEmpty() )
385 aType = rOption.GetString();
386 break;
387 case HtmlOptionId::ALIGN:
389 {
390 eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
391 eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
392 }
393 break;
394 case HtmlOptionId::WIDTH:
395 if( USHRT_MAX==aSize.Width() )
396 {
397 bPercentWidth = (rOption.GetString().indexOf('%') != -1);
398 aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
399 }
400 break;
401 case HtmlOptionId::HEIGHT:
402 if( USHRT_MAX==aSize.Height() )
403 {
404 bPercentHeight = (rOption.GetString().indexOf('%') != -1);
405 aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
406 }
407 break;
408 case HtmlOptionId::HSPACE:
409 if( USHRT_MAX==aSpace.Width() )
410 aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
411 break;
412 case HtmlOptionId::VSPACE:
413 if( USHRT_MAX==aSpace.Height() )
414 aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
415 break;
416 case HtmlOptionId::DATA:
417 if (m_bXHTML && aURL.isEmpty())
418 aData = rOption.GetString();
419 break;
420 case HtmlOptionId::UNKNOWN:
421 if (rOption.GetTokenString().equalsIgnoreAsciiCase(
423 {
424 bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
425 "FALSE");
426 }
427 break;
428 default: break;
429 }
430
431 // All parameters are passed to the plug-in.
432 aCmdLst.Append( rOption.GetTokenString(), rOption.GetString() );
433 }
434
435 static const std::set<std::u16string_view> vAllowlist = {
436 u"image/png",
437 u"image/gif",
438 u"image/x-MS-bmp",
439 u"image/jpeg",
440 u"image/x-wmf",
441 u"image/svg+xml",
442 u"image/tiff",
443 u"image/x-emf",
444 u"image/bmp",
445 u"image/tif",
446 u"image/wmf",
447 };
448
449 if (vAllowlist.find(aType) != vAllowlist.end() && m_aEmbeds.empty())
450 {
451 // Toplevel <object> for an image format -> that's an image, not an OLE object.
452 m_aEmbeds.push(nullptr);
453 return false;
454 }
455
456 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
457 SvxCSS1PropertyInfo aPropInfo;
458 if( HasStyleOptions( aStyle, aId, aClass ) )
459 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
460
461 // Convert the default values (except height/width, which is done by SetFrameSize())
463 eVertOri = text::VertOrientation::TOP;
464 if( USHRT_MAX==aSpace.Width() )
465 aSpace.setWidth( 0 );
466 if( USHRT_MAX==aSpace.Height() )
467 aSpace.setHeight( 0 );
468 if( bHidden )
469 {
470 // Size (0,0) will be changed to (MINFLY, MINFLY) in SetFrameSize()
471 aSize.setWidth( 0 ); aSize.setHeight( 0 );
472 aSpace.setWidth( 0 ); aSpace.setHeight( 0 );
473 bPercentWidth = bPercentHeight = false;
474 }
475
476 // prepare the URL
477 INetURLObject aURLObj;
478 bool bHasURL = !aURL.isEmpty() &&
479 aURLObj.SetURL(
483 bool bHasData = !aData.isEmpty();
484
485 try
486 {
487 // Strip query and everything after that for file:// URLs, browsers do
488 // the same.
489 aURLObj.SetURL(rtl::Uri::convertRelToAbs(
491 }
492 catch (const rtl::MalformedUriException& /*rException*/)
493 {
494 bHasData = false;
495 }
496
497 // do not insert plugin if it has neither URL nor type
498 bool bHasType = !aType.isEmpty();
499 if( !bHasURL && !bHasType && !bHasData )
500 return true;
501
502 if (!m_aEmbeds.empty())
503 {
504 // Nested XHTML <object> element: points to replacement graphic.
505 SwOLENode* pOLENode = m_aEmbeds.top();
506 if (!pOLENode)
507 {
508 // <object> is mapped to an image -> ignore replacement graphic.
509 return true;
510 }
511
512 svt::EmbeddedObjectRef& rObj = pOLENode->GetOLEObj().GetObject();
513 Graphic aGraphic;
514 if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
515 return true;
516
517 rObj.SetGraphic(aGraphic, aType);
518
519 // Set the size of the OLE frame to the size of the graphic.
520 SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
521 if (!pFormat)
522 return true;
523 SwAttrSet aAttrSet(pFormat->GetAttrSet());
524 aAttrSet.ClearItem(RES_CNTNT);
526 Size aDefaultTwipSize(pDevice->PixelToLogic(aGraphic.GetSizePixel(pDevice), MapMode(MapUnit::MapTwip)));
527
528 if (aSize.Width() == USHRT_MAX && bPercentHeight)
529 {
530 // Height is relative, width is not set: keep aspect ratio.
532 bPercentWidth = true;
533 }
534 if (aSize.Height() == USHRT_MAX && bPercentWidth)
535 {
536 // Width is relative, height is not set: keep aspect ratio.
538 bPercentHeight = true;
539 }
540
541 SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet);
542 pOLENode->GetDoc().SetFlyFrameAttr(*pFormat, aAttrSet);
543 return true;
544 }
545
546 // create the plug-in
548 OUString aObjName;
549 uno::Reference < embed::XEmbeddedObject > xObj;
550 if (!bHasData)
551 {
552 xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
554 {
555 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
556 if ( xSet.is() )
557 {
558 if( bHasURL )
559 xSet->setPropertyValue("PluginURL", uno::Any( aURL ) );
560 if( bHasType )
561 xSet->setPropertyValue("PluginMimeType", uno::Any( aType ) );
562
563 uno::Sequence < beans::PropertyValue > aProps;
564 aCmdLst.FillSequence( aProps );
565 xSet->setPropertyValue("PluginCommands", uno::Any( aProps ) );
566
567 }
568 }
569 }
570 else if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
571 {
572 // Has non-empty data attribute in XHTML: map that to an OLE object.
573 uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
574 aCnt.SwitchPersistence(xStorage);
575 aObjName = aCnt.CreateUniqueObjectName();
576 {
577 OUString aEmbedURL = aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
578 SvFileStream aFileStream(aEmbedURL, StreamMode::READ);
579 uno::Reference<io::XInputStream> xInStream;
580 SvMemoryStream aMemoryStream;
581
582 // Allow any MIME type that starts with magic, unless a set of allowed types are
583 // specified.
584 auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
585 if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
586 {
587 OString aMagic("{\\object");
588 OString aHeader(read_uInt8s_ToOString(aFileStream, aMagic.getLength()));
589 aFileStream.Seek(0);
590 if (aHeader == aMagic)
591 {
592 // OLE2 wrapped in RTF: either own format or real OLE2 embedding.
593 bool bOwnFormat = false;
594 if (SwReqIfReader::ExtractOleFromRtf(aFileStream, aMemoryStream, bOwnFormat))
595 {
596 xInStream.set(new utl::OStreamWrapper(aMemoryStream));
597 }
598
599 if (bOwnFormat)
600 {
601 uno::Sequence<beans::PropertyValue> aMedium = comphelper::InitPropertySequence(
602 { { "InputStream", uno::Any(xInStream) },
603 { "URL", uno::Any(OUString("private:stream")) },
604 { "DocumentBaseURL", uno::Any(m_sBaseURL) } });
605 xObj = aCnt.InsertEmbeddedObject(aMedium, aName, &m_sBaseURL);
606 }
607 else
608 {
609 // The type is now an OLE2 container, not the original XHTML type.
610 aType = "application/vnd.sun.star.oleobject";
611 }
612 }
613 }
614
615 if (!xInStream.is())
616 {
617 // Object data is neither OLE2 in RTF, nor an image. Then map this to an URL that
618 // will be set on the inner image.
619 m_aEmbedURL = aEmbedURL;
620 // Signal success, so the outer object won't fall back to the image handler.
621 return true;
622 }
623
624 if (!xObj.is())
625 {
626 uno::Reference<io::XStream> xOutStream
627 = xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
628 if (aFileStream.IsOpen())
630 xOutStream->getOutputStream());
631
632 if (!aType.isEmpty())
633 {
634 // Set media type of the native data.
635 uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
636 if (xOutStreamProps.is())
637 xOutStreamProps->setPropertyValue("MediaType", uno::Any(aType));
638 }
639 }
640 xObj = aCnt.GetEmbeddedObject(aObjName);
641 }
642 }
643
644 SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
645 if( !IsNewDoc() )
647
648 // set the anchor
649 if( !bHidden )
650 {
651 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
652 }
653 else
654 {
655 SwFormatAnchor aAnchor( RndStdIds::FLY_AT_PARA );
656 aAnchor.SetAnchor( m_pPam->GetPoint() );
657 aFrameSet.Put( aAnchor );
658 aFrameSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
659 aFrameSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
660 aFrameSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
661 }
662
663 // and the size of the frame
665 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
666 SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
667
668 // and insert into the document
669 uno::Reference<lang::XInitialization> xObjInitialization(xObj, uno::UNO_QUERY);
670 if (xObjInitialization.is())
671 {
672 // Request that the native data of the embedded object is not modified
673 // during parsing.
674 uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
675 true) };
676 uno::Sequence<uno::Any> aArguments{ uno::Any(aValues) };
677 xObjInitialization->initialize(aArguments);
678 }
679 SwFrameFormat* pFlyFormat =
680 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
681 ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
682 &aFrameSet);
683 if (xObjInitialization.is())
684 {
685 uno::Sequence<beans::PropertyValue> aValues{ comphelper::makePropertyValue("StreamReadOnly",
686 false) };
687 uno::Sequence<uno::Any> aArguments{ uno::Any(aValues) };
688 xObjInitialization->initialize(aArguments);
689 }
690
691 // set name at FrameFormat
692 if( !aName.isEmpty() )
693 pFlyFormat->SetFormatName( aName );
694
695 // set the alternative text
696 SwNoTextNode *pNoTextNd =
697 m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
698 ->GetIndex()+1 ]->GetNoTextNode();
699 pNoTextNd->SetTitle( aAlt );
700
701 // if applicable create frames and register auto-bound frames
702 if( !bHidden )
703 {
704 // HIDDEN plug-ins should stay paragraph-bound. Since RegisterFlyFrame()
705 // will change paragraph-bound frames with wrap-through into a
706 // character-bound frame, here we must create the frames by hand.
707 RegisterFlyFrame( pFlyFormat );
708 }
709
710 if (!bHasData)
711 return true;
712
713 SwOLENode* pOLENode = pNoTextNd->GetOLENode();
714 if (!pOLENode)
715 return true;
716
717 m_aEmbeds.push(pOLENode);
718
719 return true;
720}
721
722#if HAVE_FEATURE_JAVA
723void SwHTMLParser::NewObject()
724{
725 OUString aClassID;
726 OUString aStandBy, aId, aStyle, aClass;
727 Size aSize( USHRT_MAX, USHRT_MAX );
728 Size aSpace( 0, 0 );
729 sal_Int16 eVertOri = text::VertOrientation::TOP;
730 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
731
732 bool bPercentWidth = false, bPercentHeight = false,
733 bDeclare = false;
734 // create a new Command list
735 m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
736
737 const HTMLOptions& rHTMLOptions = GetOptions();
738 for (size_t i = rHTMLOptions.size(); i; )
739 {
740 const HTMLOption& rOption = rHTMLOptions[--i];
741 switch( rOption.GetToken() )
742 {
743 case HtmlOptionId::ID:
744 aId = rOption.GetString();
745 break;
746 case HtmlOptionId::STYLE:
747 aStyle = rOption.GetString();
748 break;
749 case HtmlOptionId::CLASS:
750 aClass = rOption.GetString();
751 break;
752 case HtmlOptionId::DECLARE:
753 bDeclare = true;
754 break;
755 case HtmlOptionId::CLASSID:
756 aClassID = rOption.GetString();
757 break;
758 case HtmlOptionId::CODEBASE:
759 break;
760 case HtmlOptionId::DATA:
761 break;
762 case HtmlOptionId::TYPE:
763 break;
764 case HtmlOptionId::CODETYPE:
765 break;
766 case HtmlOptionId::ARCHIVE:
767 case HtmlOptionId::UNKNOWN:
768 break;
769 case HtmlOptionId::STANDBY:
770 aStandBy = rOption.GetString();
771 break;
772 case HtmlOptionId::WIDTH:
773 bPercentWidth = (rOption.GetString().indexOf('%') != -1);
774 aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
775 break;
776 case HtmlOptionId::HEIGHT:
777 bPercentHeight = (rOption.GetString().indexOf('%') != -1);
778 aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
779 break;
780 case HtmlOptionId::ALIGN:
781 eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
782 eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
783 break;
784 case HtmlOptionId::USEMAP:
785 break;
786 case HtmlOptionId::NAME:
787 break;
788 case HtmlOptionId::HSPACE:
789 aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
790 break;
791 case HtmlOptionId::VSPACE:
792 aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
793 break;
794 case HtmlOptionId::BORDER:
795 break;
796
797 case HtmlOptionId::SDONCLICK:
798 case HtmlOptionId::ONCLICK:
799 case HtmlOptionId::SDONMOUSEOVER:
800 case HtmlOptionId::ONMOUSEOVER:
801 case HtmlOptionId::SDONMOUSEOUT:
802 case HtmlOptionId::ONMOUSEOUT:
803 break;
804 default: break;
805 }
806 // All parameters are passed to the applet.
807 m_pAppletImpl->AppendParam( rOption.GetTokenString(),
808 rOption.GetString() );
809
810 }
811
812 // Objects that are declared only are not evaluated. Moreover, only
813 // Java applets are supported.
814 bool bIsApplet = false;
815
816 if( !bDeclare && aClassID.getLength() == 42 &&
817 aClassID.startsWith("clsid:") )
818 {
819 aClassID = aClassID.copy(6);
820 SvGlobalName aCID;
821 if( aCID.MakeId( aClassID ) )
822 {
823 SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
824 0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
825
826 bIsApplet = aJavaCID == aCID;
827 }
828 }
829
830 if( !bIsApplet )
831 {
832 m_pAppletImpl.reset();
833 return;
834 }
835
836 m_pAppletImpl->SetAltText( aStandBy );
837
838 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
839 SvxCSS1PropertyInfo aPropInfo;
840 if( HasStyleOptions( aStyle, aId, aClass ) )
841 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
842
843 SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
844 if( !IsNewDoc() )
846
847 // set the anchor and the adjustment
848 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
849
850 // and still the size of the frame
852 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
853 SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
854}
855#endif
856
858{
859#if HAVE_FEATURE_JAVA
860 if( !m_pAppletImpl )
861 return;
862 if( !m_pAppletImpl->CreateApplet( m_sBaseURL ) )
863 return;
864
865 m_pAppletImpl->FinishApplet();
866
867 // and insert into the document
868 SwFrameFormat* pFlyFormat =
869 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
870 ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
871 &m_pAppletImpl->GetItemSet() );
872
873 // set the alternative name
874 SwNoTextNode *pNoTextNd =
875 m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
876 ->GetIndex()+1 ]->GetNoTextNode();
877 pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
878
879 // if applicable create frames and register auto-bound frames
880 RegisterFlyFrame( pFlyFormat );
881
882 m_pAppletImpl.reset();
883#else
884 (void) this; // Silence loplugin:staticmethods
885#endif
886}
887
888#if HAVE_FEATURE_JAVA
889void SwHTMLParser::InsertApplet()
890{
891 OUString aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
892 Size aSize( USHRT_MAX, USHRT_MAX );
893 Size aSpace( 0, 0 );
894 bool bPercentWidth = false, bPercentHeight = false, bMayScript = false;
895 sal_Int16 eVertOri = text::VertOrientation::TOP;
896 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
897
898 // create a new Command list
899 m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
900
901 const HTMLOptions& rHTMLOptions = GetOptions();
902 for (size_t i = rHTMLOptions.size(); i; )
903 {
904 const HTMLOption& rOption = rHTMLOptions[--i];
905 switch( rOption.GetToken() )
906 {
907 case HtmlOptionId::ID:
908 aId = rOption.GetString();
909 break;
910 case HtmlOptionId::STYLE:
911 aStyle = rOption.GetString();
912 break;
913 case HtmlOptionId::CLASS:
914 aClass = rOption.GetString();
915 break;
916 case HtmlOptionId::CODEBASE:
917 aCodeBase = rOption.GetString();
918 break;
919 case HtmlOptionId::CODE:
920 aCode = rOption.GetString();
921 break;
922 case HtmlOptionId::NAME:
923 aName = rOption.GetString();
924 break;
925 case HtmlOptionId::ALT:
926 aAlt = rOption.GetString();
927 break;
928 case HtmlOptionId::ALIGN:
929 eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
930 eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
931 break;
932 case HtmlOptionId::WIDTH:
933 bPercentWidth = (rOption.GetString().indexOf('%') != -1);
934 aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
935 break;
936 case HtmlOptionId::HEIGHT:
937 bPercentHeight = (rOption.GetString().indexOf('%') != -1);
938 aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
939 break;
940 case HtmlOptionId::HSPACE:
941 aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
942 break;
943 case HtmlOptionId::VSPACE:
944 aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
945 break;
946 case HtmlOptionId::MAYSCRIPT:
947 bMayScript = true;
948 break;
949 default: break;
950 }
951
952 // All parameters are passed to the applet.
953 m_pAppletImpl->AppendParam( rOption.GetTokenString(),
954 rOption.GetString() );
955 }
956
957 if( aCode.isEmpty() )
958 {
959 m_pAppletImpl.reset();
960 return;
961 }
962
963 if ( !aCodeBase.isEmpty() )
964 aCodeBase = INetURLObject::GetAbsURL( m_sBaseURL, aCodeBase );
965 m_pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, m_sBaseURL );//, aAlt );
966 m_pAppletImpl->SetAltText( aAlt );
967
968 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
969 SvxCSS1PropertyInfo aPropInfo;
970 if( HasStyleOptions( aStyle, aId, aClass ) )
971 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
972
973 SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
974 if( !IsNewDoc() )
976
977 // set the anchor and the adjustment
978 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
979
980 // and still the size or the frame
982 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
983 SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
984}
985#endif
986
988{
989#if HAVE_FEATURE_JAVA
990 if( !m_pAppletImpl )
991 return;
992
993 m_pAppletImpl->FinishApplet();
994
995 // and insert into the document
996 SwFrameFormat* pFlyFormat =
997 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
998 ::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
999 &m_pAppletImpl->GetItemSet());
1000
1001 // set the alternative name
1002 SwNoTextNode *pNoTextNd =
1003 m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
1004 ->GetIndex()+1 ]->GetNoTextNode();
1005 pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
1006
1007 // if applicable create frames and register auto-bound frames
1008 RegisterFlyFrame( pFlyFormat );
1009
1010 m_pAppletImpl.reset();
1011#else
1012 (void) this;
1013#endif
1014}
1015
1017{
1018#if HAVE_FEATURE_JAVA
1019 if( !m_pAppletImpl )
1020 return;
1021
1022 OUString aName, aValue;
1023
1024 const HTMLOptions& rHTMLOptions = GetOptions();
1025 for (size_t i = rHTMLOptions.size(); i; )
1026 {
1027 const HTMLOption& rOption = rHTMLOptions[--i];
1028 switch( rOption.GetToken() )
1029 {
1030 case HtmlOptionId::NAME:
1031 aName = rOption.GetString();
1032 break;
1033 case HtmlOptionId::VALUE:
1034 aValue = rOption.GetString();
1035 break;
1036 default: break;
1037 }
1038 }
1039
1040 if( aName.isEmpty() )
1041 return;
1042
1043 m_pAppletImpl->AppendParam( aName, aValue );
1044#else
1045 (void) this;
1046#endif
1047}
1048
1050{
1051 OUString aAlt, aId, aStyle, aClass;
1052 Size aSize( USHRT_MAX, USHRT_MAX );
1053 Size aSpace( 0, 0 );
1054 bool bPercentWidth = false, bPercentHeight = false;
1055 sal_Int16 eVertOri = text::VertOrientation::TOP;
1056 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1057
1058 const HTMLOptions& rHTMLOptions = GetOptions();
1059
1060 // First fetch the options of the Writer-Frame-Format
1061 for (const auto & rOption : rHTMLOptions)
1062 {
1063 switch( rOption.GetToken() )
1064 {
1065 case HtmlOptionId::ID:
1066 aId = rOption.GetString();
1067 break;
1068 case HtmlOptionId::STYLE:
1069 aStyle = rOption.GetString();
1070 break;
1071 case HtmlOptionId::CLASS:
1072 aClass = rOption.GetString();
1073 break;
1074 case HtmlOptionId::ALT:
1075 aAlt = rOption.GetString();
1076 break;
1077 case HtmlOptionId::ALIGN:
1078 eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
1079 eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
1080 break;
1081 case HtmlOptionId::WIDTH:
1082 bPercentWidth = (rOption.GetString().indexOf('%') != -1);
1083 aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
1084 break;
1085 case HtmlOptionId::HEIGHT:
1086 bPercentHeight = (rOption.GetString().indexOf('%') != -1);
1087 aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
1088 break;
1089 case HtmlOptionId::HSPACE:
1090 aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
1091 break;
1092 case HtmlOptionId::VSPACE:
1093 aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
1094 break;
1095 default: break;
1096 }
1097 }
1098
1099 // and now the ones for the SfxFrame
1100 SfxFrameDescriptor aFrameDesc;
1101
1102 SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, rHTMLOptions, m_sBaseURL );
1103
1104 // create a floating frame
1106 OUString aObjName;
1107 uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
1108
1109 try
1110 {
1111 // TODO/MBA: testing
1113 {
1114 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1115 if ( xSet.is() )
1116 {
1117 const OUString& aName = aFrameDesc.GetName();
1118 ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
1119 bool bHasBorder = aFrameDesc.HasFrameBorder();
1120 Size aMargin = aFrameDesc.GetMargin();
1121
1122 OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1123
1124 if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro)
1126
1127 xSet->setPropertyValue("FrameURL", uno::Any( sHRef ) );
1128 xSet->setPropertyValue("FrameName", uno::Any( aName ) );
1129
1130 if ( eScroll == ScrollingMode::Auto )
1131 xSet->setPropertyValue("FrameIsAutoScroll",
1132 uno::Any( true ) );
1133 else
1134 xSet->setPropertyValue("FrameIsScrollingMode",
1135 uno::Any( eScroll == ScrollingMode::Yes ) );
1136
1137 xSet->setPropertyValue("FrameIsBorder",
1138 uno::Any( bHasBorder ) );
1139
1140 xSet->setPropertyValue("FrameMarginWidth",
1141 uno::Any( sal_Int32( aMargin.Width() ) ) );
1142
1143 xSet->setPropertyValue("FrameMarginHeight",
1144 uno::Any( sal_Int32( aMargin.Height() ) ) );
1145 }
1146 }
1147 }
1148 catch ( uno::Exception& )
1149 {
1150 }
1151
1152 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1153 SvxCSS1PropertyInfo aPropInfo;
1154 if( HasStyleOptions( aStyle, aId, aClass ) )
1155 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
1156
1157 // fetch the ItemSet
1158 SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END-1> aFrameSet( m_xDoc->GetAttrPool() );
1159 if( !IsNewDoc() )
1160 Reader::ResetFrameFormatAttrs( aFrameSet );
1161
1162 // set the anchor and the adjustment
1163 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
1164
1165 // and still the size of the frame
1167 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
1168 SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
1169
1170 // and insert into the document
1171 SwFrameFormat* pFlyFormat =
1172 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
1173 ::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
1174 &aFrameSet);
1175
1176 // set the alternative name
1177 SwNoTextNode *pNoTextNd =
1178 m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
1179 ->GetIndex()+1 ]->GetNoTextNode();
1180 pNoTextNd->SetTitle( aAlt );
1181
1182 // if applicable create frames and register auto-bound frames
1183 RegisterFlyFrame( pFlyFormat );
1184
1185 m_bInFloatingFrame = true;
1186
1188}
1189
1191{
1193
1194 SwOLENode* pOLENode = const_cast<SwOLENode*>(rNode.GetOLENode());
1195 assert(pOLENode && "must exist");
1196 SwOLEObj& rObj = pOLENode->GetOLEObj();
1197
1198 uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
1199 SvGlobalName aClass( xClass->getClassID() );
1200 if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1201 {
1203 }
1204 else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1205 {
1207 }
1208#if HAVE_FEATURE_JAVA
1209 else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1210 {
1212 }
1213#endif
1214
1215 return static_cast< sal_uInt16 >(eType);
1216}
1217
1219 bool bInCntnr )
1220{
1221 SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1222
1223 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1224 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1225 SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1226
1227 OSL_ENSURE( pOLENd, "OLE-Node expected" );
1228 if( !pOLENd )
1229 return rWrt;
1230
1231 SwOLEObj &rObj = pOLENd->GetOLEObj();
1232
1233 uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1235 return rWrt;
1236
1237 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1238 bool bHiddenEmbed = false;
1239
1240 if( !xSet.is() )
1241 {
1242 OSL_FAIL("Unknown Object" );
1243 return rWrt;
1244 }
1245
1246 HtmlFrmOpts nFrameOpts;
1247
1248 // if possible output a line break before the "object"
1249 if( rHTMLWrt.m_bLFPossible )
1250 rHTMLWrt.OutNewLine( true );
1251
1252 if( !rFrameFormat.GetName().isEmpty() )
1253 rHTMLWrt.OutImplicitMark( rFrameFormat.GetName(),
1254 "ole" );
1255 uno::Any aAny;
1256 SvGlobalName aGlobName( xObj->getClassID() );
1257 OStringBuffer sOut;
1258 sOut.append('<');
1259 if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1260 {
1261 // first the plug-in specifics
1262 sOut.append(rHTMLWrt.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(' ').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(rHTMLWrt.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(' ').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(rHTMLWrt.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( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1381 nFrameOpts |= HTML_FRMOPTS_OLE_CSS1;
1382 OString aEndTags = rHTMLWrt.OutFrameFormatOptions( rFrameFormat, pOLENd->GetTitle(), nFrameOpts );
1383 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1384 rHTMLWrt.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().WriteCharPtr( "=\"" );
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 rHTMLWrt.Strm().WriteChar( '>' );
1419
1420 rHTMLWrt.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 rHTMLWrt.OutNewLine();
1429 OStringBuffer sBuf;
1430 sBuf.append("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param
1432 "=\"");
1433 rWrt.Strm().WriteOString( sBuf );
1434 sOut.setLength(0);
1435 HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
1436 sBuf.append("\" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
1437 rWrt.Strm().WriteOString( sBuf );
1438 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteCharPtr( "\">" );
1439 }
1440
1441 rHTMLWrt.DecIndentLevel(); // indent the applet content
1442 if( aCommands.size() )
1443 rHTMLWrt.OutNewLine();
1444 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet), false );
1445 }
1446 else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1447 {
1448 // write plug-ins parameters as options
1449
1450 uno::Sequence < beans::PropertyValue > aProps;
1451 aAny = xSet->getPropertyValue("PluginCommands");
1452 aAny >>= aProps;
1453
1454 SvCommandList aCommands;
1455 aCommands.FillFromSequence( aProps );
1456 for( size_t i = 0; i < aCommands.size(); i++ )
1457 {
1458 const SvCommand& rCommand = aCommands[ i ];
1459 const OUString& rName = rCommand.GetCommand();
1460
1461 if( SwApplet_Impl::GetOptionType( rName, false ) == SwHtmlOptType::TAG )
1462 {
1463 const OUString& rValue = rCommand.GetArgument();
1464 rWrt.Strm().WriteChar( ' ' );
1465 HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
1466 rWrt.Strm().WriteCharPtr( "=\"" );
1467 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteChar( '\"' );
1468 }
1469 }
1470 rHTMLWrt.Strm().WriteChar( '>' );
1471 }
1472 else
1473 {
1474 // and for Floating-Frames just output another </IFRAME>
1475
1476 rHTMLWrt.Strm().WriteChar( '>' );
1477 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe), false );
1478 }
1479
1480 if( !aEndTags.isEmpty() )
1481 rWrt.Strm().WriteOString( aEndTags );
1482
1483 return rWrt;
1484}
1485
1487 bool bInCntnr )
1488{
1489 SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
1490
1491 const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
1492 SwNodeOffset nStt = rFlyContent.GetContentIdx()->GetIndex()+1;
1493 SwOLENode *pOLENd = rHTMLWrt.m_pDoc->GetNodes()[ nStt ]->GetOLENode();
1494
1495 OSL_ENSURE( pOLENd, "OLE-Node expected" );
1496 if( !pOLENd )
1497 return rWrt;
1498
1499 if (rHTMLWrt.mbSkipImages)
1500 {
1501 // If we skip images, embedded objects would be completely lost.
1502 // Instead, try to use the HTML export of the embedded object.
1503 uno::Reference<text::XTextContent> xTextContent = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rHTMLWrt.m_pDoc, const_cast<SwFrameFormat*>(&rFrameFormat));
1504 uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
1505 uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
1506 SAL_WARN_IF(!xStorable.is(), "sw.html", "OutHTML_FrameFormatOLENodeGrf: no embedded object");
1507
1508 // Figure out what is the filter name of the embedded object.
1509 uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
1510 OUString aFilter;
1511 if (xServiceInfo.is())
1512 {
1513 if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
1514 aFilter = "HTML (StarCalc)";
1515 else if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
1516 aFilter = "HTML (StarWriter)";
1517 }
1518
1519 if (xStorable.is() && !aFilter.isEmpty())
1520 {
1521 try
1522 {
1523 // FIXME: exception for the simplest test document, too
1524 SvMemoryStream aStream;
1525 uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
1526 utl::MediaDescriptor aMediaDescriptor;
1527 aMediaDescriptor["FilterName"] <<= aFilter;
1528 aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter");
1529 aMediaDescriptor["OutputStream"] <<= xOutputStream;
1530 xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList());
1531 SAL_WARN_IF(aStream.GetSize()>=o3tl::make_unsigned(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString");
1532 OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize()));
1533 // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p'
1535 rWrt.Strm().WriteOString(aData);
1536 HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false);
1537 }
1538 catch ( uno::Exception& )
1539 {
1540 }
1541 }
1542
1543 return rWrt;
1544 }
1545
1546 if ( !pOLENd->GetGraphic() )
1547 {
1548 SAL_WARN("sw.html", "Unexpected missing OLE fallback graphic");
1549 return rWrt;
1550 }
1551
1552 Graphic aGraphic( *pOLENd->GetGraphic() );
1553
1554 SwDocShell* pDocSh = rHTMLWrt.m_pDoc->GetDocShell();
1555 bool bObjectOpened = false;
1556 OUString aRTFType = "text/rtf";
1557 if (!rHTMLWrt.m_aRTFOLEMimeType.isEmpty())
1558 {
1559 aRTFType = rHTMLWrt.m_aRTFOLEMimeType;
1560 }
1561
1562 if (rHTMLWrt.mbXHTML && pDocSh)
1563 {
1564 // Map native data to an outer <object> element.
1565
1566 // Calculate the file name, which is meant to be the same as the
1567 // replacement image, just with a .ole extension.
1568 OUString aFileName = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"ole");
1569
1570 // Write the data.
1571 SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
1572 uno::Reference<embed::XEmbeddedObject> xEmbeddedObject = rOLEObj.GetOleRef();
1573 OUString aFileType;
1574 SvFileStream aOutStream(aFileName, StreamMode::WRITE);
1575 uno::Reference<io::XActiveDataStreamer> xStreamProvider;
1576 uno::Reference<embed::XEmbedPersist2> xOwnEmbedded;
1577 if (xEmbeddedObject.is())
1578 {
1579 xStreamProvider.set(xEmbeddedObject, uno::UNO_QUERY);
1580 xOwnEmbedded.set(xEmbeddedObject, uno::UNO_QUERY);
1581 }
1582 if (xStreamProvider.is())
1583 {
1584 // Real OLE2 case: OleEmbeddedObject.
1585 uno::Reference<io::XInputStream> xStream(xStreamProvider->getStream(), uno::UNO_QUERY);
1586 if (xStream.is())
1587 {
1588 std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream));
1589 if (SwReqIfReader::WrapOleInRtf(*pStream, aOutStream, *pOLENd, rFrameFormat))
1590 {
1591 // Data always wrapped in RTF.
1592 aFileType = aRTFType;
1593 }
1594 }
1595 }
1596 else if (xOwnEmbedded.is())
1597 {
1598 // Our own embedded object: OCommonEmbeddedObject.
1599 SvxMSExportOLEObjects aOLEExp(0);
1600 // Trigger the load of the OLE object if needed, otherwise we can't
1601 // export it.
1602 pOLENd->GetTwipSize();
1603 SvMemoryStream aMemory;
1604 tools::SvRef<SotStorage> pStorage = new SotStorage(aMemory);
1605 aOLEExp.ExportOLEObject(rOLEObj.GetObject(), *pStorage);
1606 pStorage->Commit();
1607 aMemory.Seek(0);
1608 if (SwReqIfReader::WrapOleInRtf(aMemory, aOutStream, *pOLENd, rFrameFormat))
1609 {
1610 // Data always wrapped in RTF.
1611 aFileType = aRTFType;
1612 }
1613 }
1614 else
1615 {
1616 // Otherwise the native data is just a grab-bag: ODummyEmbeddedObject.
1617 const OUString& aStreamName = rOLEObj.GetCurrentPersistName();
1618 uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
1619 uno::Reference<io::XStream> xInStream;
1620 try
1621 {
1622 // Even the native data may be missing.
1623 xInStream = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
1624 } catch (const uno::Exception&)
1625 {
1626 TOOLS_WARN_EXCEPTION("sw.html", "OutHTML_FrameFormatOLENodeGrf: failed to open stream element");
1627 }
1628 if (xInStream.is())
1629 {
1630 uno::Reference<io::XStream> xOutStream(new utl::OStreamWrapper(aOutStream));
1631 comphelper::OStorageHelper::CopyInputToOutput(xInStream->getInputStream(),
1632 xOutStream->getOutputStream());
1633 }
1634
1635 uno::Reference<beans::XPropertySet> xOutStreamProps(xInStream, uno::UNO_QUERY);
1636 if (xOutStreamProps.is())
1637 xOutStreamProps->getPropertyValue("MediaType") >>= aFileType;
1638 if (!aRTFType.isEmpty())
1639 {
1640 aFileType = aRTFType;
1641 }
1642 }
1643 aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
1644
1645 // Refer to this data.
1646 if (rHTMLWrt.m_bLFPossible)
1647 rHTMLWrt.OutNewLine();
1648 rWrt.Strm().WriteOString(Concat2View("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object));
1649 rWrt.Strm().WriteOString(Concat2View(" data=\"" + aFileName.toUtf8() + "\""));
1650 if (!aFileType.isEmpty())
1651 rWrt.Strm().WriteOString(Concat2View(" type=\"" + aFileType.toUtf8() + "\""));
1652 rWrt.Strm().WriteOString(">");
1653 bObjectOpened = true;
1654 rHTMLWrt.m_bLFPossible = true;
1655 }
1656
1657 OUString aGraphicURL;
1658 OUString aMimeType;
1659 if(!rHTMLWrt.mbEmbedImages)
1660 {
1661 const OUString* pTempFileName = rHTMLWrt.GetOrigFileName();
1662 if(pTempFileName)
1663 aGraphicURL = *pTempFileName;
1664
1665 OUString aFilterName("JPG");
1666 XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
1667
1668 if (bObjectOpened)
1669 {
1670 aFilterName = "PNG";
1671 nFlags = XOutFlags::NONE;
1672 aMimeType = "image/png";
1673
1674 if (aGraphic.GetType() == GraphicType::NONE)
1675 {
1676 // The OLE Object has no replacement image, write a stub.
1677 aGraphicURL = lcl_CalculateFileName(rHTMLWrt.GetOrigFileName(), aGraphic, u"png");
1678 osl::File aFile(aGraphicURL);
1679 aFile.open(osl_File_OpenFlag_Create);
1680 aFile.close();
1681 }
1682 }
1683
1684 ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL,
1685 aFilterName,
1686 nFlags );
1687 if( nErr ) // error, don't write anything
1688 {
1689 rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
1690 if (bObjectOpened) // Still at least close the tag.
1691 rWrt.Strm().WriteOString(Concat2View("</" + rHTMLWrt.GetNamespace()
1693 return rWrt;
1694 }
1695 aGraphicURL = URIHelper::SmartRel2Abs(
1696 INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
1698
1699 }
1700 HtmlFrmOpts nFlags = bInCntnr ? HtmlFrmOpts::GenImgAllMask
1702 if (bObjectOpened)
1703 nFlags |= HtmlFrmOpts::Replacement;
1704 HtmlWriter aHtml(rWrt.Strm(), rHTMLWrt.maNamespace);
1705 OutHTML_ImageStart( aHtml, rWrt, rFrameFormat, aGraphicURL, aGraphic,
1706 pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1707 nFlags, "ole", nullptr, aMimeType );
1708 OutHTML_ImageEnd(aHtml, rWrt);
1709
1710 if (bObjectOpened)
1711 // Close native data.
1712 rWrt.Strm().WriteOString(Concat2View("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object
1713 ">"));
1714
1715 return rWrt;
1716}
1717
1718/* 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)
SvStream & WriteCharPtr(const char *pBuf)
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)
tools::Long GetRight() const
tools::Long GetLeft() const
void SetTextFirstLineOffset(const short nF, 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(const OUString &rName, bool bApplet)
SwNodes & GetNodes()
Definition: doc.hxx:417
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:553
SwDocShell * GetDocShell()
Definition: doc.hxx:1359
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1586
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:62
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2593
std::stack< SwOLENode * > m_aEmbeds
Non-owning pointers to already inserted OLE nodes, matching opened <object> XHTML elements.
Definition: swhtml.hxx:492
void EndApplet()
Definition: htmlplug.cxx:987
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:477
bool InsertEmbed()
Definition: htmlplug.cxx:346
bool m_bInFloatingFrame
Definition: swhtml.hxx:441
std::set< OUString > m_aAllowedRTFOLEMimeTypes
Definition: swhtml.hxx:494
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:1018
void InsertParam()
Definition: htmlplug.cxx:1016
SwPaM * m_pPam
Definition: swhtml.hxx:394
void EndObject()
Definition: htmlplug.cxx:857
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:393
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:1838
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:389
std::unique_ptr< SwApplet_Impl > m_pAppletImpl
Definition: swhtml.hxx:387
void NotifyMacroEventRead()
Definition: htmlgrin.cxx:1562
void RegisterFlyFrame(SwFrameFormat *pFlyFrame)
Definition: htmlgrin.cxx:278
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:333
bool m_bXHTML
Definition: swhtml.hxx:485
OUString m_sBaseURL
Definition: swhtml.hxx:358
void InsertFloatingFrame()
Definition: htmlplug.cxx:1049
OUString m_aEmbedURL
This is the URL of the outer <object> data if it's not OLE2 or an image.
Definition: swhtml.hxx:497
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
static sal_uInt16 GuessOLENodeFrameType(const SwNode &rNd)
Definition: htmlplug.cxx:1190
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:1570
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:1853
void OutNewLine(bool bCheck=false)
Definition: wrthtml.cxx:1521
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:424
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
Definition: wrthtml.cxx:1314
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:171
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:739
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:424
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:116
const Graphic * GetGraphic()
Definition: ndole.cxx:246
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:993
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:942
const OUString & GetCurrentPersistName() const
Definition: ndole.hxx:72
const SwPosition * GetPoint() const
Definition: pam.hxx:261
static rtl::Reference< SwXTextEmbeddedObject > CreateXTextEmbeddedObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3508
const OUString * GetOrigFileName() const
Definition: shellio.hxx:434
SvStream & Strm()
Definition: writer.cxx:214
SwDoc * m_pDoc
Definition: shellio.hxx:403
const OUString & GetBaseURL() const
Definition: shellio.hxx:439
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)
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 sal_uInt16 RES_FRMATR_END(133)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
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
Writer & OutHTML_ImageEnd(HtmlWriter &rHtml, Writer &rWrt)
Writer & OutHTML_ImageStart(HtmlWriter &rHtml, Writer &rWrt, const SwFrameFormat &rFrameFormat, const OUString &rGraphicURL, Graphic const &rGraphic, const OUString &rAlternateText, const Size &rRealSize, HtmlFrmOpts nFrameOpts, const char *pMarkType, const ImageMap *pAltImgMap, const OUString &rMimeType)
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
Writer & OutHTML_FrameFormatOLENode(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1218
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_CNTNR
Definition: htmlplug.cxx:126
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
Writer & OutHTML_FrameFormatOLENodeGrf(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
Definition: htmlplug.cxx:1486
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(OUString const &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