loplugin:oncevar in unoxml..toolkit

Change-Id: I3b97665908be0a44d24192433bdc9c2bd9008736
Reviewed-on: https://gerrit.libreoffice.org/30431
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2016-10-31 10:29:25 +02:00
parent 40f186a732
commit aeeabc36fd
6 changed files with 27 additions and 52 deletions

View File

@@ -244,9 +244,8 @@ namespace toolkitform
*/ */
void getStringItemVector( const Reference< XPropertySet >& _rxModel, ::std::vector< OUString >& _rVector ) void getStringItemVector( const Reference< XPropertySet >& _rxModel, ::std::vector< OUString >& _rVector )
{ {
static const char FM_PROP_STRINGITEMLIST[] = "StringItemList";
Sequence< OUString > aListEntries; Sequence< OUString > aListEntries;
OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) >>= aListEntries ); OSL_VERIFY( _rxModel->getPropertyValue( "StringItemList" ) >>= aListEntries );
::std::copy( aListEntries.begin(), aListEntries.end(), ::std::copy( aListEntries.begin(), aListEntries.end(),
::std::back_insert_iterator< ::std::vector< OUString > >( _rVector ) ); ::std::back_insert_iterator< ::std::vector< OUString > >( _rVector ) );
} }
@@ -284,8 +283,7 @@ namespace toolkitform
// Name, Description, Text // Name, Description, Text
OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_NAME ) >>= Descriptor->Name ); OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_NAME ) >>= Descriptor->Name );
static const char FM_PROP_HELPTEXT[] = "HelpText"; OSL_VERIFY( xModelProps->getPropertyValue( "HelpText" ) >>= Descriptor->Description );
OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_HELPTEXT ) >>= Descriptor->Description );
Any aText; Any aText;
static const char FM_PROP_TEXT[] = "Text"; static const char FM_PROP_TEXT[] = "Text";
static const char FM_PROP_LABEL[] = "Label"; static const char FM_PROP_LABEL[] = "Label";
@@ -436,8 +434,7 @@ namespace toolkitform
} }
// file select // file select
static const char FM_SUN_COMPONENT_FILECONTROL[] = "com.sun.star.form.component.FileControl"; if ( xSI->supportsService( "com.sun.star.form.component.FileControl" ) )
if ( xSI->supportsService( FM_SUN_COMPONENT_FILECONTROL ) )
pEditWidget->FileSelect = true; pEditWidget->FileSelect = true;
// maximum text length // maximum text length
@@ -539,8 +536,7 @@ namespace toolkitform
pRadioWidget->RadioGroup = determineRadioGroupId( xModelProps ); pRadioWidget->RadioGroup = determineRadioGroupId( xModelProps );
try try
{ {
static const char FM_PROP_REFVALUE[] = "RefValue"; xModelProps->getPropertyValue( "RefValue" ) >>= pRadioWidget->OnValue;
xModelProps->getPropertyValue( FM_PROP_REFVALUE ) >>= pRadioWidget->OnValue;
} }
catch(...) catch(...)
{ {
@@ -555,8 +551,7 @@ namespace toolkitform
vcl::PDFWriter::ListBoxWidget* pListWidget = static_cast< vcl::PDFWriter::ListBoxWidget* >( Descriptor.get() ); vcl::PDFWriter::ListBoxWidget* pListWidget = static_cast< vcl::PDFWriter::ListBoxWidget* >( Descriptor.get() );
// drop down // drop down
static const char FM_PROP_DROPDOWN[] = "Dropdown"; OSL_VERIFY( xModelProps->getPropertyValue( "Dropdown" ) >>= pListWidget->DropDown );
OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_DROPDOWN ) >>= pListWidget->DropDown );
// multi selection // multi selection
OSL_VERIFY( xModelProps->getPropertyValue("MultiSelection") >>= pListWidget->MultiSelect ); OSL_VERIFY( xModelProps->getPropertyValue("MultiSelection") >>= pListWidget->MultiSelect );

View File

