tdf#162563 Drop Applet and Plug-in object support in Writer filters

Change-Id: I3ddd4ed7629756506321edf51e747241b2d3e81d
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/3202
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 3abdb40559d69265100acf1b1c5c96596933c994)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205873
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Gabor Kelemen
2026-06-01 16:30:00 +02:00
committed by Xisco Fauli
parent 2961de8d41
commit ccbbb20630
15 changed files with 16 additions and 1311 deletions
@@ -6176,8 +6176,6 @@ sw/inc/sortopt.hxx:27
enum SwSortOrder Descending
sw/inc/sortopt.hxx:28
enum SwSortDirection Columns
sw/inc/SwAppletImpl.hxx:30
enum SwHtmlOptType IGNORE
sw/inc/swcrsr.hxx:65
enum SwCursorSkipMode Chars
sw/inc/swmodule.hxx:63
-2
View File
@@ -11595,7 +11595,6 @@ sw/inc/IDocumentRedlineAccess.hxx
sw/inc/IDocumentUndoRedo.hxx
sw/inc/IMark.hxx
sw/inc/PostItMgr.hxx
sw/inc/SwAppletImpl.hxx
sw/inc/SwStyleNameMapper.hxx
sw/inc/SwUndoField.hxx
sw/inc/SwXMLSectionList.hxx
@@ -12413,7 +12412,6 @@ sw/source/filter/basflt/fltshell.cxx
sw/source/filter/basflt/iodetect.cxx
sw/source/filter/basflt/shellio.cxx
sw/source/filter/docx/swdocxreader.cxx
sw/source/filter/html/SwAppletImpl.cxx
sw/source/filter/html/css1atr.cxx
sw/source/filter/html/htmlatr.cxx
sw/source/filter/html/htmlbas.cxx
-3
View File
@@ -527,9 +527,6 @@ excludelist:
sw/source/filter/basflt/iodetect.cxx:
# Actually used
- com/sun/star/embed/XStorage.hpp
sw/source/filter/html/SwAppletImpl.cxx:
# Needed for direct member access
- com/sun/star/embed/XEmbeddedObject.hpp
sw/source/filter/html/htmlfld.cxx:
# Needed for template
- com/sun/star/frame/XModel.hpp
-1
View File
@@ -545,7 +545,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/filter/basflt/fltshell \
sw/source/filter/basflt/iodetect \
sw/source/filter/basflt/shellio \
sw/source/filter/html/SwAppletImpl \
sw/source/filter/html/css1atr \
sw/source/filter/html/htmlatr \
sw/source/filter/html/htmlbas \
-64
View File
@@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <config_java.h>
#include <svl/itemset.hxx>
#include <svl/ownlist.hxx>
#include <utility>
namespace com::sun::star::embed { class XEmbeddedObject; }
enum class SwHtmlOptType {
IGNORE = 0,
TAG = 1,
PARAM = 2,
SIZE = 3
};
#define OOO_STRING_SW_HTML_O_Hidden "HIDDEN"
class SwApplet_Impl
{
css::uno::Reference < css::embed::XEmbeddedObject > m_xApplet;
SvCommandList m_aCommandList;
SfxItemSet m_aItemSet;
OUString m_sAlt;
public:
static SwHtmlOptType GetOptionType( std::u16string_view rName, bool bApplet );
SwApplet_Impl( SfxItemPool& rPool );
SwApplet_Impl( SfxItemSet aSet ): m_aItemSet (std::move(aSet)) {}
~SwApplet_Impl();
void CreateApplet( const OUString& rCode, const OUString& rName,
bool bMayScript, const OUString& rCodeBase,
std::u16string_view rBaseURL );
#if HAVE_FEATURE_JAVA
bool CreateApplet( std::u16string_view rBaseURL );
void AppendParam( const OUString& rName, const OUString& rValue );
#endif
void FinishApplet();
const css::uno::Reference < css::embed::XEmbeddedObject >& GetApplet() const { return m_xApplet; }
SfxItemSet& GetItemSet() { return m_aItemSet; }
const OUString& GetAltText() const { return m_sAlt; }
void SetAltText( const OUString& rAlt ) {m_sAlt = rAlt;}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-194
View File
@@ -1,194 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <SwAppletImpl.hxx>
#include <svtools/htmlkywd.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <comphelper/embeddedobjectcontainer.hxx>
#include <comphelper/classids.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <o3tl/string_view.hxx>
#include <svtools/embedhlp.hxx>
#include <tools/globname.hxx>
#include <tools/urlobj.hxx>
#include <hintids.hxx>
using namespace com::sun::star;
SwHtmlOptType SwApplet_Impl::GetOptionType( std::u16string_view rName, bool bApplet )
{
SwHtmlOptType nType = bApplet ? SwHtmlOptType::PARAM : SwHtmlOptType::TAG;
switch( rName[0] )
{
case 'A':
case 'a':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_align ) ||
o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_alt ) )
nType = SwHtmlOptType::IGNORE;
else if( bApplet &&
(rName == u"ARCHIVE" || rName == u"ARCHIVES" ) )
nType = SwHtmlOptType::TAG;
break;
case 'C':
case 'c':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_class ) ||
(bApplet && (o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_code ) ||
o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
nType = SwHtmlOptType::IGNORE;
break;
case 'H':
case 'h':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_height ) )
nType = SwHtmlOptType::SIZE;
else if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
(!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SW_HTML_O_Hidden )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'I':
case 'i':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_id ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'M':
case 'm':
if( bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'N':
case 'n':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_name ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'O':
case 'o':
if( bApplet && rName == u"OBJECT" )
nType = SwHtmlOptType::TAG;
break;
case 'S':
case 's':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_style ) ||
(!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_src )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'T':
case 't':
if( !bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_type ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'V':
case 'v':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_vspace ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'W':
case 'w':
if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_width ) )
nType = SwHtmlOptType::SIZE;
break;
}
return nType;
}
SwApplet_Impl::SwApplet_Impl( SfxItemPool& rPool ) :
m_aItemSet( rPool, svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1> )
{
}
void SwApplet_Impl::CreateApplet( const OUString& rCode, const OUString& rName,
bool bMayScript, const OUString& rCodeBase,
std::u16string_view rDocumentBaseURL )
{
comphelper::EmbeddedObjectContainer aCnt;
OUString aName;
// create Applet; it will be in running state
m_xApplet = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_APPLET_CLASSID ).GetByteSequence(), aName );
(void)::svt::EmbeddedObjectRef::TryRunningState( m_xApplet );
INetURLObject aUrlBase(rDocumentBaseURL);
aUrlBase.removeSegment();
OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::DecodeMechanism::NONE);
uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
xSet->setPropertyValue(u"AppletCode"_ustr, uno::Any( rCode ) );
xSet->setPropertyValue(u"AppletName"_ustr, uno::Any( rName ) );
xSet->setPropertyValue(u"AppletIsScript"_ustr, uno::Any( bMayScript ) );
xSet->setPropertyValue(u"AppletDocBase"_ustr, uno::Any( sDocBase ) );
if ( !rCodeBase.isEmpty() )
xSet->setPropertyValue(u"AppletCodeBase"_ustr, uno::Any( rCodeBase ) );
else
xSet->setPropertyValue(u"AppletCodeBase"_ustr, uno::Any( sDocBase ) );
}
}
#if HAVE_FEATURE_JAVA
bool SwApplet_Impl::CreateApplet( std::u16string_view rBaseURL )
{
OUString aCode, aName, aCodeBase;
bool bMayScript = false;
size_t nArgCount = m_aCommandList.size();
for( size_t i = 0; i < nArgCount; i++ )
{
const SvCommand& rArg = m_aCommandList[i];
const OUString& rName = rArg.GetCommand();
if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) )
aCode = rArg.GetArgument();
else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ) )
aCodeBase = INetURLObject::GetAbsURL( rBaseURL, rArg.GetArgument() );
else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
aName = rArg.GetArgument();
else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
bMayScript = true;
}
if( aCode.isEmpty() )
return false;
CreateApplet( aCode, aName, bMayScript, aCodeBase, rBaseURL );
return true;
}
#endif
SwApplet_Impl::~SwApplet_Impl()
{
}
void SwApplet_Impl::FinishApplet()
{
uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
uno::Sequence < beans::PropertyValue > aProps;
m_aCommandList.FillSequence( aProps );
xSet->setPropertyValue(u"AppletCommands"_ustr, uno::Any( aProps ) );
}
}
#if HAVE_FEATURE_JAVA
void SwApplet_Impl::AppendParam( const OUString& rName, const OUString& rValue )
{
m_aCommandList.Append( rName, rValue );
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-2
View File
@@ -38,8 +38,6 @@ enum SwHTMLFrameType
HTML_FRMTYPE_EMPTY,
HTML_FRMTYPE_TEXT,
HTML_FRMTYPE_GRF,
HTML_FRMTYPE_PLUGIN,
HTML_FRMTYPE_APPLET,
HTML_FRMTYPE_IFRAME,
HTML_FRMTYPE_OLE,
HTML_FRMTYPE_MARQUEE,
-60
View File
@@ -61,18 +61,6 @@ constexpr AllHtmlFlags aHTMLOutFramePageFlyTable[][MAX_BROWSERS] =
{ HtmlOut::GraphicNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::GraphicNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// plug-in
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// applet
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::Span } // Netscape 4
},
{
// floating frame
{ HtmlOut::OleNode, HtmlPosition::Prefix, HtmlContainerFlags::NONE }, // IE 4
@@ -153,18 +141,6 @@ constexpr AllHtmlFlags aHTMLOutFrameParaFrameTable[][MAX_BROWSERS] =
{ HtmlOut::GraphicNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::GraphicNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
{ HtmlOut::OleNode, HtmlPosition::Before, HtmlContainerFlags::NONE }, // IE 4
@@ -246,18 +222,6 @@ constexpr AllHtmlFlags aHTMLOutFrameParaPrtAreaTable[][MAX_BROWSERS] =
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
@@ -338,18 +302,6 @@ constexpr AllHtmlFlags aHTMLOutFrameParaOtherTable[][MAX_BROWSERS] =
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// plug-in
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// applet
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::Span } // Netscape 4
},
{
// floating frame
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
@@ -430,18 +382,6 @@ constexpr AllHtmlFlags aHTMLOutFrameAsCharTable[][MAX_BROWSERS] =
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::GraphicNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// plug-in
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// applet
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // SW
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE } // Netscape 4
},
{
// floating frame
{ HtmlOut::OleNode, HtmlPosition::Inside, HtmlContainerFlags::NONE }, // IE 4
+11 -594
View File
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_java.h>
#include <hintids.hxx>
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
@@ -37,7 +35,6 @@
#include <tools/globname.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <IDocumentContentOperations.hxx>
#include <SwAppletImpl.hxx>
#include <fmtornt.hxx>
#include <fmtfsize.hxx>
#include <fmtsrnd.hxx>
@@ -91,36 +88,6 @@ using namespace com::sun::star;
#define HTML_DFLT_APPLET_WIDTH (o3tl::toTwips(125, o3tl::Length::mm10))
#define HTML_DFLT_APPLET_HEIGHT (o3tl::toTwips(125, o3tl::Length::mm10))
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL =
HtmlFrmOpts::Alt |
HtmlFrmOpts::Size |
HtmlFrmOpts::Name;
const HtmlFrmOpts HTML_FRMOPTS_EMBED_CNTNR =
HTML_FRMOPTS_EMBED_ALL |
HtmlFrmOpts::AbsSize;
const HtmlFrmOpts HTML_FRMOPTS_EMBED =
HTML_FRMOPTS_EMBED_ALL |
HtmlFrmOpts::Align |
HtmlFrmOpts::Space |
HtmlFrmOpts::BrClear |
HtmlFrmOpts::Name;
const HtmlFrmOpts HTML_FRMOPTS_HIDDEN_EMBED =
HtmlFrmOpts::Alt |
HtmlFrmOpts::Name;
const HtmlFrmOpts HTML_FRMOPTS_APPLET_ALL =
HtmlFrmOpts::Alt |
HtmlFrmOpts::Size;
const HtmlFrmOpts HTML_FRMOPTS_APPLET_CNTNR =
HTML_FRMOPTS_APPLET_ALL |
HtmlFrmOpts::AbsSize;
const HtmlFrmOpts HTML_FRMOPTS_APPLET =
HTML_FRMOPTS_APPLET_ALL |
HtmlFrmOpts::Align |
HtmlFrmOpts::Space |
HtmlFrmOpts::BrClear;
const HtmlFrmOpts HTML_FRMOPTS_IFRAME_ALL =
HtmlFrmOpts::Alt |
HtmlFrmOpts::Size;
@@ -417,7 +384,7 @@ bool SwHTMLParser::InsertEmbed()
break;
case HtmlOptionId::UNKNOWN:
if (rOption.GetTokenString().equalsIgnoreAsciiCase(
OOO_STRING_SW_HTML_O_Hidden))
"HIDDEN"))
{
bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
"FALSE");
@@ -544,27 +511,7 @@ bool SwHTMLParser::InsertEmbed()
comphelper::EmbeddedObjectContainer aCnt;
OUString aObjName;
uno::Reference < embed::XEmbeddedObject > xObj;
if (!bHasData)
{
xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
{
uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
if( bHasURL )
xSet->setPropertyValue(u"PluginURL"_ustr, uno::Any( aURL ) );
if( bHasType )
xSet->setPropertyValue(u"PluginMimeType"_ustr, uno::Any( aType ) );
uno::Sequence < beans::PropertyValue > aProps;
aCmdLst.FillSequence( aProps );
xSet->setPropertyValue(u"PluginCommands"_ustr, uno::Any( aProps ) );
}
}
}
else if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
if (SwDocShell* pDocSh = m_xDoc->GetDocShell())
{
// Has non-empty data attribute in XHTML: map that to an OLE object.
uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
@@ -719,333 +666,6 @@ bool SwHTMLParser::InsertEmbed()
return true;
}
#if HAVE_FEATURE_JAVA
void SwHTMLParser::NewObject()
{
OUString aClassID;
OUString aStandBy, aId, aStyle, aClass;
Size aSize( USHRT_MAX, USHRT_MAX );
Size aSpace( 0, 0 );
sal_Int16 eVertOri = text::VertOrientation::TOP;
sal_Int16 eHoriOri = text::HoriOrientation::NONE;
bool bPercentWidth = false, bPercentHeight = false,
bDeclare = false;
// create a new Command list
m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
const HTMLOptions& rHTMLOptions = GetOptions();
for (size_t i = rHTMLOptions.size(); i; )
{
const HTMLOption& rOption = rHTMLOptions[--i];
switch( rOption.GetToken() )
{
case HtmlOptionId::ID:
aId = rOption.GetString();
break;
case HtmlOptionId::STYLE:
aStyle = rOption.GetString();
break;
case HtmlOptionId::CLASS:
aClass = rOption.GetString();
break;
case HtmlOptionId::DECLARE:
bDeclare = true;
break;
case HtmlOptionId::CLASSID:
aClassID = rOption.GetString();
break;
case HtmlOptionId::CODEBASE:
break;
case HtmlOptionId::DATA:
break;
case HtmlOptionId::TYPE:
break;
case HtmlOptionId::CODETYPE:
break;
case HtmlOptionId::ARCHIVE:
case HtmlOptionId::UNKNOWN:
break;
case HtmlOptionId::STANDBY:
aStandBy = rOption.GetString();
break;
case HtmlOptionId::WIDTH:
bPercentWidth = (rOption.GetString().indexOf('%') != -1);
aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::HEIGHT:
bPercentHeight = (rOption.GetString().indexOf('%') != -1);
aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::ALIGN:
eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
break;
case HtmlOptionId::USEMAP:
break;
case HtmlOptionId::NAME:
break;
case HtmlOptionId::HSPACE:
aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::VSPACE:
aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::BORDER:
break;
case HtmlOptionId::SDONCLICK:
case HtmlOptionId::ONCLICK:
case HtmlOptionId::SDONMOUSEOVER:
case HtmlOptionId::ONMOUSEOVER:
case HtmlOptionId::SDONMOUSEOUT:
case HtmlOptionId::ONMOUSEOUT:
break;
default: break;
}
// All parameters are passed to the applet.
m_pAppletImpl->AppendParam( rOption.GetTokenString(),
rOption.GetString() );
}
// Objects that are declared only are not evaluated. Moreover, only
// Java applets are supported.
bool bIsApplet = false;
if( !bDeclare && aClassID.getLength() == 42 &&
aClassID.startsWith("clsid:") )
{
aClassID = aClassID.copy(6);
SvGlobalName aCID;
if( aCID.MakeId( aClassID ) )
{
SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
bIsApplet = aJavaCID == aCID;
}
}
if( !bIsApplet )
{
m_pAppletImpl.reset();
return;
}
m_pAppletImpl->SetAltText( aStandBy );
SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
SvxCSS1PropertyInfo aPropInfo;
if( HasStyleOptions( aStyle, aId, aClass ) )
(void)ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( rFrameSet );
// set the anchor and the adjustment
SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
// and still the size of the frame
Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
}
#endif
void SwHTMLParser::EndObject()
{
#if HAVE_FEATURE_JAVA
if( !m_pAppletImpl )
return;
if( !m_pAppletImpl->CreateApplet( m_sBaseURL ) )
return;
m_pAppletImpl->FinishApplet();
// and insert into the document
SwFrameFormat* pFlyFormat =
m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
&m_pAppletImpl->GetItemSet() );
// set the alternative name
SwNoTextNode *pNoTextNd =
m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
->GetIndex()+1 ]->GetNoTextNode();
pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
// if applicable create frames and register auto-bound frames
RegisterFlyFrame( pFlyFormat );
m_pAppletImpl.reset();
#else
(void) this; // Silence loplugin:staticmethods
#endif
}
#if HAVE_FEATURE_JAVA
void SwHTMLParser::InsertApplet()
{
OUString aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
Size aSize( USHRT_MAX, USHRT_MAX );
Size aSpace( 0, 0 );
bool bPercentWidth = false, bPercentHeight = false, bMayScript = false;
sal_Int16 eVertOri = text::VertOrientation::TOP;
sal_Int16 eHoriOri = text::HoriOrientation::NONE;
// create a new Command list
m_pAppletImpl.reset(new SwApplet_Impl( m_xDoc->GetAttrPool() ));
const HTMLOptions& rHTMLOptions = GetOptions();
for (size_t i = rHTMLOptions.size(); i; )
{
const HTMLOption& rOption = rHTMLOptions[--i];
switch( rOption.GetToken() )
{
case HtmlOptionId::ID:
aId = rOption.GetString();
break;
case HtmlOptionId::STYLE:
aStyle = rOption.GetString();
break;
case HtmlOptionId::CLASS:
aClass = rOption.GetString();
break;
case HtmlOptionId::CODEBASE:
aCodeBase = rOption.GetString();
break;
case HtmlOptionId::CODE:
aCode = rOption.GetString();
break;
case HtmlOptionId::NAME:
aName = rOption.GetString();
break;
case HtmlOptionId::ALT:
aAlt = rOption.GetString();
break;
case HtmlOptionId::ALIGN:
eVertOri = rOption.GetEnum( aHTMLImgVAlignTable, eVertOri );
eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
break;
case HtmlOptionId::WIDTH:
bPercentWidth = (rOption.GetString().indexOf('%') != -1);
aSize.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::HEIGHT:
bPercentHeight = (rOption.GetString().indexOf('%') != -1);
aSize.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::HSPACE:
aSpace.setWidth( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::VSPACE:
aSpace.setHeight( static_cast<tools::Long>(rOption.GetNumber()) );
break;
case HtmlOptionId::MAYSCRIPT:
bMayScript = true;
break;
default: break;
}
// All parameters are passed to the applet.
m_pAppletImpl->AppendParam( rOption.GetTokenString(),
rOption.GetString() );
}
if( aCode.isEmpty() )
{
m_pAppletImpl.reset();
return;
}
if ( !aCodeBase.isEmpty() )
aCodeBase = INetURLObject::GetAbsURL( m_sBaseURL, aCodeBase );
m_pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, m_sBaseURL );//, aAlt );
m_pAppletImpl->SetAltText( aAlt );
SfxItemSet aItemSet( m_xDoc->GetAttrPool(), m_pCSS1Parser->GetWhichMap() );
SvxCSS1PropertyInfo aPropInfo;
if( HasStyleOptions( aStyle, aId, aClass ) )
(void)ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
SfxItemSet& rFrameSet = m_pAppletImpl->GetItemSet();
if( !IsNewDoc() )
Reader::ResetFrameFormatAttrs( rFrameSet );
// set the anchor and the adjustment
SetAnchorAndAdjustment( eVertOri, eHoriOri, aPropInfo, rFrameSet );
// and still the size or the frame
Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
SetFixSize( aSize, aDfltSz, bPercentWidth, bPercentHeight, aPropInfo, rFrameSet );
SetSpace( aSpace, aItemSet, aPropInfo, rFrameSet );
}
#endif
void SwHTMLParser::EndApplet()
{
#if HAVE_FEATURE_JAVA
if( !m_pAppletImpl )
return;
m_pAppletImpl->FinishApplet();
// and insert into the document
SwFrameFormat* pFlyFormat =
m_xDoc->getIDocumentContentOperations().InsertEmbObject(*m_pPam,
::svt::EmbeddedObjectRef( m_pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
&m_pAppletImpl->GetItemSet());
// set the alternative name
SwNoTextNode *pNoTextNd =
m_xDoc->GetNodes()[ pFlyFormat->GetContent().GetContentIdx()
->GetIndex()+1 ]->GetNoTextNode();
pNoTextNd->SetTitle( m_pAppletImpl->GetAltText() );
// if applicable create frames and register auto-bound frames
RegisterFlyFrame( pFlyFormat );
m_pAppletImpl.reset();
#else
(void) this;
#endif
}
void SwHTMLParser::InsertParam()
{
#if HAVE_FEATURE_JAVA
if( !m_pAppletImpl )
return;
OUString aName, aValue;
const HTMLOptions& rHTMLOptions = GetOptions();
for (size_t i = rHTMLOptions.size(); i; )
{
const HTMLOption& rOption = rHTMLOptions[--i];
switch( rOption.GetToken() )
{
case HtmlOptionId::NAME:
aName = rOption.GetString();
break;
case HtmlOptionId::VALUE:
aValue = rOption.GetString();
break;
default: break;
}
}
if( aName.isEmpty() )
return;
m_pAppletImpl->AppendParam( aName, aValue );
#else
(void) this;
#endif
}
void SwHTMLParser::InsertFloatingFrame()
{
OUString aAlt, aId, aStyle, aClass;
@@ -1199,20 +819,10 @@ SwHTMLFrameType SwHTMLWriter::GuessOLENodeFrameType( const SwNode& rNode )
uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef();
SvGlobalName aClass( xClass->getClassID() );
if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
{
eType = HTML_FRMTYPE_PLUGIN;
}
else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
{
eType = HTML_FRMTYPE_IFRAME;
}
#if HAVE_FEATURE_JAVA
else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
{
eType = HTML_FRMTYPE_APPLET;
}
#endif
return eType;
}
@@ -1252,124 +862,18 @@ SwHTMLWriter& OutHTML_FrameFormatOLENode( SwHTMLWriter& rWrt, const SwFrameForma
if( !rFrameFormat.GetName().isEmpty() )
rWrt.OutImplicitMark( rFrameFormat.GetName().toString(),
"ole" );
uno::Any aAny;
SvGlobalName aGlobName( xObj->getClassID() );
OStringBuffer sOut("<");
if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
{
// first the plug-in specifics
sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_embed);
// or the Floating-Frame specifics
OUString aStr;
OUString aURL;
aAny = xSet->getPropertyValue(u"PluginURL"_ustr);
if( (aAny >>= aStr) && !aStr.isEmpty() )
{
aURL = rWrt.normalizeURL(aStr, false);
}
sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
if( !aURL.isEmpty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_src "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), aURL );
sOut.append('\"');
}
SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
xSet );
OUString aType;
aAny = xSet->getPropertyValue(u"PluginMimeType"_ustr);
if( (aAny >>= aType) && !aType.isEmpty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_type "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), aType );
sOut.append('\"');
}
if ((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) &&
css::text::WrapTextMode_THROUGH == rFrameFormat.GetSurround().GetSurround() )
{
// A HIDDEN plug-in
sOut.append(" " OOO_STRING_SW_HTML_O_Hidden);
nFrameOpts = HTML_FRMOPTS_HIDDEN_EMBED;
bHiddenEmbed = true;
}
else
{
nFrameOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
: HTML_FRMOPTS_EMBED;
}
}
else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
{
// or the applet specifics
sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet);
// CODEBASE
OUString aCd;
aAny = xSet->getPropertyValue(u"AppletCodeBase"_ustr);
if( (aAny >>= aCd) && !aCd.isEmpty() )
{
OUString sCodeBase(rWrt.normalizeURL(aCd, false));
if( !sCodeBase.isEmpty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_codebase "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase );
sOut.append('\"');
}
}
// CODE
OUString aClass;
aAny = xSet->getPropertyValue(u"AppletCode"_ustr);
aAny >>= aClass;
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_code "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), aClass );
sOut.append('\"');
// NAME
OUString aAppletName;
aAny = xSet->getPropertyValue(u"AppletName"_ustr);
aAny >>= aAppletName;
if( !aAppletName.isEmpty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName );
sOut.append('\"');
}
bool bScript = false;
aAny = xSet->getPropertyValue(u"AppletIsScript"_ustr);
aAny >>= bScript;
if( bScript )
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_mayscript);
nFrameOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
: HTML_FRMOPTS_APPLET;
}
else
{
// or the Floating-Frame specifics
sOut.append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_iframe);
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
xSet );
nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
: HTML_FRMOPTS_IFRAME;
}
nFrameOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
: HTML_FRMOPTS_IFRAME;
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
@@ -1381,93 +885,6 @@ SwHTMLWriter& OutHTML_FrameFormatOLENode( SwHTMLWriter& rWrt, const SwFrameForma
if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameOpts );
if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
{
// output the parameters of applets as separate tags
// and write a </APPLET>
uno::Sequence < beans::PropertyValue > aProps;
aAny = xSet->getPropertyValue(u"AppletCommands"_ustr);
aAny >>= aProps;
SvCommandList aCommands;
aCommands.FillFromSequence( aProps );
std::vector<sal_uLong> aParams;
size_t i = aCommands.size();
while( i > 0 )
{
const SvCommand& rCommand = aCommands[ --i ];
const OUString& rName = rCommand.GetCommand();
SwHtmlOptType nType = SwApplet_Impl::GetOptionType( rName, true );
if( SwHtmlOptType::TAG == nType )
{
const OUString& rValue = rCommand.GetArgument();
rWrt.Strm().WriteChar( ' ' );
HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
rWrt.Strm().WriteOString( "=\"" );
HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteChar( '\"' );
}
else if( SwHtmlOptType::PARAM == nType )
{
aParams.push_back( i );
}
}
rWrt.Strm().WriteChar( '>' );
rWrt.IncIndentLevel(); // indent the applet content
size_t ii = aParams.size();
while( ii > 0 )
{
const SvCommand& rCommand = aCommands[ aParams[--ii] ];
const OUString& rName = rCommand.GetCommand();
const OUString& rValue = rCommand.GetArgument();
rWrt.OutNewLine();
sOut.append(
"<" + rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_param
" " OOO_STRING_SVTOOLS_HTML_O_name
"=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
sOut.append("\" " OOO_STRING_SVTOOLS_HTML_O_value "=\"");
rWrt.Strm().WriteOString( sOut );
sOut.setLength(0);
HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteOString( "\">" );
}
rWrt.DecIndentLevel(); // indent the applet content
if( aCommands.size() )
rWrt.OutNewLine();
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_applet), false );
}
else if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
{
// write plug-ins parameters as options
uno::Sequence < beans::PropertyValue > aProps;
aAny = xSet->getPropertyValue(u"PluginCommands"_ustr);
aAny >>= aProps;
SvCommandList aCommands;
aCommands.FillFromSequence( aProps );
for( size_t i = 0; i < aCommands.size(); i++ )
{
const SvCommand& rCommand = aCommands[ i ];
const OUString& rName = rCommand.GetCommand();
if( SwApplet_Impl::GetOptionType( rName, false ) == SwHtmlOptType::TAG )
{
const OUString& rValue = rCommand.GetArgument();
rWrt.Strm().WriteChar( ' ' );
HTMLOutFuncs::Out_String( rWrt.Strm(), rName );
rWrt.Strm().WriteOString( "=\"" );
HTMLOutFuncs::Out_String( rWrt.Strm(), rValue ).WriteChar( '\"' );
}
}
rWrt.Strm().WriteChar( '>' );
}
else
{
// and for Floating-Frames just output another </IFRAME>
-45
View File
@@ -21,7 +21,6 @@
#include <algorithm>
#include <memory>
#include <config_java.h>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
@@ -112,7 +111,6 @@
#include "wrthtml.hxx"
#include <linkenum.hxx>
#include <breakit.hxx>
#include <SwAppletImpl.hxx>
#include <swdll.hxx>
#include <txatbase.hxx>
@@ -721,14 +719,6 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
InsertAttr( SwFormatField( aField ), false );
}
if( m_pAppletImpl )
{
if( m_pAppletImpl->GetApplet().is() )
EndApplet();
else
EndObject();
}
// maybe remove an existing LF after the last paragraph
if( IsNewDoc() )
bLFStripped = StripTrailingLF() > 0;
@@ -1157,30 +1147,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
return;
}
else if( m_pAppletImpl )
{
// in an applet only <PARAM> tags and the </APPLET> tag
// are of interest for us (for the moment)
// <SCRIPT> is ignored here (from Netscape)!
switch( nToken )
{
case HtmlTokenId::APPLET_OFF:
m_bCallNextToken = false;
EndApplet();
break;
case HtmlTokenId::OBJECT_OFF:
m_bCallNextToken = false;
EndObject();
break;
case HtmlTokenId::PARAM:
InsertParam();
break;
default: break;
}
return;
}
else if( m_bTextArea )
{
// in a TextArea everything up to </TEXTAREA> is inserted as text.
@@ -1469,10 +1435,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
InsertImage();
break;
}
#if HAVE_FEATURE_JAVA
NewObject();
m_bCallNextToken = m_pAppletImpl!=nullptr && m_xTable;
#endif
break;
case HtmlTokenId::OBJECT_OFF:
@@ -1480,13 +1442,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
m_aEmbeds.pop();
break;
case HtmlTokenId::APPLET_ON:
#if HAVE_FEATURE_JAVA
InsertApplet();
m_bCallNextToken = m_pAppletImpl!=nullptr && m_xTable;
#endif
break;
case HtmlTokenId::IFRAME_ON:
if (bFuzzing && m_nFloatingFrames > 64)
SAL_WARN("sw.html", "Not importing any more FloatingFrames for fuzzing performance");
+2 -17
View File
@@ -19,8 +19,6 @@
#ifndef INCLUDED_SW_SOURCE_FILTER_HTML_SWHTML_HXX
#define INCLUDED_SW_SOURCE_FILTER_HTML_SWHTML_HXX
#include <config_java.h>
#include <sfx2/sfxhtml.hxx>
#include <svl/listener.hxx>
#include <svl/macitem.hxx>
@@ -56,7 +54,6 @@ class SwStartNode;
class SwFormatColl;
class SwField;
class SwHTMLForm_Impl;
class SwApplet_Impl;
struct SwHTMLFootEndNote_Impl;
class HTMLTableCnts;
class SwNumRule;
@@ -400,8 +397,6 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
//onto them until parsing is done
std::vector<std::unique_ptr<SwTableBox>> m_aOrphanedTableBoxes;
std::unique_ptr<SwApplet_Impl> m_pAppletImpl; // current applet
std::unique_ptr<SwCSS1Parser> m_pCSS1Parser; // Style-Sheet-Parser
std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;
std::vector<SwPending> m_vPendingStack;
@@ -689,7 +684,7 @@ private:
// <SPACER>
void InsertSpacer();
// Inserting graphics, plug-ins and applets
// Inserting graphics
// search image maps and link with graphic nodes
ImageMap *FindImageMap( std::u16string_view rURL ) const;
@@ -731,20 +726,10 @@ private:
void GetDefaultScriptType( ScriptType& rType,
OUString& rTypeStr ) const;
// the actual insert methods for <IMG>, <EMBED>, <APPLET> and <PARAM>
// the actual insert methods for <IMG>, <EMBED> and <PARAM>
void InsertImage(); // htmlgrin.cxx
bool InsertEmbed(); // htmlplug.cxx
#if HAVE_FEATURE_JAVA
void NewObject(); // htmlplug.cxx
#endif
void EndObject(); // link CommandLine with applet (htmlplug.cxx)
#if HAVE_FEATURE_JAVA
void InsertApplet(); // htmlplug.cxx
#endif
void EndApplet(); // link CommandLine with applet (htmlplug.cxx)
void InsertParam(); // htmlplug.cxx
void InsertFloatingFrame();
// parse <BODY>-tag: set background graphic and background colour (htmlgrin.cxx)
+3 -134
View File
@@ -35,7 +35,6 @@
#include <unoframe.hxx>
#include "xmlexp.hxx"
#include "xmltexte.hxx"
#include <SwAppletImpl.hxx>
#include <ndindex.hxx>
#include <tools/mapunit.hxx>
@@ -58,8 +57,6 @@ enum SvEmbeddedObjectTypes
{
SV_EMBEDDED_OWN,
SV_EMBEDDED_OUTPLACE,
SV_EMBEDDED_APPLET,
SV_EMBEDDED_PLUGIN,
SV_EMBEDDED_FRAME
};
@@ -82,8 +79,6 @@ SwXMLTextParagraphExport::SwXMLTextParagraphExport(
SwXMLExport& rExp,
SvXMLAutoStylePoolP& _rAutoStylePool ) :
XMLTextParagraphExport( rExp, _rAutoStylePool ),
m_aAppletClassId( SO3_APPLET_CLASSID ),
m_aPluginClassId( SO3_PLUGIN_CLASSID ),
m_aIFrameClassId( SO3_IFRAME_CLASSID )
{
}
@@ -223,15 +218,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
SvGlobalName aClassId( rObjRef->getClassID() );
SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
if( m_aPluginClassId == aClassId )
{
nType = SV_EMBEDDED_PLUGIN;
}
else if( m_aAppletClassId == aClassId )
{
nType = SV_EMBEDDED_APPLET;
}
else if( m_aIFrameClassId == aClassId )
if( m_aIFrameClassId == aClassId )
{
nType = SV_EMBEDDED_FRAME;
}
@@ -243,7 +230,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
enum XMLTokenEnum eElementName = XML__UNKNOWN_;
SvXMLExport &rXMLExport = GetExport();
// First the stuff common to each of Applet/Plugin/Floating Frame
// First the stuff common to Floating Frame
OUString sStyle;
Any aAny;
if( rPropSetInfo->hasPropertyByName( gsFrameStyleName ) )
@@ -352,72 +339,6 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE
: XML_OBJECT;
break;
case SV_EMBEDDED_APPLET:
{
// It's an applet!
if( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
{
uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
OUString aStr;
Any aAny2 = xSet->getPropertyValue(u"AppletCodeBase"_ustr);
aAny2 >>= aStr;
if (!aStr.isEmpty() )
lcl_addURL(rXMLExport, aStr);
aAny2 = xSet->getPropertyValue(u"AppletName"_ustr);
aAny2 >>= aStr;
if (!aStr.isEmpty())
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
aAny2 = xSet->getPropertyValue(u"AppletCode"_ustr);
aAny2 >>= aStr;
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
bool bScript = false;
aAny2 = xSet->getPropertyValue(u"AppletIsScript"_ustr);
aAny2 >>= bScript;
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bScript ? XML_TRUE : XML_FALSE );
uno::Sequence < beans::PropertyValue > aProps;
aAny2 = xSet->getPropertyValue(u"AppletCommands"_ustr);
aAny2 >>= aProps;
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
if ( nType2 == SwHtmlOptType::TAG)
{
OUString aStr2;
aProp.Value >>= aStr2;
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, aProp.Name, aStr2);
}
}
eElementName = XML_APPLET;
}
}
break;
case SV_EMBEDDED_PLUGIN:
{
// It's a plugin!
if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
{
uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
OUString aStr;
Any aAny2 = xSet->getPropertyValue(u"PluginURL"_ustr);
aAny2 >>= aStr;
lcl_addURL( rXMLExport, aStr );
aAny2 = xSet->getPropertyValue(u"PluginMimeType"_ustr);
aAny2 >>= aStr;
if (!aStr.isEmpty())
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
eElementName = XML_PLUGIN;
}
}
break;
case SV_EMBEDDED_FRAME:
{
// It's a floating frame!
@@ -468,58 +389,6 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
rXMLExport.AddEmbeddedObjectAsBase64( sURL );
}
break;
case SV_EMBEDDED_APPLET:
{
if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
{
uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
uno::Sequence < beans::PropertyValue > aProps;
aAny = xSet->getPropertyValue(u"AppletCommands"_ustr);
aAny >>= aProps;
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
if (SwHtmlOptType::PARAM == nType2 || SwHtmlOptType::SIZE == nType2 )
{
OUString aStr;
aProp.Value >>= aStr;
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
}
}
}
}
break;
case SV_EMBEDDED_PLUGIN:
{
if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
{
uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
uno::Sequence < beans::PropertyValue > aProps;
aAny = xSet->getPropertyValue(u"PluginCommands"_ustr);
aAny >>= aProps;
sal_Int32 i = aProps.getLength();
while ( i > 0 )
{
const beans::PropertyValue& aProp = aProps[--i];
const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, false );
if ( nType2 == SwHtmlOptType::TAG)
{
OUString aStr;
aProp.Value >>= aStr;
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
}
}
}
}
break;
default:
break;
}
@@ -540,7 +409,7 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
GetExport().AddEmbeddedObjectAsBase64( sURL );
}
// Lastly the stuff common to each of Applet/Plugin/Floating Frame
// Lastly the stuff common to Floating Frame
exportEvents( rPropSet );
exportTitleAndDescription( rPropSet, rPropSetInfo ); // #i73249#
exportContour( rPropSet, rPropSetInfo );
-2
View File
@@ -39,8 +39,6 @@ namespace com::sun::star::style { class XStyle; }
class SwXMLTextParagraphExport : public XMLTextParagraphExport
{
const SvGlobalName m_aAppletClassId;
const SvGlobalName m_aPluginClassId;
const SvGlobalName m_aIFrameClassId;
// Collected autostyles for use in exportTextAutoStyles
-174
View File
@@ -53,7 +53,6 @@
#include "xmltexti.hxx"
#include "XMLRedlineImportHelper.hxx"
#include <xmloff/XMLFilterServiceNames.h>
#include <SwAppletImpl.hxx>
#include <ndole.hxx>
#include <docsh.hxx>
#include <sfx2/docfile.hxx>
@@ -603,125 +602,6 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
return xPropSet;
}
uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
const OUString &rName,
const OUString &rCode,
bool bMayScript,
const OUString& rHRef,
sal_Int32 nWidth, sal_Int32 nHeight )
{
// this method will modify the document directly -> lock SolarMutex
SolarMutexGuard aGuard;
OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
assert( pTextCursor && "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
SfxItemSet aItemSet(SfxItemSet::makeFixedSfxItemSet<RES_FRMATR_BEGIN, RES_FRMATR_END>( pDoc->GetAttrPool() ));
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
SwApplet_Impl aAppletImpl ( std::move(aItemSet) );
OUString sCodeBase;
if( !rHRef.isEmpty() )
sCodeBase = GetXMLImport().GetAbsoluteReference( rHRef );
aAppletImpl.CreateApplet ( rCode, rName, bMayScript, sCodeBase, GetXMLImport().GetDocumentBase() );
// set the size of the applet
lcl_setObjectVisualArea( aAppletImpl.GetApplet(),
embed::Aspects::MSOLE_CONTENT,
Size( nWidth, nHeight ),
MapUnit::Map100thMM );
SwFrameFormat *const pFrameFormat =
pDoc->getIDocumentContentOperations().InsertEmbObject( *pTextCursor->GetPaM(),
::svt::EmbeddedObjectRef(aAppletImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT),
&aAppletImpl.GetItemSet());
rtl::Reference<SwXTextEmbeddedObject> xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
*pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
// req for z-order
SwXFrame::GetOrCreateSdrObject(*static_cast<SwFlyFrameFormat*>(pFrameFormat));
}
return xPropSet;
}
uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
const OUString &rMimeType,
const OUString& rHRef,
sal_Int32 nWidth, sal_Int32 nHeight )
{
OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get());
assert( pTextCursor && "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
SfxItemSet aItemSet(SfxItemSet::makeFixedSfxItemSet<RES_FRMATR_BEGIN, RES_FRMATR_END>( pDoc->GetAttrPool() ));
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
// We'll need a (valid) URL, or we need a MIME type. If we don't have
// either, do not insert plugin and return early. Copy URL into URL object
// on the way.
INetURLObject aURLObj;
bool bValidURL = !rHRef.isEmpty() &&
aURLObj.SetURL( URIHelper::SmartRel2Abs( INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) );
bool bValidMimeType = !rMimeType.isEmpty();
if( !bValidURL && !bValidMimeType )
return nullptr;
rtl::Reference < SwXTextEmbeddedObject > xPropSet;
uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
try
{
// create object with desired ClassId
uno::Sequence < sal_Int8 > aClass( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence() );
uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() );
uno::Reference < embed::XEmbeddedObject > xObj( xFactory->createInstanceInitNew(
aClass, OUString(), xStorage, u"DummyName"_ustr,
uno::Sequence < beans::PropertyValue >() ), uno::UNO_QUERY );
// set size to the object
lcl_setObjectVisualArea( xObj,
embed::Aspects::MSOLE_CONTENT,
Size( nWidth, nHeight ),
MapUnit::Map100thMM );
if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
{
uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
if( bValidURL )
xSet->setPropertyValue(u"PluginURL"_ustr,
Any( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
if( bValidMimeType )
xSet->setPropertyValue(u"PluginMimeType"_ustr,
Any( rMimeType ) );
}
SwFrameFormat *const pFrameFormat =
pDoc->getIDocumentContentOperations().InsertEmbObject(
*pTextCursor->GetPaM(),
::svt::EmbeddedObjectRef(xObj, embed::Aspects::MSOLE_CONTENT),
&aItemSet);
xPropSet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
*pDoc, pFrameFormat);
if( pDoc->getIDocumentDrawModelAccess().GetDrawModel() )
{
SwXFrame::GetOrCreateSdrObject(*
static_cast<SwFlyFrameFormat*>(pFrameFormat)); // req for z-order
}
}
}
catch ( uno::Exception& )
{
}
return xPropSet;
}
uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFrame(
const OUString& rName,
const OUString& rHRef,
@@ -876,60 +756,6 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
return xPropSet;
}
void SwXMLTextImportHelper::endAppletOrPlugin(
const uno::Reference < XPropertySet > &rPropSet,
std::map < const OUString, OUString > &rParamMap)
{
// this method will modify the document directly -> lock SolarMutex
SolarMutexGuard aGuard;
SwXFrame* pFrame = dynamic_cast<SwXFrame*>(rPropSet.get());
assert(pFrame && "SwXFrame missing");
SwFrameFormat *pFrameFormat = pFrame->GetFrameFormat();
const SwFormatContent& rContent = pFrameFormat->GetContent();
const SwNodeIndex *pNdIdx = rContent.GetContentIdx();
SwOLENode *pOLENd = pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTextNode()->GetOLENode();
SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
uno::Reference < embed::XEmbeddedObject > xEmbObj( rOLEObj.GetOleRef() );
if ( !svt::EmbeddedObjectRef::TryRunningState( xEmbObj ) )
return;
uno::Reference < beans::XPropertySet > xSet( xEmbObj->getComponent(), uno::UNO_QUERY );
if ( !xSet.is() )
return;
const sal_Int32 nCount = rParamMap.size();
uno::Sequence< beans::PropertyValue > aCommandSequence( nCount );
std::transform(rParamMap.begin(), rParamMap.end(), aCommandSequence.getArray(),
[](const auto& rParam)
{
return beans::PropertyValue(/* Name */ rParam.first,
/* Handle */ -1,
/* Value */ uno::Any(rParam.second),
/* State */ beans::PropertyState_DIRECT_VALUE);
});
// unfortunately the names of the properties are depending on the object
OUString aParaName(u"AppletCommands"_ustr);
try
{
xSet->setPropertyValue( aParaName, Any( aCommandSequence ) );
}
catch ( uno::Exception& )
{
aParaName = "PluginCommands";
try
{
xSet->setPropertyValue( aParaName, Any( aCommandSequence ) );
}
catch ( uno::Exception& )
{
}
}
}
// redlining helper methods
// (override to provide the real implementation)
void SwXMLTextImportHelper::RedlineAdd(
-17
View File
@@ -57,19 +57,6 @@ public:
const OUString& rStyleName,
const OUString& rTableName,
sal_Int32 nWidth, sal_Int32 nHeight ) override;
virtual css::uno::Reference<css::beans::XPropertySet>
createAndInsertApplet(
const OUString &rName,
const OUString &rCode,
bool bMayScript,
const OUString& rHRef,
sal_Int32 nWidth, sal_Int32 nHeight ) override;
virtual css::uno::Reference<css::beans::XPropertySet>
createAndInsertPlugin(
const OUString &rMimeType,
const OUString& rHRef,
sal_Int32 nWidth, sal_Int32 nHeight ) override;
virtual css::uno::Reference<css::beans::XPropertySet>
createAndInsertFloatingFrame(
@@ -78,10 +65,6 @@ public:
const OUString &rStyleName,
sal_Int32 nWidth, sal_Int32 nHeight ) override;
virtual void endAppletOrPlugin(
const css::uno::Reference < css::beans::XPropertySet > &rPropSet,
std::map < const OUString, OUString > &rParamMap) override;
virtual bool IsInHeaderFooter() const override;
// redlining helper methods