include/sfx2/sfxbasemodel.hxx | 2 +- sfx2/source/doc/sfxbasemodel.cxx | 12 +++++++++--- sfx2/source/view/viewprn.cxx | 1 - 3 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 774c6a6e1603bf3f12f1573b0778e0f0f9783169 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Mon Nov 29 10:18:52 2021 +0100 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Mon Nov 29 17:21:38 2021 +0100 tdf#117280: fix multiple Macro execution when triggered by Document print event Change-Id: Ibfebcc1a31464b2610afea2035e3d723a0c79167 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126018 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Julien Nabet <serval2...@yahoo.fr> diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx index b55705b57e1d..8ccd59292e58 100644 --- a/include/sfx2/sfxbasemodel.hxx +++ b/include/sfx2/sfxbasemodel.hxx @@ -721,7 +721,7 @@ private: SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage ); SAL_DLLPRIVATE OUString GetMediumFilterName_Impl() const; - SAL_DLLPRIVATE void postEvent_Impl( const OUString& aName, const css::uno::Reference< css::frame::XController2 >& xController = css::uno::Reference< css::frame::XController2 >() ); + SAL_DLLPRIVATE void postEvent_Impl( const OUString& aName, const css::uno::Reference< css::frame::XController2 >& xController = css::uno::Reference< css::frame::XController2 >(), const css::uno::Any& aSupplement = css::uno::Any()); SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); SAL_DLLPRIVATE css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper (); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 28afbd7e5bad..44cd4216bece 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2896,7 +2896,13 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , } const SfxViewEventHint* pViewHint = dynamic_cast<const SfxViewEventHint*>(&rHint); - postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >() ); + if (pViewHint) + { + const SfxPrintingHint* pPrintingHint = dynamic_cast<const SfxPrintingHint*>(&rHint); + postEvent_Impl( pNamedHint->GetEventName(), pViewHint->GetController(), pPrintingHint? Any(pPrintingHint->GetWhich()) : Any() ); + } + else + postEvent_Impl( pNamedHint->GetEventName(), Reference< frame::XController2 >() ); } if ( rHint.GetId() == SfxHintId::TitleChanged ) @@ -3223,7 +3229,7 @@ public: }; } // anonymous namespace -void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame::XController2 >& xController ) +void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame::XController2 >& xController, const Any& supplement ) { // object already disposed? if ( impl_isDisposed() ) @@ -3245,7 +3251,7 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame { SAL_INFO("sfx.doc", "SfxDocumentEvent: " + aName); - document::DocumentEvent aDocumentEvent( static_cast<frame::XModel*>(this), aName, xController, Any() ); + document::DocumentEvent aDocumentEvent( static_cast<frame::XModel*>(this), aName, xController, supplement ); pIC->forEach< document::XDocumentEventListener, NotifySingleListenerIgnoreRE< document::XDocumentEventListener, document::DocumentEvent > >( NotifySingleListenerIgnoreRE< document::XDocumentEventListener, document::DocumentEvent >( diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index dbf84dde0d3c..f6cd8936ee84 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -313,7 +313,6 @@ void SfxPrinterController::jobStarted() xDocProps->setPrintDate( now.GetUNODateTime() ); - SfxGetpApp()->NotifyEvent( SfxEventHint(SfxEventHintId::PrintDoc, GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), mpObjectShell ) ); uno::Sequence < beans::PropertyValue > aOpts; aOpts = getJobProperties( aOpts );