20 #include <config_java.h>
23 #include <rtl/strbuf.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>
72 #include <rtl/uri.hxx>
80 #include <osl/file.hxx>
87 #define HTML_DFLT_EMBED_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
88 #define HTML_DFLT_EMBED_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
90 #define HTML_DFLT_APPLET_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
91 #define HTML_DFLT_APPLET_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
146 OUString lcl_CalculateFileName(
const OUString* pOrigFileName,
const Graphic& rGraphic,
147 std::u16string_view rExtension)
152 aFileName = *pOrigFileName;
166 const Size& rTwipDfltSize,
167 bool bPercentWidth,
bool bPercentHeight,
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() );
186 aTwipSz.setWidth( rTwipDfltSize.
Width() );
190 aTwipSz.setWidth( rCSS1PropInfo.
m_nWidth );
192 else if( bPercentWidth && rPixSize.
Width() )
195 if( nPercentWidth > 100 )
198 aTwipSz.setWidth( rTwipDfltSize.
Width() );
200 else if( USHRT_MAX==rPixSize.
Width() )
202 aTwipSz.setWidth( rTwipDfltSize.
Width() );
204 if( aTwipSz.Width() <
MINFLY )
206 aTwipSz.setWidth(
MINFLY );
213 aTwipSz.setHeight( rTwipDfltSize.
Height() );
217 aTwipSz.setHeight( rCSS1PropInfo.
m_nHeight );
219 else if( bPercentHeight && rPixSize.
Height() )
222 if( nPercentHeight > 100 )
223 nPercentHeight = 100;
225 aTwipSz.setHeight( rTwipDfltSize.
Height() );
227 else if( USHRT_MAX==rPixSize.
Height() )
229 aTwipSz.setHeight( rTwipDfltSize.
Height() );
231 if( aTwipSz.Height() <
MINFLY )
233 aTwipSz.setHeight(
MINFLY );
239 aFrameSize.SetHeightPercent( nPercentHeight );
240 rFlyItemSet.
Put( aFrameSize );
248 sal_Int32 nLeftSpace = 0, nRightSpace = 0;
249 sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
256 nLeftSpace = nRightSpace = aTwipSpc.Width();
257 nUpperSpace = nLowerSpace = o3tl::narrowing<sal_uInt16>(aTwipSpc.Height());
268 nLeftSpace = aLRItem.
GetLeft();
278 if( nLeftSpace > 0 || nRightSpace > 0 )
281 aLRItem.
SetLeft( std::max<sal_Int32>(nLeftSpace, 0) );
282 aLRItem.
SetRight( std::max<sal_Int32>(nRightSpace, 0) );
283 rFlyItemSet.
Put( aLRItem );
292 rFlyItemSet.
Put( aHoriOri );
303 nUpperSpace = pULItem->GetUpper();
308 nLowerSpace = pULItem->GetLower();
313 if( !(nUpperSpace || nLowerSpace) )
319 rFlyItemSet.
Put( aULItem );
328 rFlyItemSet.
Put( aVertOri );
338 sal_Int32
nIndex = rPath.indexOf(
'?');
341 return rPath.copy(0, nIndex);
350 Size aSize( USHRT_MAX, USHRT_MAX );
351 Size aSpace( USHRT_MAX, USHRT_MAX );
352 bool bPercentWidth =
false, bPercentHeight =
false, bHidden =
false;
360 for (
const auto & rOption : rHTMLOptions)
362 switch( rOption.GetToken() )
364 case HtmlOptionId::ID:
365 aId = rOption.GetString();
367 case HtmlOptionId::STYLE:
368 aStyle = rOption.GetString();
370 case HtmlOptionId::CLASS:
371 aClass = rOption.GetString();
373 case HtmlOptionId::NAME:
374 aName = rOption.GetString();
376 case HtmlOptionId::SRC:
378 aURL = rOption.GetString();
380 case HtmlOptionId::ALT:
381 aAlt = rOption.GetString();
383 case HtmlOptionId::TYPE:
384 if( aType.isEmpty() )
385 aType = rOption.GetString();
387 case HtmlOptionId::ALIGN:
394 case HtmlOptionId::WIDTH:
395 if( USHRT_MAX==aSize.
Width() )
397 bPercentWidth = (rOption.GetString().indexOf(
'%') != -1);
398 aSize.
setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
401 case HtmlOptionId::HEIGHT:
402 if( USHRT_MAX==aSize.
Height() )
404 bPercentHeight = (rOption.GetString().indexOf(
'%') != -1);
405 aSize.
setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
408 case HtmlOptionId::HSPACE:
409 if( USHRT_MAX==aSpace.
Width() )
410 aSpace.
setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
412 case HtmlOptionId::VSPACE:
413 if( USHRT_MAX==aSpace.
Height() )
414 aSpace.
setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
416 case HtmlOptionId::DATA:
417 if (m_bXHTML && aURL.isEmpty())
418 aData = rOption.GetString();
420 case HtmlOptionId::UNKNOWN:
421 if (rOption.GetTokenString().equalsIgnoreAsciiCase(
424 bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
432 aCmdLst.
Append( rOption.GetTokenString(), rOption.GetString() );
435 static const std::set<std::u16string_view> vAllowlist = {
446 if (vAllowlist.find(aType) != vAllowlist.end() && m_aEmbeds.empty())
449 m_aEmbeds.push(
nullptr);
453 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
455 if( HasStyleOptions( aStyle, aId, aClass ) )
456 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
460 eVertOri = text::VertOrientation::TOP;
461 if( USHRT_MAX==aSpace.
Width() )
463 if( USHRT_MAX==aSpace.
Height() )
470 bPercentWidth = bPercentHeight =
false;
475 bool bHasURL = !aURL.isEmpty() &&
480 bool bHasData = !aData.isEmpty();
486 aURLObj.
SetURL(rtl::Uri::convertRelToAbs(
489 catch (
const rtl::MalformedUriException& )
495 bool bHasType = !aType.isEmpty();
496 if( !bHasURL && !bHasType && !bHasData )
499 if (!m_aEmbeds.empty())
524 SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet);
532 uno::Reference < embed::XEmbeddedObject > xObj;
538 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
542 xSet->setPropertyValue(
"PluginURL",
uno::Any( aURL ) );
544 xSet->setPropertyValue(
"PluginMimeType",
uno::Any( aType ) );
546 uno::Sequence < beans::PropertyValue > aProps;
548 xSet->setPropertyValue(
"PluginCommands",
uno::Any( aProps ) );
553 else if (
SwDocShell* pDocSh = m_xDoc->GetDocShell())
556 uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
562 uno::Reference<io::XInputStream> xInStream;
567 auto it = m_aAllowedRTFOLEMimeTypes.find(aType);
568 if (m_aAllowedRTFOLEMimeTypes.empty() || it != m_aAllowedRTFOLEMimeTypes.end())
570 OString aMagic(
"{\\object");
573 if (aHeader == aMagic)
576 bool bOwnFormat =
false;
585 { {
"InputStream",
uno::Any(xInStream) },
586 {
"URL",
uno::Any(OUString(
"private:stream")) },
587 {
"DocumentBaseURL",
uno::Any(m_sBaseURL) } });
593 aType =
"application/vnd.sun.star.oleobject";
604 uno::Reference<io::XStream> xOutStream
605 = xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
606 if (aFileStream.IsOpen())
608 xOutStream->getOutputStream());
610 if (!aType.isEmpty())
613 uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
614 if (xOutStreamProps.is())
615 xOutStreamProps->setPropertyValue(
"MediaType",
uno::Any(aType));
629 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
635 aFrameSet.Put( aAnchor );
636 aFrameSet.Put(
SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
638 aFrameSet.Put(
SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
643 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
644 SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
647 uno::Reference<lang::XInitialization> xObjInitialization(xObj, uno::UNO_QUERY);
648 if (xObjInitialization.is())
658 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
661 if (xObjInitialization.is())
670 if( !aName.isEmpty() )
685 RegisterFlyFrame( pFlyFormat );
695 m_aEmbeds.push(pOLENode);
700 #if HAVE_FEATURE_JAVA
701 void SwHTMLParser::NewObject()
704 OUString aStandBy,
aId, aStyle, aClass;
705 Size aSize( USHRT_MAX, USHRT_MAX );
707 sal_Int16 eVertOri = text::VertOrientation::TOP;
710 bool bPercentWidth =
false, bPercentHeight =
false,
713 m_pAppletImpl.reset(
new SwApplet_Impl( m_xDoc->GetAttrPool() ));
716 for (
size_t i = rHTMLOptions.size();
i; )
721 case HtmlOptionId::ID:
724 case HtmlOptionId::STYLE:
727 case HtmlOptionId::CLASS:
730 case HtmlOptionId::DECLARE:
733 case HtmlOptionId::CLASSID:
736 case HtmlOptionId::CODEBASE:
738 case HtmlOptionId::DATA:
740 case HtmlOptionId::TYPE:
742 case HtmlOptionId::CODETYPE:
744 case HtmlOptionId::ARCHIVE:
745 case HtmlOptionId::UNKNOWN:
747 case HtmlOptionId::STANDBY:
750 case HtmlOptionId::WIDTH:
751 bPercentWidth = (rOption.
GetString().indexOf(
'%') != -1);
752 aSize.setWidth( static_cast<tools::Long>(rOption.
GetNumber()) );
754 case HtmlOptionId::HEIGHT:
755 bPercentHeight = (rOption.
GetString().indexOf(
'%') != -1);
756 aSize.setHeight( static_cast<tools::Long>(rOption.
GetNumber()) );
758 case HtmlOptionId::ALIGN:
762 case HtmlOptionId::USEMAP:
764 case HtmlOptionId::NAME:
766 case HtmlOptionId::HSPACE:
767 aSpace.setWidth( static_cast<tools::Long>(rOption.
GetNumber()) );
769 case HtmlOptionId::VSPACE:
770 aSpace.setHeight( static_cast<tools::Long>(rOption.
GetNumber()) );
772 case HtmlOptionId::BORDER:
775 case HtmlOptionId::SDONCLICK:
776 case HtmlOptionId::ONCLICK:
777 case HtmlOptionId::SDONMOUSEOVER:
778 case HtmlOptionId::ONMOUSEOVER:
779 case HtmlOptionId::SDONMOUSEOUT:
780 case HtmlOptionId::ONMOUSEOUT:
792 bool bIsApplet =
false;
794 if( !bDeclare && aClassID.getLength() == 42 &&
795 aClassID.startsWith(
"clsid:") )
797 aClassID = aClassID.copy(6);
799 if( aCID.
MakeId( aClassID ) )
801 SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
802 0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
804 bIsApplet = aJavaCID == aCID;
810 m_pAppletImpl.reset();
814 m_pAppletImpl->SetAltText( aStandBy );
816 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
818 if( HasStyleOptions( aStyle, aId, aClass ) )
819 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
821 SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
826 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
830 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
831 SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
837 #if HAVE_FEATURE_JAVA
840 if( !m_pAppletImpl->CreateApplet( m_sBaseURL ) )
843 m_pAppletImpl->FinishApplet();
847 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
849 &m_pAppletImpl->GetItemSet() );
855 pNoTextNd->
SetTitle( m_pAppletImpl->GetAltText() );
858 RegisterFlyFrame( pFlyFormat );
860 m_pAppletImpl.reset();
866 #if HAVE_FEATURE_JAVA
867 void SwHTMLParser::InsertApplet()
869 OUString aCodeBase, aCode,
aName, aAlt, aId, aStyle, aClass;
870 Size aSize( USHRT_MAX, USHRT_MAX );
872 bool bPercentWidth =
false, bPercentHeight =
false, bMayScript =
false;
873 sal_Int16 eVertOri = text::VertOrientation::TOP;
877 m_pAppletImpl.reset(
new SwApplet_Impl( m_xDoc->GetAttrPool() ));
880 for (
size_t i = rHTMLOptions.size();
i; )
885 case HtmlOptionId::ID:
888 case HtmlOptionId::STYLE:
891 case HtmlOptionId::CLASS:
894 case HtmlOptionId::CODEBASE:
897 case HtmlOptionId::CODE:
900 case HtmlOptionId::NAME:
903 case HtmlOptionId::ALT:
906 case HtmlOptionId::ALIGN:
910 case HtmlOptionId::WIDTH:
911 bPercentWidth = (rOption.
GetString().indexOf(
'%') != -1);
912 aSize.setWidth( static_cast<tools::Long>(rOption.
GetNumber()) );
914 case HtmlOptionId::HEIGHT:
915 bPercentHeight = (rOption.
GetString().indexOf(
'%') != -1);
916 aSize.setHeight( static_cast<tools::Long>(rOption.
GetNumber()) );
918 case HtmlOptionId::HSPACE:
919 aSpace.setWidth( static_cast<tools::Long>(rOption.
GetNumber()) );
921 case HtmlOptionId::VSPACE:
922 aSpace.setHeight( static_cast<tools::Long>(rOption.
GetNumber()) );
924 case HtmlOptionId::MAYSCRIPT:
935 if( aCode.isEmpty() )
937 m_pAppletImpl.reset();
941 if ( !aCodeBase.isEmpty() )
943 m_pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, m_sBaseURL );
944 m_pAppletImpl->SetAltText( aAlt );
946 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
948 if( HasStyleOptions( aStyle, aId, aClass ) )
949 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
951 SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
956 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
960 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
961 SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
967 #if HAVE_FEATURE_JAVA
971 m_pAppletImpl->FinishApplet();
975 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
977 &m_pAppletImpl->GetItemSet());
983 pNoTextNd->
SetTitle( m_pAppletImpl->GetAltText() );
986 RegisterFlyFrame( pFlyFormat );
988 m_pAppletImpl.reset();
996 #if HAVE_FEATURE_JAVA
1000 OUString aName, aValue;
1003 for (
size_t i = rHTMLOptions.size();
i; )
1008 case HtmlOptionId::NAME:
1011 case HtmlOptionId::VALUE:
1018 if( aName.isEmpty() )
1021 m_pAppletImpl->AppendParam( aName, aValue );
1029 OUString aAlt, aId, aStyle, aClass;
1030 Size aSize( USHRT_MAX, USHRT_MAX );
1031 Size aSpace( 0, 0 );
1032 bool bPercentWidth =
false, bPercentHeight =
false;
1033 sal_Int16 eVertOri = text::VertOrientation::TOP;
1039 for (
const auto & rOption : rHTMLOptions)
1043 case HtmlOptionId::ID:
1046 case HtmlOptionId::STYLE:
1049 case HtmlOptionId::CLASS:
1052 case HtmlOptionId::ALT:
1055 case HtmlOptionId::ALIGN:
1059 case HtmlOptionId::WIDTH:
1060 bPercentWidth = (rOption.
GetString().indexOf(
'%') != -1);
1063 case HtmlOptionId::HEIGHT:
1064 bPercentHeight = (rOption.
GetString().indexOf(
'%') != -1);
1067 case HtmlOptionId::HSPACE:
1070 case HtmlOptionId::VSPACE:
1092 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1095 const OUString& aName = aFrameDesc.
GetName();
1101 xSet->setPropertyValue(
"FrameName",
uno::Any( aName ) );
1103 if ( eScroll == ScrollingMode::Auto )
1104 xSet->setPropertyValue(
"FrameIsAutoScroll",
1107 xSet->setPropertyValue(
"FrameIsScrollingMode",
1108 uno::Any( eScroll == ScrollingMode::Yes ) );
1110 xSet->setPropertyValue(
"FrameIsBorder",
1113 xSet->setPropertyValue(
"FrameMarginWidth",
1116 xSet->setPropertyValue(
"FrameMarginHeight",
1121 catch ( uno::Exception& )
1125 SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
1127 if( HasStyleOptions( aStyle, aId, aClass ) )
1128 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
1136 SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, aFrameSet );
1140 SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, aFrameSet );
1141 SetSpace( aSpace, aItemSet, aPropInfo, aFrameSet );
1145 m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
1156 RegisterFlyFrame( pFlyFormat );
1158 m_bInFloatingFrame =
true;
1160 ++m_nFloatingFrames;
1169 uno::Reference < embed::XClassifiedObject > xClass = rObj.
GetOleRef();
1179 #if HAVE_FEATURE_JAVA
1186 return static_cast< sal_uInt16
>(eType);
1198 OSL_ENSURE( pOLENd,
"OLE-Node expected" );
1204 uno::Reference < embed::XEmbeddedObject > xObj( rObj.
GetOleRef() );
1208 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1209 bool bHiddenEmbed =
false;
1213 OSL_FAIL(
"Unknown Object" );
1223 if( !rFrameFormat.
GetName().isEmpty() )
1237 aAny = xSet->getPropertyValue(
"PluginURL");
1238 if( (aAny >>= aStr) && !aStr.isEmpty() )
1244 if( !aURL.isEmpty() )
1253 aAny = xSet->getPropertyValue(
"PluginMimeType");
1254 if( (aAny >>= aType) && !aType.isEmpty() )
1268 bHiddenEmbed =
true;
1284 aAny = xSet->getPropertyValue(
"AppletCodeBase");
1285 if( (aAny >>= aCd) && !aCd.isEmpty() )
1288 if( !sCodeBase.isEmpty() )
1299 aAny = xSet->getPropertyValue(
"AppletCode");
1307 OUString aAppletName;
1308 aAny = xSet->getPropertyValue(
"AppletName");
1309 aAny >>= aAppletName;
1310 if( !aAppletName.isEmpty() )
1318 bool bScript =
false;
1319 aAny = xSet->getPropertyValue(
"AppletIsScript");
1355 uno::Sequence < beans::PropertyValue > aProps;
1356 aAny = xSet->getPropertyValue(
"AppletCommands");
1361 std::vector<sal_uLong> aParams;
1362 size_t i = aCommands.
size();
1365 const SvCommand& rCommand = aCommands[ --i ];
1366 const OUString& rName = rCommand.
GetCommand();
1378 aParams.push_back( i );
1386 size_t ii = aParams.size();
1389 const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1390 const OUString& rName = rCommand.
GetCommand();
1405 if( aCommands.
size() )
1413 uno::Sequence < beans::PropertyValue > aProps;
1414 aAny = xSet->getPropertyValue(
"PluginCommands");
1419 for(
size_t i = 0;
i < aCommands.
size();
i++ )
1422 const OUString& rName = rCommand.
GetCommand();
1443 if( !aEndTags.isEmpty() )
1458 OSL_ENSURE( pOLENd,
"OLE-Node expected" );
1467 uno::Reference<document::XEmbeddedObjectSupplier2> xEmbeddedObjectSupplier(xTextContent, uno::UNO_QUERY);
1468 uno::Reference<frame::XStorable> xStorable(xEmbeddedObjectSupplier->getEmbeddedObject(), uno::UNO_QUERY);
1469 SAL_WARN_IF(!xStorable.is(),
"sw.html",
"OutHTML_FrameFormatOLENodeGrf: no embedded object");
1472 uno::Reference<lang::XServiceInfo> xServiceInfo(xStorable, uno::UNO_QUERY);
1474 if (xServiceInfo.is())
1476 if (xServiceInfo->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
1477 aFilter =
"HTML (StarCalc)";
1478 else if (xServiceInfo->supportsService(
"com.sun.star.text.TextDocument"))
1479 aFilter =
"HTML (StarWriter)";
1482 if (xStorable.is() && !aFilter.isEmpty())
1490 aMediaDescriptor[
"FilterName"] <<= aFilter;
1491 aMediaDescriptor[
"FilterOptions"] <<= OUString(
"SkipHeaderFooter");
1492 aMediaDescriptor[
"OutputStream"] <<= xOutputStream;
1493 xStorable->storeToURL(
"private:stream", aMediaDescriptor.getAsConstPropertyValueList());
1495 OString
aData(static_cast<const char*>(aStream.
GetData()), static_cast<sal_Int32>(aStream.
GetSize()));
1501 catch ( uno::Exception& )
1511 SAL_WARN(
"sw.html",
"Unexpected missing OLE fallback graphic");
1518 bool bObjectOpened =
false;
1519 OUString aRTFType =
"text/rtf";
1525 if (rHTMLWrt.
mbXHTML && pDocSh)
1531 OUString aFileName = lcl_CalculateFileName(rHTMLWrt.
GetOrigFileName(), aGraphic,
u"ole");
1535 uno::Reference<embed::XEmbeddedObject> xEmbeddedObject = rOLEObj.
GetOleRef();
1538 uno::Reference<io::XActiveDataStreamer> xStreamProvider;
1539 uno::Reference<embed::XEmbedPersist2> xOwnEmbedded;
1540 if (xEmbeddedObject.is())
1542 xStreamProvider.set(xEmbeddedObject, uno::UNO_QUERY);
1543 xOwnEmbedded.set(xEmbeddedObject, uno::UNO_QUERY);
1545 if (xStreamProvider.is())
1548 uno::Reference<io::XInputStream>
xStream(xStreamProvider->getStream(), uno::UNO_QUERY);
1555 aFileType = aRTFType;
1559 else if (xOwnEmbedded.is())
1574 aFileType = aRTFType;
1580 const OUString& aStreamName = rOLEObj.GetCurrentPersistName();
1581 uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
1582 uno::Reference<io::XStream> xInStream;
1586 xInStream = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
1587 }
catch (
const uno::Exception&)
1589 TOOLS_WARN_EXCEPTION(
"sw.html",
"OutHTML_FrameFormatOLENodeGrf: failed to open stream element");
1595 xOutStream->getOutputStream());
1598 uno::Reference<beans::XPropertySet> xOutStreamProps(xInStream, uno::UNO_QUERY);
1599 if (xOutStreamProps.is())
1600 xOutStreamProps->getPropertyValue(
"MediaType") >>= aFileType;
1601 if (!aRTFType.isEmpty())
1603 aFileType = aRTFType;
1612 rWrt.
Strm().
WriteOString(OStringConcatenation(
" data=\"" + aFileName.toUtf8() +
"\""));
1613 if (!aFileType.isEmpty())
1614 rWrt.
Strm().
WriteOString(OStringConcatenation(
" type=\"" + aFileType.toUtf8() +
"\""));
1616 bObjectOpened =
true;
1620 OUString aGraphicURL;
1626 aGraphicURL = *pTempFileName;
1628 OUString aFilterName(
"JPG");
1629 XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
1633 aFilterName =
"PNG";
1634 nFlags = XOutFlags::NONE;
1635 aMimeType =
"image/png";
1637 if (aGraphic.GetType() == GraphicType::NONE)
1640 aGraphicURL = lcl_CalculateFileName(rHTMLWrt.
GetOrigFileName(), aGraphic,
u"png");
1641 osl::File aFile(aGraphicURL);
1642 aFile.open(osl_File_OpenFlag_Create);
1667 nFlags,
"ole",
nullptr, aMimeType );
#define OOO_STRING_SVTOOLS_HTML_O_src
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
static SwHtmlOptType GetOptionType(const OUString &rName, bool bApplet)
static void SetSpace(const Size &rPixSpace, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFlyItemSet)
const char *const aClassID
const HtmlFrmOpts HTML_FRMOPTS_IFRAME
const OUString & GetBaseURL() const
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
#define OOO_STRING_SW_HTML_O_Hidden
const OUString & GetName() const
HtmlOptionId GetToken() const
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
bool mbXHTML
If XHTML markup should be written instead of HTML.
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool WrapOleInRtf(SvStream &rOle2, SvStream &rRtf, SwOLENode &rOLENode, const SwFrameFormat &rFormat)
Wraps an OLE2 container binary in an RTF fragment.
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
void setWidth(tools::Long nWidth)
#define HTML_DFLT_APPLET_HEIGHT
const SwOLEObj & GetOLEObj() const
SwDocShell * GetDocShell()
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
BitmapChecksum GetChecksum() const
#define HTML_DFLT_EMBED_HEIGHT
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const HtmlFrmOpts HTML_FRMOPTS_EMBED
const HtmlFrmOpts HTML_FRMOPTS_HIDDEN_EMBED
#define SO3_IFRAME_CLASSID
Writer & OutHTML_FrameFormatOLENodeGrf(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
tools::Long GetRight() const
void SetTitle(const OUString &rTitle)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
const OUString & GetString() const
constexpr sal_uInt16 RES_FRMATR_END(133)
#define OOO_STRING_SVTOOLS_HTML_iframe
Writer & OutHTML_ImageEnd(HtmlWriter &rHtml, Writer &rWrt)
sal_uInt64 Seek(sal_uInt64 nPos)
Content, content of frame (header, footer, fly).
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, std::string_view rStr, bool bOn=true)
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
SvStream & WriteCharPtr(const char *pBuf)
OString maNamespace
XML namespace, in case of XHTML.
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
void OutNewLine(bool bCheck=false)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
SvxCSS1LengthType m_eHeightType
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
Sequence< PropertyValue > aArguments
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
#define HTML_DFLT_APPLET_WIDTH
void SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &)
#define WARN_SWG_POOR_LOAD
svt::EmbeddedObjectRef & GetObject()
#define OOO_STRING_SVTOOLS_HTML_O_mayscript
void FillSequence(css::uno::Sequence< css::beans::PropertyValue > &) const
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)
SwNodeOffset GetIndex() const
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
OUString CreateUniqueObjectName()
#define OOO_STRING_SVTOOLS_HTML_O_code
static OUString StripQueryFromPath(const OUString &rBase, const OUString &rPath)
Strips query and fragment from a URL path if base URL is a file:// one.
bool IsHTMLMode(sal_uInt32 nMode) const
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
constexpr OUStringLiteral aData
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
#define TOOLS_WARN_EXCEPTION(area, stream)
The graphic frame is a replacement image of an OLE object.
const OUString & GetArgument() const
void FillFromSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
void InsertFloatingFrame()
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
const HtmlFrmOpts HTML_FRMOPTS_OLE_CSS1
const INetURLObject & GetURL() const
const Graphic * GetGraphic()
bool MakeId(std::u16string_view rId)
tools::Long GetLeft() const
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void Append(const OUString &rCommand, const OUString &rArg)
#define OOO_STRING_SVTOOLS_HTML_O_name
#define OOO_STRING_SVTOOLS_HTML_embed
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
SwNodes & GetNodes()
Node is in which nodes-array/doc?
const HtmlFrmOpts HTML_FRMOPTS_APPLET
#define SO3_APPLET_CLASSID
virtual Size GetTwipSize() const override
static void Out_FrameDescriptor(SvStream &, const OUString &rBaseURL, const css::uno::Reference< css::beans::XPropertySet > &xSet, OUString *pNonConvertableChars=nullptr)
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Frame cannot be moved in Var-direction.
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
const HtmlFrmOpts HTML_FRMOPTS_APPLET_CNTNR
HTMLOptionEnum< sal_Int16 > const aHTMLImgVAlignTable[]
sal_uInt32 GetNumber() const
bool HasFrameBorder() const
bool setBase(std::u16string_view rTheBase, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SwNodeIndex * GetContentIdx() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
OUString m_aRTFOLEMimeType
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
const OUString & GetCommand() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define OOO_STRING_SVTOOLS_HTML_O_codebase
const Size & GetMargin() const
const HtmlFrmOpts HTML_FRMOPTS_APPLET_ALL
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_ALL
#define OOO_STRING_SVTOOLS_HTML_applet
SvxCSS1LengthType m_eWidthType
ScrollingMode GetScrollingMode() const
#define HTMLMODE_ABS_POS_FLY
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, OUString *pNonConvertableChars=nullptr)
#define HTML_DFLT_EMBED_WIDTH
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
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)
#define SAL_WARN_IF(condition, area, stream)
SvStream & WriteOString(std::string_view rStr)
constexpr tools::Long Height() const
OUString GetTitle() const
void ExportOLEObject(svt::EmbeddedObjectRef const &rObj, SotStorage &rDestStg)
::std::vector< HTMLOption > HTMLOptions
COMPHELPER_DLLPUBLIC bool isFileUrl(OUString const &url)
bool ExtractOleFromRtf(SvStream &rRtf, SvStream &rOle, bool &bOwnFormat)
Extracts an OLE2 container binary from an RTF fragment.
const OUString * GetOrigFileName() const
void SetGraphic(const Graphic &rGraphic, const OUString &rMediaType)
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
#define OOO_STRING_SVTOOLS_HTML_param
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
SvStream & WriteChar(char nChar)
const OUString & GetTokenString() const
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
#define OOO_STRING_SVTOOLS_HTML_O_value
void setHeight(tools::Long nHeight)
#define OOO_STRING_SVTOOLS_HTML_O_type
static GraphicFilter & GetGraphicFilter()
const sal_Unicode *const aMimeType[]
#define SAL_WARN(area, stream)
void ParseFrameOptions(SfxFrameDescriptor *pFrame, const HTMLOptions &rOptions, std::u16string_view rBaseURL)
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
HTMLOptionEnum< sal_Int16 > const aHTMLImgHAlignTable[]
static css::uno::Reference< css::text::XTextContent > CreateXTextEmbeddedObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL
#define OOO_STRING_SVTOOLS_HTML_object
static sal_uInt16 GuessOLENodeFrameType(const SwNode &rNd)
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
#define OOO_STRING_SVTOOLS_HTML_span
#define SO3_PLUGIN_CLASSID
OString read_uInt8s_ToOString(SvStream &rStrm, std::size_t nLen)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
const HtmlFrmOpts HTML_FRMOPTS_EMBED_CNTNR
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_CNTNR
static void SetFixSize(const Size &rPixSize, const Size &rTwipDfltSize, bool bPercentWidth, bool bPercentHeight, SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet)
OString OutFrameFormatOptions(const SwFrameFormat &rFrameFormat, const OUString &rAltText, HtmlFrmOpts nFrameOpts)
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
Writer & OutHTML_FrameFormatOLENode(Writer &rWrt, const SwFrameFormat &rFrameFormat, bool bInCntnr)
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void OutCSS1_FrameFormatOptions(const SwFrameFormat &rFrameFormat, HtmlFrmOpts nFrameOpts, const SdrObject *pSdrObj=nullptr, const SfxItemSet *pItemSet=nullptr)
Base class of the Writer document model elements.