diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-02-10 15:44:47 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-02-10 15:58:39 +0100 |
commit | 463e1cd292b347d43ff33eef61a539a5e9d1c53f (patch) | |
tree | 54022ef2bee5fc53cbf95730171e6715e79b38a1 /framework/source | |
parent | 627cf7e91a741f55c6519bc33451b5aab9a68267 (diff) |
Simplify string literal usage
Change-Id: I216d0af8fd78bec8668ea2a5be7d75f7c1df0c31
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/jobs/helponstartup.cxx | 55 | ||||
-rw-r--r-- | framework/source/jobs/job.cxx | 16 | ||||
-rw-r--r-- | framework/source/jobs/jobdata.cxx | 86 | ||||
-rw-r--r-- | framework/source/jobs/jobexecutor.cxx | 2 |
4 files changed, 48 insertions, 111 deletions
diff --git a/framework/source/jobs/helponstartup.cxx b/framework/source/jobs/helponstartup.cxx index 19b35a40f4b8..af7e5afe9646 100644 --- a/framework/source/jobs/helponstartup.cxx +++ b/framework/source/jobs/helponstartup.cxx @@ -44,31 +44,6 @@ namespace framework{ - -// path to module config -static OUString CFG_PACKAGE_MODULES ("/org.openoffice.Setup/Office/Factories"); -static OUString CFG_PACKAGE_SETUP ("/org.openoffice.Setup"); -static OUString CFG_PACKAGE_COMMON ("/org.openoffice.Office.Common"); -static OUString CFG_PATH_L10N ("L10N"); -static OUString CFG_PATH_HELP ("Help"); -static OUString CFG_KEY_LOCALE ("ooLocale"); -static OUString CFG_KEY_HELPSYSTEM ("System"); - -// props of job environment -static OUString PROP_ENVIRONMENT ("Environment"); -static OUString PROP_JOBCONFIG ("JobConfig"); -static OUString PROP_ENVTYPE ("EnvType"); -static OUString PROP_MODEL ("Model"); - -// props of module config -static OUString PROP_HELP_BASEURL ("ooSetupFactoryHelpBaseURL"); -static OUString PROP_AUTOMATIC_HELP ("ooSetupFactoryHelpOnOpen"); - -// special value of job environment -static OUString ENVTYPE_DOCUMENTEVENT ("DOCUMENTEVENT"); - -//----------------------------------------------- - DEFINE_XSERVICEINFO_MULTISERVICE_2(HelpOnStartup , ::cppu::OWeakObject , SERVICENAME_JOB , @@ -89,24 +64,24 @@ DEFINE_INIT_SERVICE(HelpOnStartup, m_xConfig = css::uno::Reference< css::container::XNameAccess >( ::comphelper::ConfigurationHelper::openConfig( m_xContext, - CFG_PACKAGE_MODULES, + "/org.openoffice.Setup/Office/Factories", ::comphelper::ConfigurationHelper::E_READONLY), css::uno::UNO_QUERY_THROW); // ask for office locale ::comphelper::ConfigurationHelper::readDirectKey( m_xContext, - CFG_PACKAGE_SETUP, - CFG_PATH_L10N, - CFG_KEY_LOCALE, + "/org.openoffice.Setup", + "L10N", + "ooLocale", ::comphelper::ConfigurationHelper::E_READONLY) >>= m_sLocale; // detect system ::comphelper::ConfigurationHelper::readDirectKey( m_xContext, - CFG_PACKAGE_COMMON, - CFG_PATH_HELP, - CFG_KEY_HELPSYSTEM, + "/org.openoffice.Office.Common", + "Help", + "System", ::comphelper::ConfigurationHelper::E_READONLY) >>= m_sSystem; // Start listening for disposing events of these services, @@ -206,17 +181,17 @@ void SAL_CALL HelpOnStartup::disposing(const css::lang::EventObject& aEvent) OUString HelpOnStartup::its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments) { ::comphelper::SequenceAsHashMap lArgs (lArguments); - ::comphelper::SequenceAsHashMap lEnvironment = lArgs.getUnpackedValueOrDefault(PROP_ENVIRONMENT, css::uno::Sequence< css::beans::NamedValue >()); - ::comphelper::SequenceAsHashMap lJobConfig = lArgs.getUnpackedValueOrDefault(PROP_JOBCONFIG , css::uno::Sequence< css::beans::NamedValue >()); + ::comphelper::SequenceAsHashMap lEnvironment = lArgs.getUnpackedValueOrDefault("Environment", css::uno::Sequence< css::beans::NamedValue >()); + ::comphelper::SequenceAsHashMap lJobConfig = lArgs.getUnpackedValueOrDefault("JobConfig", css::uno::Sequence< css::beans::NamedValue >()); // check for right environment. // If its not a DocumentEvent, which triggered this job, // we cant work correctly! => return immediately and do nothing - OUString sEnvType = lEnvironment.getUnpackedValueOrDefault(PROP_ENVTYPE, OUString()); - if (!sEnvType.equals(ENVTYPE_DOCUMENTEVENT)) + OUString sEnvType = lEnvironment.getUnpackedValueOrDefault("EnvType", OUString()); + if (sEnvType != "DOCUMENTEVENT") return OUString(); - css::uno::Reference< css::frame::XModel > xDoc = lEnvironment.getUnpackedValueOrDefault(PROP_MODEL, css::uno::Reference< css::frame::XModel >()); + css::uno::Reference< css::frame::XModel > xDoc = lEnvironment.getUnpackedValueOrDefault("Model", css::uno::Reference< css::frame::XModel >()); if (!xDoc.is()) return OUString(); @@ -329,7 +304,7 @@ OUString HelpOnStartup::its_getCurrentHelpURL() continue; OUString sHelpBaseURL; - xModuleConfig->getByName(PROP_HELP_BASEURL) >>= sHelpBaseURL; + xModuleConfig->getByName("ooSetupFactoryHelpBaseURL") >>= sHelpBaseURL; OUString sHelpURLForModule = HelpOnStartup::ist_createHelpURL(sHelpBaseURL, sLocale, sSystem); if (sHelpURL.equals(sHelpURLForModule)) return sal_True; @@ -364,12 +339,12 @@ OUString HelpOnStartup::its_checkIfHelpEnabledAndGetURL(const OUString& sModule) sal_Bool bHelpEnabled = sal_False; if (xModuleConfig.is()) - xModuleConfig->getByName(PROP_AUTOMATIC_HELP) >>= bHelpEnabled; + xModuleConfig->getByName("ooSetupFactoryHelpOnOpen") >>= bHelpEnabled; if (bHelpEnabled) { OUString sHelpBaseURL; - xModuleConfig->getByName(PROP_HELP_BASEURL) >>= sHelpBaseURL; + xModuleConfig->getByName("ooSetupFactoryHelpBaseURL") >>= sHelpBaseURL; sHelpURL = HelpOnStartup::ist_createHelpURL(sHelpBaseURL, sLocale, sSystem); } } diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index 2d0bc573ddc8..7e234a33e473 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -356,28 +356,28 @@ 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 everytimes ... but some of its members are opetional! css::uno::Sequence< css::beans::NamedValue > lEnvArgs(1); - lEnvArgs[0].Name = OUString::createFromAscii(JobData::PROP_ENVTYPE); + lEnvArgs[0].Name = "EnvType"; lEnvArgs[0].Value <<= m_aJobCfg.getEnvironmentDescriptor(); if (m_xFrame.is()) { sal_Int32 c = lEnvArgs.getLength(); lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = OUString::createFromAscii(JobData::PROP_FRAME); + lEnvArgs[c].Name = "Frame"; lEnvArgs[c].Value <<= m_xFrame; } if (m_xModel.is()) { sal_Int32 c = lEnvArgs.getLength(); lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = OUString::createFromAscii(JobData::PROP_MODEL); + lEnvArgs[c].Name = "Model"; lEnvArgs[c].Value <<= m_xModel; } if (eMode==JobData::E_EVENT) { sal_Int32 c = lEnvArgs.getLength(); lEnvArgs.realloc(c+1); - lEnvArgs[c].Name = OUString::createFromAscii(JobData::PROP_EVENTNAME); + lEnvArgs[c].Name = "EventName"; lEnvArgs[c].Value <<= m_aJobCfg.getEvent(); } @@ -400,28 +400,28 @@ css::uno::Sequence< css::beans::NamedValue > Job::impl_generateJobArgs( /*IN*/ c { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = OUString::createFromAscii(JobData::PROPSET_CONFIG); + lAllArgs[nLength].Name = "Config"; lAllArgs[nLength].Value <<= lConfigArgs; } if (lJobConfigArgs.getLength()>0) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = OUString::createFromAscii(JobData::PROPSET_OWNCONFIG); + lAllArgs[nLength].Name = "JobConfig"; lAllArgs[nLength].Value <<= lJobConfigArgs; } if (lEnvArgs.getLength()>0) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = OUString::createFromAscii(JobData::PROPSET_ENVIRONMENT); + lAllArgs[nLength].Name = "Environment"; lAllArgs[nLength].Value <<= lEnvArgs; } if (lDynamicArgs.getLength()>0) { sal_Int32 nLength = lAllArgs.getLength(); lAllArgs.realloc(nLength+1); - lAllArgs[nLength].Name = OUString::createFromAscii(JobData::PROPSET_DYNAMICDATA); + lAllArgs[nLength].Name = "DynamicData"; lAllArgs[nLength].Value <<= lDynamicArgs; } diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index 3d7972955a06..603f9ae341b6 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -31,39 +31,11 @@ #include <tools/wldcrd.hxx> #include <unotools/configpaths.hxx> -#include <rtl/ustrbuf.hxx> #include <vcl/svapp.hxx> namespace framework{ - -const sal_Char* JobData::JOBCFG_ROOT = "/org.openoffice.Office.Jobs/Jobs/" ; -const sal_Char* JobData::JOBCFG_PROP_SERVICE = "Service" ; -const sal_Char* JobData::JOBCFG_PROP_CONTEXT = "Context" ; -const sal_Char* JobData::JOBCFG_PROP_ARGUMENTS = "Arguments" ; - -const sal_Char* JobData::EVENTCFG_ROOT = "/org.openoffice.Office.Jobs/Events/" ; -const sal_Char* JobData::EVENTCFG_PATH_JOBLIST = "/JobList" ; -const sal_Char* JobData::EVENTCFG_PROP_ADMINTIME = "AdminTime" ; -const sal_Char* JobData::EVENTCFG_PROP_USERTIME = "UserTime" ; - -const sal_Char* JobData::PROPSET_CONFIG = "Config" ; -const sal_Char* JobData::PROPSET_OWNCONFIG = "JobConfig" ; -const sal_Char* JobData::PROPSET_ENVIRONMENT = "Environment" ; -const sal_Char* JobData::PROPSET_DYNAMICDATA = "DynamicData" ; - -const sal_Char* JobData::PROP_ALIAS = "Alias" ; -const sal_Char* JobData::PROP_EVENTNAME = "EventName" ; -const sal_Char* JobData::PROP_ENVTYPE = "EnvType" ; -const sal_Char* JobData::PROP_FRAME = "Frame" ; -const sal_Char* JobData::PROP_MODEL = "Model" ; -const sal_Char* JobData::PROP_SERVICE = "Service" ; -const sal_Char* JobData::PROP_CONTEXT = "Context" ; - - - -//________________________________ /** @short standard ctor @descr It initialize this new instance. @@ -158,10 +130,10 @@ void JobData::setAlias( const OUString& sAlias ) // try to open the configuration set of this job directly and get a property access to it // We open it readonly here - OUString sKey(OUString::createFromAscii(JOBCFG_ROOT)); - sKey += ::utl::wrapConfigurationElementName(m_sAlias); - - ConfigAccess aConfig(m_xContext, sKey); + ConfigAccess aConfig( + m_xContext, + ("/org.openoffice.Office.Jobs/Jobs/" + + utl::wrapConfigurationElementName(m_sAlias))); aConfig.open(ConfigAccess::E_READONLY); if (aConfig.getMode()==ConfigAccess::E_CLOSED) { @@ -175,15 +147,15 @@ void JobData::setAlias( const OUString& sAlias ) css::uno::Any aValue; // read uno implementation name - aValue = xJobProperties->getPropertyValue(OUString::createFromAscii(JOBCFG_PROP_SERVICE)); + aValue = xJobProperties->getPropertyValue("Service"); aValue >>= m_sService; // read module context list - aValue = xJobProperties->getPropertyValue(OUString::createFromAscii(JOBCFG_PROP_CONTEXT)); + aValue = xJobProperties->getPropertyValue("Context"); aValue >>= m_sContext; // read whole argument list - aValue = xJobProperties->getPropertyValue(OUString::createFromAscii(JOBCFG_PROP_ARGUMENTS)); + aValue = xJobProperties->getPropertyValue("Arguments"); css::uno::Reference< css::container::XNameAccess > xArgumentList; if ( (aValue >>= xArgumentList) && @@ -292,10 +264,10 @@ void JobData::setJobConfig( const css::uno::Sequence< css::beans::NamedValue >& // It doesn't matter if this config object was already opened before. // It doesn nothing here then ... or it change the mode automaticly, if // it was opened using another one before. - OUString sKey(OUString::createFromAscii(JOBCFG_ROOT)); - sKey += ::utl::wrapConfigurationElementName(m_sAlias); - - ConfigAccess aConfig(m_xContext, sKey); + ConfigAccess aConfig( + m_xContext, + ("/org.openoffice.Office.Jobs/Jobs/" + + utl::wrapConfigurationElementName(m_sAlias))); aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return; @@ -460,15 +432,15 @@ css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const lConfig.realloc(3); sal_Int32 i = 0; - lConfig[i].Name = OUString::createFromAscii(PROP_ALIAS); + lConfig[i].Name = "Alias"; lConfig[i].Value <<= m_sAlias; ++i; - lConfig[i].Name = OUString::createFromAscii(PROP_SERVICE); + lConfig[i].Name = "Service"; lConfig[i].Value <<= m_sService; ++i; - lConfig[i].Name = OUString::createFromAscii(PROP_CONTEXT); + lConfig[i].Name = "Context"; lConfig[i].Value <<= m_sContext; ++i; } @@ -521,14 +493,11 @@ void JobData::disableJob() // It doesn't matter if this config object was already opened before. // It doesn nothing here then ... or it change the mode automaticly, if // it was opened using another one before. - OUStringBuffer sKey(256); - sKey.appendAscii(JobData::EVENTCFG_ROOT ); - sKey.append (::utl::wrapConfigurationElementName(m_sEvent)); - sKey.appendAscii(JobData::EVENTCFG_PATH_JOBLIST ); - sKey.appendAscii("/" ); - sKey.append (::utl::wrapConfigurationElementName(m_sAlias)); - - ConfigAccess aConfig(m_xContext, sKey.makeStringAndClear()); + ConfigAccess aConfig( + m_xContext, + ("/org.openoffice.Office.Jobs/Events/" + + utl::wrapConfigurationElementName(m_sEvent) + "/JobList/" + + utl::wrapConfigurationElementName(m_sAlias))); aConfig.open(ConfigAccess::E_READWRITE); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return; @@ -539,7 +508,7 @@ void JobData::disableJob() // Convert and write the user timestamp to the configuration. css::uno::Any aValue; aValue <<= Converter::convert_DateTime2ISO8601(DateTime( DateTime::SYSTEM)); - xPropSet->setPropertyValue(OUString::createFromAscii(EVENTCFG_PROP_USERTIME), aValue); + xPropSet->setPropertyValue("UserTime", aValue); } aConfig.close(); @@ -622,14 +591,8 @@ sal_Bool JobData::hasCorrectContext(const OUString& rModuleIdent) const css::uno::Sequence< OUString > JobData::getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const OUString& sEvent ) { - // these static values may perform following loop for reading time stamp values ... - static OUString ADMINTIME = OUString::createFromAscii(JobData::EVENTCFG_PROP_ADMINTIME); - static OUString USERTIME = OUString::createFromAscii(JobData::EVENTCFG_PROP_USERTIME ); - static OUString ROOT = OUString::createFromAscii(JobData::EVENTCFG_ROOT ); - static OUString JOBLIST = OUString::createFromAscii(JobData::EVENTCFG_PATH_JOBLIST ); - // create a config access to "/org.openoffice.Office.Jobs/Events" - ConfigAccess aConfig(rxContext,ROOT); + ConfigAccess aConfig(rxContext, "/org.openoffice.Office.Jobs/Events"); aConfig.open(ConfigAccess::E_READONLY); if (aConfig.getMode()==ConfigAccess::E_CLOSED) return css::uno::Sequence< OUString >(); @@ -639,8 +602,7 @@ css::uno::Sequence< OUString > JobData::getEnabledJobsForEvent( const css::uno:: return css::uno::Sequence< OUString >(); // check if the given event exist inside list of registered ones - OUString sPath(sEvent); - sPath += JOBLIST; + OUString sPath(sEvent + "/JobList"); if (!xEventRegistry->hasByHierarchicalName(sPath)) return css::uno::Sequence< OUString >(); @@ -676,10 +638,10 @@ css::uno::Sequence< OUString > JobData::getEnabledJobsForEvent( const css::uno:: } OUString sAdminTime; - xJob->getPropertyValue(ADMINTIME) >>= sAdminTime; + xJob->getPropertyValue("AdminTime") >>= sAdminTime; OUString sUserTime; - xJob->getPropertyValue(USERTIME) >>= sUserTime; + xJob->getPropertyValue("UserTime") >>= sUserTime; if (!isEnabled(sAdminTime, sUserTime)) continue; diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index f5605a2075b8..077a39f173bc 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -132,7 +132,7 @@ public: JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base (*static_cast<Mutex *>(this)) , m_xContext (xContext ) - , m_aConfig (xContext, OUString::createFromAscii(JobData::EVENTCFG_ROOT) ) + , m_aConfig (xContext, "/org.openoffice.Office.Jobs/Events") { } |