diff options
Diffstat (limited to 'framework/source/jobs')
-rw-r--r-- | framework/source/jobs/helponstartup.cxx | 9 | ||||
-rw-r--r-- | framework/source/jobs/job.cxx | 36 | ||||
-rw-r--r-- | framework/source/jobs/jobdata.cxx | 29 | ||||
-rw-r--r-- | framework/source/jobs/jobdispatch.cxx | 29 | ||||
-rw-r--r-- | framework/source/jobs/jobexecutor.cxx | 138 | ||||
-rw-r--r-- | framework/source/jobs/jobresult.cxx | 19 | ||||
-rw-r--r-- | framework/source/jobs/joburl.cxx | 24 | ||||
-rw-r--r-- | framework/source/jobs/shelljob.cxx | 9 |
8 files changed, 119 insertions, 174 deletions
diff --git a/framework/source/jobs/helponstartup.cxx b/framework/source/jobs/helponstartup.cxx index 968a3aa10577..2795a3f45057 100644 --- a/framework/source/jobs/helponstartup.cxx +++ b/framework/source/jobs/helponstartup.cxx @@ -27,6 +27,7 @@ // include others #include <comphelper/sequenceashashmap.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/help.hxx> @@ -56,8 +57,8 @@ css::uno::Sequence< OUString > SAL_CALL HelpOnStartup::getSupportedServiceNames( return { SERVICENAME_JOB }; } -HelpOnStartup::HelpOnStartup(const css::uno::Reference< css::uno::XComponentContext >& xContext) - : m_xContext (xContext) +HelpOnStartup::HelpOnStartup(css::uno::Reference< css::uno::XComponentContext > xContext) + : m_xContext (std::move(xContext)) { // create some needed uno services and cache it m_xModuleManager = css::frame::ModuleManager::create( m_xContext ); @@ -65,10 +66,10 @@ HelpOnStartup::HelpOnStartup(const css::uno::Reference< css::uno::XComponentCont m_xDesktop = css::frame::Desktop::create(m_xContext); // ask for office locale - m_sLocale = officecfg::Setup::L10N::ooLocale::get(m_xContext); + m_sLocale = officecfg::Setup::L10N::ooLocale::get(); // detect system - m_sSystem = officecfg::Office::Common::Help::System::get(m_xContext); + m_sSystem = officecfg::Office::Common::Help::System::get(); // Start listening for disposing events of these services, // so we can react e.g. for an office shutdown diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index 39b867ac3291..711bd47b5823 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -31,7 +31,8 @@ #include <comphelper/sequence.hxx> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <utility> #include <vcl/svapp.hxx> namespace framework{ @@ -50,10 +51,10 @@ namespace framework{ (May be null!) */ Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext , - /*IN*/ const css::uno::Reference< css::frame::XFrame >& xFrame ) + /*IN*/ css::uno::Reference< css::frame::XFrame > xFrame ) : m_aJobCfg (xContext ) , m_xContext (xContext ) - , m_xFrame (xFrame ) + , m_xFrame (std::move(xFrame )) , m_bListenOnDesktop (false ) , m_bListenOnFrame (false ) , m_bListenOnModel (false ) @@ -77,10 +78,10 @@ Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xCont (May be null!) */ Job::Job( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext , - /*IN*/ const css::uno::Reference< css::frame::XModel >& xModel ) + /*IN*/ css::uno::Reference< css::frame::XModel > xModel ) : m_aJobCfg (xContext ) , m_xContext (xContext ) - , m_xModel (xModel ) + , m_xModel (std::move(xModel )) , m_bListenOnDesktop (false ) , m_bListenOnFrame (false ) , m_bListenOnModel (false ) @@ -156,6 +157,18 @@ void Job::setJobData( const JobData& aData ) void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs ) { /* SAFE { */ + class SolarMutexAntiGuard { + SolarMutexResettableGuard & m_rGuard; + public: + SolarMutexAntiGuard(SolarMutexResettableGuard & rGuard) : m_rGuard(rGuard) + { + m_rGuard.clear(); + } + ~SolarMutexAntiGuard() + { + m_rGuard.reset(); + } + }; SolarMutexResettableGuard aWriteLock; // reject dangerous calls @@ -191,23 +204,24 @@ void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lD if (xAJob.is()) { m_aAsyncWait.reset(); - aWriteLock.clear(); + SolarMutexAntiGuard const ag(aWriteLock); /* } SAFE */ xAJob->executeAsync(lJobArgs, xThis); // wait for finishing this job - so this method // does the same for synchronous and asynchronous jobs! m_aAsyncWait.wait(); - aWriteLock.reset(); /* SAFE { */ // Note: Result handling was already done inside the callback! } // execute it synchron else if (xSJob.is()) { - aWriteLock.clear(); - /* } SAFE */ - css::uno::Any aResult = xSJob->execute(lJobArgs); - aWriteLock.reset(); + css::uno::Any aResult; + { + SolarMutexAntiGuard const ag(aWriteLock); + /* } SAFE */ + aResult = xSJob->execute(lJobArgs); + } /* SAFE { */ impl_reactForJobResult(aResult); } diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index 974f2630fe84..0ca06fcaca8a 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -32,6 +32,7 @@ #include <tools/wldcrd.hxx> #include <unotools/configpaths.hxx> +#include <utility> #include <vcl/svapp.hxx> namespace framework{ @@ -45,8 +46,8 @@ namespace framework{ @param rxContext reference to the uno service manager */ -JobData::JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) - : m_xContext (rxContext ) +JobData::JobData( css::uno::Reference< css::uno::XComponentContext > xContext ) + : m_xContext (std::move(xContext )) { // share code for member initialization with defaults! impl_reset(); @@ -76,7 +77,6 @@ JobData::JobData( const JobData& rCopy ) */ JobData& JobData::operator=( const JobData& rCopy ) { - SolarMutexGuard g; // Please don't copy the uno service manager reference. // That can change the uno context, which isn't a good idea! m_eMode = rCopy.m_eMode; @@ -110,7 +110,6 @@ JobData::~JobData() */ void JobData::setAlias( const OUString& sAlias ) { - SolarMutexGuard g; // delete all old information! Otherwise we mix it with the new one ... impl_reset(); @@ -176,7 +175,6 @@ void JobData::setAlias( const OUString& sAlias ) */ void JobData::setService( const OUString& sService ) { - SolarMutexGuard g; // delete all old information! Otherwise we mix it with the new one ... impl_reset(); // take over the new information @@ -208,7 +206,6 @@ void JobData::setEvent( const OUString& sEvent , // share code to read all job properties! setAlias(sAlias); - SolarMutexGuard g; // take over the new information - which differ against set one of method setAlias()! m_sEvent = sEvent; m_eMode = E_EVENT; @@ -227,8 +224,6 @@ void JobData::setEvent( const OUString& sEvent , */ void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments ) { - SolarMutexGuard g; - // update member m_lArguments = std::move(lArguments); @@ -275,7 +270,6 @@ void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments ) */ void JobData::setEnvironment( EEnvironment eEnvironment ) { - SolarMutexGuard g; m_eEnvironment = eEnvironment; } @@ -286,20 +280,17 @@ void JobData::setEnvironment( EEnvironment eEnvironment ) */ JobData::EMode JobData::getMode() const { - SolarMutexGuard g; return m_eMode; } JobData::EEnvironment JobData::getEnvironment() const { - SolarMutexGuard g; return m_eEnvironment; } OUString JobData::getEnvironmentDescriptor() const { OUString sDescriptor; - SolarMutexGuard g; switch(m_eEnvironment) { case E_EXECUTION : @@ -321,25 +312,21 @@ OUString JobData::getEnvironmentDescriptor() const OUString JobData::getService() const { - SolarMutexGuard g; return m_sService; } OUString JobData::getEvent() const { - SolarMutexGuard g; return m_sEvent; } std::vector< css::beans::NamedValue > JobData::getJobConfig() const { - SolarMutexGuard g; return m_lArguments; } css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const { - SolarMutexGuard g; css::uno::Sequence< css::beans::NamedValue > lConfig; if (m_eMode==E_ALIAS) { @@ -363,7 +350,6 @@ css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const */ bool JobData::hasConfig() const { - SolarMutexGuard g; return (m_eMode==E_ALIAS || m_eMode==E_EVENT); } @@ -379,8 +365,6 @@ bool JobData::hasConfig() const */ void JobData::disableJob() { - SolarMutexGuard g; - // No configuration - not used from EXECUTOR and not triggered from an event => no chance! if (m_eMode!=E_EVENT) return; @@ -447,10 +431,10 @@ void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XC } } -bool JobData::hasCorrectContext(const OUString& rModuleIdent) const +bool JobData::hasCorrectContext(std::u16string_view rModuleIdent) const { sal_Int32 nContextLen = m_sContext.getLength(); - sal_Int32 nModuleIdLen = rModuleIdent.getLength(); + sal_Int32 nModuleIdLen = rModuleIdent.size(); if ( nContextLen == 0 ) return true; @@ -460,7 +444,7 @@ bool JobData::hasCorrectContext(const OUString& rModuleIdent) const sal_Int32 nIndex = m_sContext.indexOf( rModuleIdent ); if ( nIndex >= 0 && ( nIndex+nModuleIdLen <= nContextLen )) { - OUString sContextModule = m_sContext.copy( nIndex, nModuleIdLen ); + std::u16string_view sContextModule = m_sContext.subView( nIndex, nModuleIdLen ); return sContextModule == rModuleIdent; } } @@ -547,7 +531,6 @@ std::vector< OUString > JobData::getEnabledJobsForEvent( const css::uno::Referen */ void JobData::impl_reset() { - SolarMutexGuard g; m_eMode = E_UNKNOWN_MODE; m_eEnvironment = E_UNKNOWN_ENVIRONMENT; m_sAlias.clear(); diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx index e32f65123375..2352919dea09 100644 --- a/framework/source/jobs/jobdispatch.cxx +++ b/framework/source/jobs/jobdispatch.cxx @@ -36,6 +36,7 @@ #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/implbase.hxx> #include <rtl/ref.hxx> +#include <utility> #include <vcl/svapp.hxx> using namespace framework; @@ -73,7 +74,7 @@ private: public: - explicit JobDispatch(const css::uno::Reference< css::uno::XComponentContext >& xContext); + explicit JobDispatch(css::uno::Reference< css::uno::XComponentContext > xContext); virtual ~JobDispatch() override; void impl_dispatchEvent ( const OUString& sEvent , @@ -132,8 +133,8 @@ public: @param xContext reference to the uno service manager */ -JobDispatch::JobDispatch( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext ) - : m_xContext (xContext ) +JobDispatch::JobDispatch( /*IN*/ css::uno::Reference< css::uno::XComponentContext > xContext ) + : m_xContext (std::move(xContext )) { } @@ -300,11 +301,7 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& // get list of all enabled jobs // The called static helper methods read it from the configuration and // filter disabled jobs using it's time stamp values. - /* SAFE { */ - SolarMutexResettableGuard aReadLock; std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); - aReadLock.clear(); - /* } SAFE */ css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); @@ -316,9 +313,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& int nExecutedJobs=0; for (const OUString & lJob : lJobs) { - /* SAFE { */ - aReadLock.reset(); - JobData aCfg(m_xContext); aCfg.setEvent(sEvent, lJob); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -327,9 +321,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - if (!bIsEnabled) continue; @@ -373,9 +364,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString& /*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs , /*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) { - /* SAFE { */ - SolarMutexClearableGuard aReadLock; - JobData aCfg(m_xContext); aCfg.setService(sService); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -388,9 +376,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); // Special mode for listener. @@ -422,9 +407,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString& /*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs , /*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) { - /* SAFE { */ - SolarMutexClearableGuard aReadLock; - JobData aCfg(m_xContext); aCfg.setAlias(sAlias); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -432,9 +414,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); // Special mode for listener. diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 5578b877b028..f1c450bd6530 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -31,10 +31,9 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/document/XEventListener.hpp> -#include <cppuhelper/basemutex.hxx> -#include <cppuhelper/compbase.hxx> +#include <comphelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> -#include <unotools/configmgr.hxx> +#include <comphelper/configuration.hxx> #include <unotools/configpaths.hxx> #include <rtl/ref.hxx> #include <sal/log.hxx> @@ -44,7 +43,7 @@ using namespace framework; namespace { -typedef cppu::WeakComponentImplHelper< +typedef comphelper::WeakComponentImplHelper< css::lang::XServiceInfo , css::task::XJobExecutor , css::container::XContainerListener // => lang.XEventListener @@ -57,7 +56,7 @@ typedef cppu::WeakComponentImplHelper< inside the configuration and execute it. Of course it controls the lifetime of such jobs too. */ -class JobExecutor : private cppu::BaseMutex, public Base +class JobExecutor : public Base { private: @@ -73,7 +72,7 @@ private: /** helper to allow us listen to the configuration without a cyclic dependency */ css::uno::Reference<css::container::XContainerListener> m_xConfigListener; - virtual void SAL_CALL disposing() final override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) final override; public: @@ -121,15 +120,14 @@ public: reference to the uno service manager */ JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext ) - : Base (m_aMutex) - , m_xContext (xContext ) + : m_xContext (xContext ) , m_aConfig (xContext, "/org.openoffice.Office.Jobs/Events") { } void JobExecutor::initListeners() { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return; // read the list of all currently registered events inside configuration. @@ -162,21 +160,19 @@ void JobExecutor::initListeners() JobExecutor::~JobExecutor() { - disposing(); + std::unique_lock g(m_aMutex); + disposing(g); } -void JobExecutor::disposing() { +void JobExecutor::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { css::uno::Reference<css::container::XContainer> notifier; css::uno::Reference<css::container::XContainerListener> listener; - { - osl::MutexGuard g(rBHelper.rMutex); - if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) { - notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY); - listener = m_xConfigListener; - m_aConfig.close(); - } - m_xConfigListener.clear(); + if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) { + notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY); + listener = m_xConfigListener; + m_aConfig.close(); } + m_xConfigListener.clear(); if (notifier.is()) { notifier->removeContainerListener(listener); } @@ -195,45 +191,38 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) { SAL_INFO( "fwk", "JobExecutor::trigger()"); - std::vector< OUString > lJobs; + /* SAFE */ + { + std::unique_lock g(m_aMutex); - /* SAFE */ { - osl::MutexGuard g(rBHelper.rMutex); + // Optimization! + // Check if the given event name exist inside configuration and reject wrong requests. + // This optimization suppress using of the cfg api for getting event and job descriptions ... + if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end()) + return; - // Optimization! - // Check if the given event name exist inside configuration and reject wrong requests. - // This optimization suppress using of the cfg api for getting event and job descriptions ... - if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end()) - return; + } /* SAFE */ // get list of all enabled jobs // The called static helper methods read it from the configuration and // filter disabled jobs using it's time stamp values. - lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); - } /* SAFE */ + std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); // step over all enabled jobs and execute it size_t c = lJobs.size(); for (size_t j=0; j<c; ++j) { - rtl::Reference<Job> pJob; - - /* SAFE */ - { - SolarMutexGuard g2; - - JobData aCfg(m_xContext); - aCfg.setEvent(sEvent, lJobs[j]); - aCfg.setEnvironment(JobData::E_EXECUTION); + JobData aCfg(m_xContext); + aCfg.setEvent(sEvent, lJobs[j]); + aCfg.setEnvironment(JobData::E_EXECUTION); - /*Attention! - Jobs implements interfaces and dies by ref count! - And freeing of such uno object is done by uno itself. - So we have to use dynamic memory everytimes. - */ - pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >()); - pJob->setJobData(aCfg); - } /* SAFE */ + /*Attention! + Jobs implements interfaces and dies by ref count! + And freeing of such uno object is done by uno itself. + So we have to use dynamic memory everytimes. + */ + rtl::Reference<Job> pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >()); + pJob->setJobData(aCfg); pJob->execute(css::uno::Sequence< css::beans::NamedValue >()); } @@ -241,15 +230,12 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent ) { - static constexpr OUStringLiteral EVENT_ON_DOCUMENT_OPENED(u"onDocumentOpened"); // Job UI event : OnNew or OnLoad - static constexpr OUStringLiteral EVENT_ON_DOCUMENT_ADDED(u"onDocumentAdded"); // Job API event : OnCreate or OnLoadFinished + static constexpr OUString EVENT_ON_DOCUMENT_OPENED(u"onDocumentOpened"_ustr); // Job UI event : OnNew or OnLoad + static constexpr OUString EVENT_ON_DOCUMENT_ADDED(u"onDocumentAdded"_ustr); // Job API event : OnCreate or OnLoadFinished OUString aModuleIdentifier; ::std::vector< JobData::TJob2DocEventBinding > lJobs; - /* SAFE */ { - osl::MutexGuard g(rBHelper.rMutex); - // Optimization! // Check if the given event name exist inside configuration and reject wrong requests. // This optimization suppress using of the cfg api for getting event and job descriptions. @@ -263,29 +249,33 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent catch( const css::uno::Exception& ) {} - // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened". - if ( - (aEvent.EventName == "OnNew") || - (aEvent.EventName == "OnLoad") - ) + /* SAFE */ { - if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs); - } + std::unique_lock g(m_aMutex); - // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded". - if ( - (aEvent.EventName == "OnCreate") || - (aEvent.EventName == "OnLoadFinished") - ) - { - if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs); - } + // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened". + if ( + (aEvent.EventName == "OnNew") || + (aEvent.EventName == "OnLoad") + ) + { + if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end()) + JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs); + } - // Add all jobs for "real" notified event too .-) - if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end()) - JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs); + // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded". + if ( + (aEvent.EventName == "OnCreate") || + (aEvent.EventName == "OnLoadFinished") + ) + { + if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end()) + JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs); + } + + // Add all jobs for "real" notified event too .-) + if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end()) + JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs); } /* SAFE */ // step over all enabled jobs and execute it @@ -293,9 +283,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent { rtl::Reference<Job> pJob; - /* SAFE */ { - SolarMutexGuard g2; - const JobData::TJob2DocEventBinding& rBinding = lJob; JobData aCfg(m_xContext); @@ -313,7 +300,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent css::uno::Reference< css::frame::XModel > xModel(aEvent.Source, css::uno::UNO_QUERY); pJob = new Job(m_xContext, xModel); pJob->setJobData(aCfg); - } /* SAFE */ pJob->execute(css::uno::Sequence< css::beans::NamedValue >()); } @@ -371,7 +357,7 @@ void SAL_CALL JobExecutor::elementReplaced( const css::container::ContainerEvent void SAL_CALL JobExecutor::disposing( const css::lang::EventObject& aEvent ) { /* SAFE { */ - osl::MutexGuard g(rBHelper.rMutex); + std::unique_lock g(m_aMutex); css::uno::Reference< css::uno::XInterface > xCFG(m_aConfig.cfg(), css::uno::UNO_QUERY); if ( (xCFG == aEvent.Source ) && diff --git a/framework/source/jobs/jobresult.cxx b/framework/source/jobs/jobresult.cxx index 58cd2b59401c..183543606b59 100644 --- a/framework/source/jobs/jobresult.cxx +++ b/framework/source/jobs/jobresult.cxx @@ -142,7 +142,6 @@ JobResult::~JobResult() */ JobResult& JobResult::operator=(const JobResult& rCopy) { - SolarMutexGuard g; m_eParts = rCopy.m_eParts; m_lArguments = rCopy.m_lArguments; m_aDispatchResult = rCopy.m_aDispatchResult; @@ -161,11 +160,7 @@ JobResult& JobResult::operator=(const JobResult& rCopy) @return We return true only, if any set flag of the given mask match. */ -bool JobResult::existPart(sal_uInt32 eParts) const -{ - SolarMutexGuard g; - return ((m_eParts & eParts) == eParts); -} +bool JobResult::existPart(sal_uInt32 eParts) const { return ((m_eParts & eParts) == eParts); } /** @short provides access to our internal members @@ -175,17 +170,9 @@ bool JobResult::existPart(sal_uInt32 eParts) const @return It returns the state of the internal member without any checks! */ -std::vector<css::beans::NamedValue> JobResult::getArguments() const -{ - SolarMutexGuard g; - return m_lArguments; -} +std::vector<css::beans::NamedValue> JobResult::getArguments() const { return m_lArguments; } -css::frame::DispatchResultEvent JobResult::getDispatchResult() const -{ - SolarMutexGuard g; - return m_aDispatchResult; -} +css::frame::DispatchResultEvent JobResult::getDispatchResult() const { return m_aDispatchResult; } } // namespace framework diff --git a/framework/source/jobs/joburl.cxx b/framework/source/jobs/joburl.cxx index efff201a8401..5533014edf80 100644 --- a/framework/source/jobs/joburl.cxx +++ b/framework/source/jobs/joburl.cxx @@ -24,6 +24,7 @@ #include <jobs/joburl.hxx> #include <vcl/svapp.hxx> +#include <o3tl/string_view.hxx> namespace framework{ @@ -99,7 +100,6 @@ JobURL::JobURL( /*IN*/ const OUString& sURL ) */ bool JobURL::isValid() const { - SolarMutexGuard g; return (m_eRequest!=E_UNKNOWN); } @@ -121,8 +121,6 @@ bool JobURL::isValid() const */ bool JobURL::getEvent( /*OUT*/ OUString& sEvent ) const { - SolarMutexGuard g; - sEvent.clear(); bool bSet = ((m_eRequest & E_EVENT) == E_EVENT); if (bSet) @@ -149,8 +147,6 @@ bool JobURL::getEvent( /*OUT*/ OUString& sEvent ) const */ bool JobURL::getAlias( /*OUT*/ OUString& sAlias ) const { - SolarMutexGuard g; - sAlias.clear(); bool bSet = ((m_eRequest & E_ALIAS) == E_ALIAS); if (bSet) @@ -177,8 +173,6 @@ bool JobURL::getAlias( /*OUT*/ OUString& sAlias ) const */ bool JobURL::getService( /*OUT*/ OUString& sService ) const { - SolarMutexGuard g; - sService.clear(); bool bSet = ((m_eRequest & E_SERVICE) == E_SERVICE); if (bSet) @@ -212,14 +206,14 @@ bool JobURL::getService( /*OUT*/ OUString& sService ) const @return <TRUE/> if the identifier could be found and the string was split. <FALSE/> otherwise. */ -bool JobURL::implst_split( /*IN*/ const OUString& sPart , +bool JobURL::implst_split( /*IN*/ std::u16string_view sPart , /*IN*/ const char* pPartIdentifier , /*IN*/ sal_Int32 nPartLength , /*OUT*/ OUString& rPartValue , /*OUT*/ OUString& rPartArguments ) { // first search for the given identifier - bool bPartFound = sPart.matchIgnoreAsciiCaseAsciiL(pPartIdentifier,nPartLength); + bool bPartFound = o3tl::matchIgnoreAsciiCase(sPart, std::string_view(pPartIdentifier,nPartLength)); // If it exist - we can split the part and return sal_True. // Otherwise we do nothing and return sal_False. @@ -229,16 +223,16 @@ bool JobURL::implst_split( /*IN*/ const OUString& sPart , // Do so - we set the return value with the whole part string. // Arguments will be set to an empty string as default. // If we detect the right sign - we split the arguments and overwrite the default. - OUString sValueAndArguments = sPart.copy(nPartLength); - OUString sValue = sValueAndArguments; + std::u16string_view sValueAndArguments = sPart.substr(nPartLength); + std::u16string_view sValue = sValueAndArguments; OUString sArguments; - sal_Int32 nArgStart = sValueAndArguments.indexOf('?'); - if (nArgStart!=-1) + size_t nArgStart = sValueAndArguments.find('?'); + if (nArgStart != std::u16string_view::npos) { - sValue = sValueAndArguments.copy(0,nArgStart); + sValue = sValueAndArguments.substr(0,nArgStart); ++nArgStart; // ignore '?'! - sArguments = sValueAndArguments.copy(nArgStart); + sArguments = sValueAndArguments.substr(nArgStart); } rPartValue = sValue; diff --git a/framework/source/jobs/shelljob.cxx b/framework/source/jobs/shelljob.cxx index 292c1a701508..0c895db33f71 100644 --- a/framework/source/jobs/shelljob.cxx +++ b/framework/source/jobs/shelljob.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/util/PathSubstitution.hpp> #include <com/sun/star/util/XStringSubstitution.hpp> #include <cppuhelper/supportsservice.hxx> +#include <utility> namespace framework{ @@ -55,8 +56,8 @@ css::uno::Sequence< OUString > SAL_CALL ShellJob::getSupportedServiceNames() } -ShellJob::ShellJob(const css::uno::Reference< css::uno::XComponentContext >& xContext) - : m_xContext (xContext) +ShellJob::ShellJob(css::uno::Reference< css::uno::XComponentContext > xContext) + : m_xContext (std::move(xContext)) { } @@ -101,8 +102,8 @@ css::uno::Any SAL_CALL ShellJob::execute(const css::uno::Sequence< css::beans::N css::uno::Any ShellJob::impl_generateAnswer4Deactivation() { - css::uno::Sequence< css::beans::NamedValue > aAnswer { { JobConst::ANSWER_DEACTIVATE_JOB, css::uno::makeAny(true) } }; - return css::uno::makeAny(aAnswer); + css::uno::Sequence< css::beans::NamedValue > aAnswer { { JobConst::ANSWER_DEACTIVATE_JOB, css::uno::Any(true) } }; + return css::uno::Any(aAnswer); } OUString ShellJob::impl_substituteCommandVariables(const OUString& sCommand) |