@@ -40,7 +40,6 @@ using namespace ::osl;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star; using namespace ::com::sun::star;
static const char ROOTNODE_EVENTS[] = "Office.Events/ApplicationEvents";
#define PATHDELIMITER "/" #define PATHDELIMITER "/"
#define SETNODE_BINDINGS "Bindings" #define SETNODE_BINDINGS "Bindings"
#define PROPERTYNAME_BINDINGURL "BindingURL" #define PROPERTYNAME_BINDINGURL "BindingURL"
@@ -107,7 +106,7 @@ public:
GlobalEventConfig_Impl::GlobalEventConfig_Impl() GlobalEventConfig_Impl::GlobalEventConfig_Impl()
: ConfigItem( ROOTNODE_EVENTS, ConfigItemMode::ImmediateUpdate ) : ConfigItem( "Office.Events/ApplicationEvents", ConfigItemMode::ImmediateUpdate )
{ {
// the supported event names // the supported event names
for (const GlobalEventId id : o3tl::enumrange<GlobalEventId>()) for (const GlobalEventId id : o3tl::enumrange<GlobalEventId>())
@@ -169,15 +168,15 @@ void GlobalEventConfig_Impl::ImplCommit()
ClearNodeSet( SETNODE_BINDINGS ); ClearNodeSet( SETNODE_BINDINGS );
Sequence< beans::PropertyValue > seqValues( 1 ); Sequence< beans::PropertyValue > seqValues( 1 );
OUString sNode; OUString sNode;
static const char sPrefix[] = SETNODE_BINDINGS PATHDELIMITER "BindingType['";
static const char sPostfix[] = "']" PATHDELIMITER PROPERTYNAME_BINDINGURL;
//step through the list of events //step through the list of events
for(int i=0;it!=it_end;++it,++i) for(int i=0;it!=it_end;++it,++i)
{ {
//no point in writing out empty bindings! //no point in writing out empty bindings!
if(it->second.isEmpty() ) if(it->second.isEmpty() )
continue; continue;
sNode = sPrefix + it->first + sPostfix; sNode = SETNODE_BINDINGS PATHDELIMITER "BindingType['" +
it->first +
"']" PATHDELIMITER PROPERTYNAME_BINDINGURL;
OSL_TRACE("writing binding for: %s",OUStringToOString(sNode , RTL_TEXTENCODING_ASCII_US ).pData->buffer); OSL_TRACE("writing binding for: %s",OUStringToOString(sNode , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
seqValues[ 0 ].Name = sNode; seqValues[ 0 ].Name = sNode;
seqValues[ 0 ].Value <<= it->second; seqValues[ 0 ].Value <<= it->second;

View File

@@ -51,12 +51,6 @@ namespace {
static const ::sal_Int32 s_nOffsetPassword = 3; static const ::sal_Int32 s_nOffsetPassword = 3;
static const ::sal_Int32 s_nOffsetThumbnail = 4; static const ::sal_Int32 s_nOffsetThumbnail = 4;
const char s_sCommonHistory[] = "org.openoffice.Office.Common/History";
const char s_sHistories[] = "org.openoffice.Office.Histories/Histories";
const char s_sPickListSize[] = "PickListSize";
const char s_sHelpBookmarksSize[] = "HelpBookmarkSize";
const char s_sPickList[] = "PickList";
const char s_sHelpBookmarks[] = "HelpBookmarks";
const char s_sItemList[] = "ItemList"; const char s_sItemList[] = "ItemList";
const char s_sOrderList[] = "OrderList"; const char s_sOrderList[] = "OrderList";
const char s_sHistoryItemRef[] = "HistoryItemRef"; const char s_sHistoryItemRef[] = "HistoryItemRef";
@@ -108,14 +102,14 @@ SvtHistoryOptions_Impl::SvtHistoryOptions_Impl()
m_xCfg.set( m_xCfg.set(
::comphelper::ConfigurationHelper::openConfig( ::comphelper::ConfigurationHelper::openConfig(
::comphelper::getProcessComponentContext(), ::comphelper::getProcessComponentContext(),
s_sHistories, "org.openoffice.Office.Histories/Histories",
::comphelper::EConfigurationModes::Standard), ::comphelper::EConfigurationModes::Standard),
uno::UNO_QUERY); uno::UNO_QUERY);
m_xCommonXCU.set( m_xCommonXCU.set(
::comphelper::ConfigurationHelper::openConfig( ::comphelper::ConfigurationHelper::openConfig(
::comphelper::getProcessComponentContext(), ::comphelper::getProcessComponentContext(),
s_sCommonHistory, "org.openoffice.Office.Common/History",
::comphelper::EConfigurationModes::Standard), ::comphelper::EConfigurationModes::Standard),
uno::UNO_QUERY); uno::UNO_QUERY);
} }
@@ -146,11 +140,11 @@ sal_uInt32 SvtHistoryOptions_Impl::GetCapacity(EHistoryType eHistory)
switch (eHistory) switch (eHistory)
{ {
case ePICKLIST: case ePICKLIST:
xListAccess->getPropertyValue(s_sPickListSize) >>= nSize; xListAccess->getPropertyValue("PickListSize") >>= nSize;
break; break;
case eHELPBOOKMARKS: case eHELPBOOKMARKS:
xListAccess->getPropertyValue(s_sHelpBookmarksSize) >>= nSize; xListAccess->getPropertyValue("HelpBookmarkSize") >>= nSize;
break; break;
default: default:
@@ -174,11 +168,11 @@ uno::Reference<container::XNameAccess> SvtHistoryOptions_Impl::GetListAccess(EHi
switch (eHistory) switch (eHistory)
{ {
case ePICKLIST: case ePICKLIST:
m_xCfg->getByName(s_sPickList) >>= xListAccess; m_xCfg->getByName("PickList") >>= xListAccess;
break; break;
case eHELPBOOKMARKS: case eHELPBOOKMARKS:
m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess; m_xCfg->getByName("HelpBookmarks") >>= xListAccess;
break; break;
default: default:

View File

@@ -785,12 +785,7 @@ bool SvtLinguConfigItem::IsReadOnly( sal_Int32 nPropertyHandle ) const
static SvtLinguConfigItem *pCfgItem = nullptr; static SvtLinguConfigItem *pCfgItem = nullptr;
static sal_Int32 nCfgItemRefCount = 0; static sal_Int32 nCfgItemRefCount = 0;
static const char aG_SupportedDictionaryFormats[] = "SupportedDictionaryFormats";
static const char aG_Dictionaries[] = "Dictionaries"; static const char aG_Dictionaries[] = "Dictionaries";
static const char aG_Locations[] = "Locations";
static const char aG_Format[] = "Format";
static const char aG_Locales[] = "Locales";
static const char aG_DisabledDictionaries[] = "DisabledDictionaries";
SvtLinguConfig::SvtLinguConfig() SvtLinguConfig::SvtLinguConfig()
{ {
@@ -905,7 +900,7 @@ bool SvtLinguConfig::GetSupportedDictionaryFormatsFor(
xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW ); xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
xNA.set( xNA->getByName( rSetName ), uno::UNO_QUERY_THROW ); xNA.set( xNA->getByName( rSetName ), uno::UNO_QUERY_THROW );
xNA.set( xNA->getByName( rSetEntry ), uno::UNO_QUERY_THROW ); xNA.set( xNA->getByName( rSetEntry ), uno::UNO_QUERY_THROW );
if (xNA->getByName( aG_SupportedDictionaryFormats ) >>= rFormatList) if (xNA->getByName( "SupportedDictionaryFormats" ) >>= rFormatList)
bSuccess = true; bSuccess = true;
DBG_ASSERT( rFormatList.getLength(), "supported dictionary format list is empty" ); DBG_ASSERT( rFormatList.getLength(), "supported dictionary format list is empty" );
} }
@@ -953,9 +948,9 @@ bool SvtLinguConfig::GetDictionaryEntry(
uno::Sequence< OUString > aLocations; uno::Sequence< OUString > aLocations;
OUString aFormatName; OUString aFormatName;
uno::Sequence< OUString > aLocaleNames; uno::Sequence< OUString > aLocaleNames;
bSuccess = (xNA->getByName( aG_Locations ) >>= aLocations) && bSuccess = (xNA->getByName( "Locations" ) >>= aLocations) &&
(xNA->getByName( aG_Format ) >>= aFormatName) && (xNA->getByName( "Format" ) >>= aFormatName) &&
(xNA->getByName( aG_Locales ) >>= aLocaleNames); (xNA->getByName( "Locales" ) >>= aLocaleNames);
DBG_ASSERT( aLocations.getLength(), "Dictionary locations not set" ); DBG_ASSERT( aLocations.getLength(), "Dictionary locations not set" );
DBG_ASSERT( !aFormatName.isEmpty(), "Dictionary format name not set" ); DBG_ASSERT( !aFormatName.isEmpty(), "Dictionary format name not set" );
DBG_ASSERT( aLocaleNames.getLength(), "No locales set for the dictionary" ); DBG_ASSERT( aLocaleNames.getLength(), "No locales set for the dictionary" );
@@ -993,7 +988,7 @@ uno::Sequence< OUString > SvtLinguConfig::GetDisabledDictionaries() const
{ {
uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xNA( GetMainUpdateAccess(), uno::UNO_QUERY_THROW );
xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW ); xNA.set( xNA->getByName("ServiceManager"), uno::UNO_QUERY_THROW );
xNA->getByName( aG_DisabledDictionaries ) >>= aResult; xNA->getByName( "DisabledDictionaries" ) >>= aResult;
} }
catch (uno::Exception &) catch (uno::Exception &)
{ {

View File

@@ -335,8 +335,6 @@ MediaDescriptor::MediaDescriptor(const css::uno::Sequence< css::beans::PropertyV
bool MediaDescriptor::isStreamReadOnly() const bool MediaDescriptor::isStreamReadOnly() const
{ {
static const char CONTENTSCHEME_FILE[] = "file";
static const char CONTENTPROP_ISREADONLY[] = "IsReadOnly";
static bool READONLY_FALLBACK = false; static bool READONLY_FALLBACK = false;
bool bReadOnly = READONLY_FALLBACK; bool bReadOnly = READONLY_FALLBACK;
@@ -373,14 +371,14 @@ bool MediaDescriptor::isStreamReadOnly() const
if (xId.is()) if (xId.is())
aScheme = xId->getContentProviderScheme(); aScheme = xId->getContentProviderScheme();
if (aScheme.equalsIgnoreAsciiCase(CONTENTSCHEME_FILE)) if (aScheme.equalsIgnoreAsciiCase("file"))
bReadOnly = true; bReadOnly = true;
else else
{ {
::ucbhelper::Content aContent(xContent, ::ucbhelper::Content aContent(xContent,
utl::UCBContentHelper::getDefaultCommandEnvironment(), utl::UCBContentHelper::getDefaultCommandEnvironment(),
comphelper::getProcessComponentContext()); comphelper::getProcessComponentContext());
aContent.getPropertyValue(CONTENTPROP_ISREADONLY) >>= bReadOnly; aContent.getPropertyValue("IsReadOnly") >>= bReadOnly;
} }
} }
} }

View File

@@ -1491,12 +1491,6 @@ void SAL_CALL librdf_Repository::setStatementRDFa(
throw (uno::RuntimeException, lang::IllegalArgumentException, throw (uno::RuntimeException, lang::IllegalArgumentException,
rdf::RepositoryException, std::exception) rdf::RepositoryException, std::exception)
{ {
static const char s_cell[] = "com.sun.star.table.Cell";
static const char s_cellprops[] = "com.sun.star.text.CellProperties"; // for writer
static const char s_paragraph[] = "com.sun.star.text.Paragraph";
static const char s_bookmark[] = "com.sun.star.text.Bookmark";
static const char s_meta[] = "com.sun.star.text.InContentMetadata";
if (!i_xSubject.is()) { if (!i_xSubject.is()) {
throw lang::IllegalArgumentException( throw lang::IllegalArgumentException(
"librdf_Repository::setStatementRDFa: Subject is null", *this, 0); "librdf_Repository::setStatementRDFa: Subject is null", *this, 0);
@@ -1520,14 +1514,14 @@ throw (uno::RuntimeException, lang::IllegalArgumentException,
const uno::Reference<lang::XServiceInfo> xService(i_xObject, const uno::Reference<lang::XServiceInfo> xService(i_xObject,
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
uno::Reference<text::XTextRange> xTextRange; uno::Reference<text::XTextRange> xTextRange;
if (xService->supportsService(s_cell) || if (xService->supportsService("com.sun.star.table.Cell") ||
xService->supportsService(s_cellprops) || xService->supportsService("com.sun.star.text.CellProperties") || // for writer
xService->supportsService(s_paragraph)) xService->supportsService("com.sun.star.text.Paragraph"))
{ {
xTextRange.set(i_xObject, uno::UNO_QUERY_THROW); xTextRange.set(i_xObject, uno::UNO_QUERY_THROW);
} }
else if (xService->supportsService(s_bookmark) || else if (xService->supportsService("com.sun.star.text.Bookmark") ||
xService->supportsService(s_meta)) xService->supportsService("com.sun.star.text.InContentMetadata"))
{ {
const uno::Reference<text::XTextContent> xTextContent(i_xObject, const uno::Reference<text::XTextContent> xTextContent(i_xObject,
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);