Skip to content

Commit

Permalink
check IFrame "FrameURL" target
Browse files Browse the repository at this point in the history
similiar to

commit b3edf85
Date:   Wed Aug 7 17:37:11 2019 +0100

    warn on load when a document binds an event to a macro

Conflicts:
	sfx2/source/doc/iframe.cxx
	sw/source/filter/html/htmlplug.cxx
	sw/source/filter/xml/xmltexti.cxx

Change-Id: Iea888b1c083d2dc69ec322309ac9ae8c5e5eb315
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139059
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
  • Loading branch information
Caolán McNamara authored and thorstenb committed Sep 1, 2022
1 parent e36986a commit 7c29958
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
9 changes: 7 additions & 2 deletions sfx2/source/appl/macroloader.cxx
Expand Up @@ -76,10 +76,10 @@ css::uno::Sequence<OUString> SAL_CALL SfxMacroLoader::getSupportedServiceNames()
return aSeq;
}

SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
SfxObjectShell* SfxMacroLoader::GetObjectShell(const Reference <XFrame>& xFrame)
{
SfxObjectShell* pDocShell = nullptr;
Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );

if ( xFrame.is() )
{
SfxFrame* pFrame=nullptr;
Expand All @@ -96,6 +96,11 @@ SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
return pDocShell;
}

SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
{
Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
return SfxMacroLoader::GetObjectShell(xFrame);
}

uno::Reference<frame::XDispatch> SAL_CALL SfxMacroLoader::queryDispatch(
const util::URL& aURL ,
Expand Down
20 changes: 15 additions & 5 deletions sfx2/source/doc/iframe.cxx
Expand Up @@ -39,11 +39,13 @@
#include <svl/ownlist.hxx>
#include <svl/itemprop.hxx>
#include <sfx2/frmdescr.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/sfxdlg.hxx>
#include <sfx2/sfxsids.hrc>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx>
#include <tools/debug.hxx>
#include <macroloader.hxx>

using namespace ::com::sun::star;

Expand Down Expand Up @@ -159,6 +161,19 @@ sal_Bool SAL_CALL IFrameObject::load(
{
if ( SvtMiscOptions().IsPluginsEnabled() )
{
util::URL aTargetURL;
aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );
uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) );
xTrans->parseStrict( aTargetURL );

if (INetURLObject(aTargetURL.Complete).GetProtocol() == INetProtocol::Macro)
{
uno::Reference<frame::XFramesSupplier> xParentFrame = xFrame->getCreator();
SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame);
if (pDoc && !pDoc->AdjustMacroMode())
return false;
}

DBG_ASSERT( !mxFrame.is(), "Frame already existing!" );
VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() );
Expand All @@ -181,11 +196,6 @@ sal_Bool SAL_CALL IFrameObject::load(
if ( xFramesSupplier.is() )
mxFrame->setCreator( xFramesSupplier );

util::URL aTargetURL;
aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );
uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) );
xTrans->parseStrict( aTargetURL );

uno::Sequence < beans::PropertyValue > aProps(2);
aProps[0].Name = "PluginMode";
aProps[0].Value <<= sal_Int16(2);
Expand Down
2 changes: 2 additions & 0 deletions sfx2/source/inc/macroloader.hxx
Expand Up @@ -82,6 +82,8 @@ public:
virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override;

virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override;

static SfxObjectShell* GetObjectShell(const css::uno::Reference<css::frame::XFrame>& xFrame);
};

#endif
Expand Down
7 changes: 6 additions & 1 deletion sw/source/filter/html/htmlplug.cxx
Expand Up @@ -1087,7 +1087,12 @@ void SwHTMLParser::InsertFloatingFrame()
bool bHasBorder = aFrameDesc.HasFrameBorder();
Size aMargin = aFrameDesc.GetMargin();

xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );

if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro)
NotifyMacroEventRead();

xSet->setPropertyValue("FrameURL", uno::makeAny( sHRef ) );
xSet->setPropertyValue("FrameName", uno::makeAny( aName ) );

if ( eScroll == ScrollingMode::Auto )
Expand Down
9 changes: 7 additions & 2 deletions sw/source/filter/xml/xmltexti.cxx
Expand Up @@ -853,9 +853,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
OUString sHRef = URIHelper::SmartRel2Abs(
INetURLObject( GetXMLImport().GetBaseURL() ), rHRef );

if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro)
GetXMLImport().NotifyMacroEventRead();

xSet->setPropertyValue("FrameURL",
makeAny( URIHelper::SmartRel2Abs(
INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) ) );
makeAny( sHRef ) );

xSet->setPropertyValue("FrameName",
makeAny( rName ) );
Expand Down

0 comments on commit 7c29958

Please sign in to comment.