diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 09:44:28 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-30 10:31:26 +0200 |
commit | f662ba95361ba6b8eb49e0acd98bf28bc5f21100 (patch) | |
tree | a06ea88459155bb72b3f01dcda1d27f17cc49209 /framework/source/jobs | |
parent | bddfc920220b712c08eda96ac320a274e4bfcee6 (diff) |
Prepare for removal of non-const operator[] from Sequence in framework
Change-Id: Ied2683a0b8a1bab1a7594da1e9bdbd3cb753552c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124370
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'framework/source/jobs')
-rw-r--r-- | framework/source/jobs/job.cxx | 56 | ||||
-rw-r--r-- | framework/source/jobs/jobdata.cxx | 23 | ||||
-rw-r--r-- | framework/source/jobs/jobdispatch.cxx | 4 |
3 files changed, 42 insertions, 41 deletions
diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index 81203f3afcfc..39b867ac3291 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -336,30 +336,36 @@ css::uno::Sequence< css::beans::NamedValue > Job::impl_generateJobArgs( /*IN*/ c // Create list of environment variables. This list must be part of the // returned structure every time... but some of its members are optional! - css::uno::Sequence< css::beans::NamedValue > lEnvArgs(1); - lEnvArgs[0].Name = "EnvType"; - lEnvArgs[0].Value <<= m_aJobCfg.getEnvironmentDescriptor(); + sal_Int32 nLen = 1; + if (m_xFrame.is()) + ++nLen; + if (m_xModel.is()) + ++nLen; + if (eMode==JobData::E_EVENT) + ++nLen; + css::uno::Sequence< css::beans::NamedValue > lEnvArgs(nLen); + auto plEnvArgs = lEnvArgs.getArray(); + plEnvArgs[0].Name = "EnvType"; + plEnvArgs[0].Value <<= m_aJobCfg.getEnvironmentDescriptor(); + sal_Int32 i = 0; if (m_xFrame.is()) { - sal_Int32 c = lEnvArgs.getLength(); - lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = "Frame"; - lEnvArgs[c].Value <<= m_xFrame; + ++i; + plEnvArgs[i].Name = "Frame"; + plEnvArgs[i].Value <<= m_xFrame; } if (m_xModel.is()) { - sal_Int32 c = lEnvArgs.getLength(); - lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = "Model"; - lEnvArgs[c].Value <<= m_xModel; + ++i; + plEnvArgs[i].Name = "Model"; + plEnvArgs[i].Value <<= m_xModel; } if (eMode==JobData::E_EVENT) { - sal_Int32 c = lEnvArgs.getLength(); - lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = "EventName"; - lEnvArgs[c].Value <<= m_aJobCfg.getEvent(); + ++i; + plEnvArgs[i].Name = "EventName"; + plEnvArgs[i].Value <<= m_aJobCfg.getEvent(); } // get the configuration data from the job data container ... if possible @@ -381,29 +387,33 @@ css::uno::Sequence< css::beans::NamedValue > Job::impl_generateJobArgs( /*IN*/ c { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = "Config"; - lAllArgs[nLength].Value <<= lConfigArgs; + auto plAllArgs = lAllArgs.getArray(); + plAllArgs[nLength].Name = "Config"; + plAllArgs[nLength].Value <<= lConfigArgs; } if (!lJobConfigArgs.empty()) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = "JobConfig"; - lAllArgs[nLength].Value <<= comphelper::containerToSequence(lJobConfigArgs); + auto plAllArgs = lAllArgs.getArray(); + plAllArgs[nLength].Name = "JobConfig"; + plAllArgs[nLength].Value <<= comphelper::containerToSequence(lJobConfigArgs); } if (lEnvArgs.hasElements()) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = "Environment"; - lAllArgs[nLength].Value <<= lEnvArgs; + auto plAllArgs = lAllArgs.getArray(); + plAllArgs[nLength].Name = "Environment"; + plAllArgs[nLength].Value <<= lEnvArgs; } if (lDynamicArgs.hasElements()) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = "DynamicData"; - lAllArgs[nLength].Value <<= lDynamicArgs; + auto plAllArgs = lAllArgs.getArray(); + plAllArgs[nLength].Name = "DynamicData"; + plAllArgs[nLength].Value <<= lDynamicArgs; } return lAllArgs; diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index a516abdadd7c..974f2630fe84 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -252,12 +252,14 @@ void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments ) { sal_Int32 nCount = m_lArguments.size(); css::uno::Sequence< OUString > lNames (nCount); + auto lNamesRange = asNonConstRange(lNames); css::uno::Sequence< css::uno::Any > lValues(nCount); + auto lValuesRange = asNonConstRange(lValues); for (sal_Int32 i=0; i<nCount; ++i) { - lNames [i] = m_lArguments[i].Name; - lValues[i] = m_lArguments[i].Value; + lNamesRange [i] = m_lArguments[i].Name; + lValuesRange[i] = m_lArguments[i].Value; } xArgumentList->setHierarchicalPropertyValues(lNames, lValues); @@ -341,20 +343,9 @@ css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const css::uno::Sequence< css::beans::NamedValue > lConfig; if (m_eMode==E_ALIAS) { - lConfig.realloc(3); - sal_Int32 i = 0; - - lConfig[i].Name = "Alias"; - lConfig[i].Value <<= m_sAlias; - ++i; - - lConfig[i].Name = "Service"; - lConfig[i].Value <<= m_sService; - ++i; - - lConfig[i].Name = "Context"; - lConfig[i].Value <<= m_sContext; - ++i; + lConfig = { { "Alias", css::uno::Any(m_sAlias) }, + { "Service", css::uno::Any(m_sService) }, + { "Context", css::uno::Any(m_sContext) } }; } return lConfig; } diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx index c07727d017e7..e32f65123375 100644 --- a/framework/source/jobs/jobdispatch.cxx +++ b/framework/source/jobs/jobdispatch.cxx @@ -226,9 +226,9 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL JobD // don't pack resulting list! sal_Int32 nCount = lDescriptor.getLength(); css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatches(nCount); - + auto lDispatchesRange = asNonConstRange(lDispatches); for (sal_Int32 i=0; i<nCount; ++i) - lDispatches[i] = queryDispatch( lDescriptor[i].FeatureURL , + lDispatchesRange[i] = queryDispatch( lDescriptor[i].FeatureURL , lDescriptor[i].FrameName , lDescriptor[i].SearchFlags ); return lDispatches; |