Rewrite fix for tdf#99353 in way that doesn't trigger loplugin:passstuffbyref

c4acf692e8 "loplugin:passstuffbyref" had
accidentally reverted 390ddd3bde "tdf#99353 take
the footgun away from FilterCache".  Many thanks to Matteo Casalin for spotting
it.

Change-Id: I572b940cf215d6e83cac56fd8d2ac2f24b659579
This commit is contained in:
Stephan Bergmann
2016-05-04 10:03:19 +02:00
parent 4efe3bd736
commit 312bf21ae6

View File

@@ -1791,69 +1791,74 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
const CacheItem & aItem) const CacheItem & aItem)
throw(css::uno::Exception) throw(css::uno::Exception)
{ {
// This function changes the properties of aItem one-by-one; but it also
// listens to the configuration changes and reloads the whole item from the
// configuration on change, so use a copy of aItem throughout:
CacheItem copiedItem(aItem);
CacheItem::const_iterator pIt; CacheItem::const_iterator pIt;
switch(eType) switch(eType)
{ {
case E_TYPE : case E_TYPE :
{ {
pIt = aItem.find(PROPNAME_PREFERREDFILTER); pIt = copiedItem.find(PROPNAME_PREFERREDFILTER);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_PREFERREDFILTER, pIt->second); xItem->replaceByName(PROPNAME_PREFERREDFILTER, pIt->second);
pIt = aItem.find(PROPNAME_DETECTSERVICE); pIt = copiedItem.find(PROPNAME_DETECTSERVICE);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_DETECTSERVICE, pIt->second); xItem->replaceByName(PROPNAME_DETECTSERVICE, pIt->second);
pIt = aItem.find(PROPNAME_URLPATTERN); pIt = copiedItem.find(PROPNAME_URLPATTERN);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_URLPATTERN, pIt->second); xItem->replaceByName(PROPNAME_URLPATTERN, pIt->second);
pIt = aItem.find(PROPNAME_EXTENSIONS); pIt = copiedItem.find(PROPNAME_EXTENSIONS);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_EXTENSIONS, pIt->second); xItem->replaceByName(PROPNAME_EXTENSIONS, pIt->second);
pIt = aItem.find(PROPNAME_PREFERRED); pIt = copiedItem.find(PROPNAME_PREFERRED);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_PREFERRED, pIt->second); xItem->replaceByName(PROPNAME_PREFERRED, pIt->second);
pIt = aItem.find(PROPNAME_MEDIATYPE); pIt = copiedItem.find(PROPNAME_MEDIATYPE);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_MEDIATYPE, pIt->second); xItem->replaceByName(PROPNAME_MEDIATYPE, pIt->second);
pIt = aItem.find(PROPNAME_CLIPBOARDFORMAT); pIt = copiedItem.find(PROPNAME_CLIPBOARDFORMAT);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_CLIPBOARDFORMAT, pIt->second); xItem->replaceByName(PROPNAME_CLIPBOARDFORMAT, pIt->second);
css::uno::Reference< css::container::XNameReplace > xUIName; css::uno::Reference< css::container::XNameReplace > xUIName;
xItem->getByName(PROPNAME_UINAME) >>= xUIName; xItem->getByName(PROPNAME_UINAME) >>= xUIName;
impl_savePatchUINames(xUIName, aItem); impl_savePatchUINames(xUIName, copiedItem);
} }
break; break;
case E_FILTER : case E_FILTER :
{ {
pIt = aItem.find(PROPNAME_TYPE); pIt = copiedItem.find(PROPNAME_TYPE);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_TYPE, pIt->second); xItem->replaceByName(PROPNAME_TYPE, pIt->second);
pIt = aItem.find(PROPNAME_FILEFORMATVERSION); pIt = copiedItem.find(PROPNAME_FILEFORMATVERSION);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_FILEFORMATVERSION, pIt->second); xItem->replaceByName(PROPNAME_FILEFORMATVERSION, pIt->second);
pIt = aItem.find(PROPNAME_UICOMPONENT); pIt = copiedItem.find(PROPNAME_UICOMPONENT);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_UICOMPONENT, pIt->second); xItem->replaceByName(PROPNAME_UICOMPONENT, pIt->second);
pIt = aItem.find(PROPNAME_FILTERSERVICE); pIt = copiedItem.find(PROPNAME_FILTERSERVICE);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_FILTERSERVICE, pIt->second); xItem->replaceByName(PROPNAME_FILTERSERVICE, pIt->second);
pIt = aItem.find(PROPNAME_DOCUMENTSERVICE); pIt = copiedItem.find(PROPNAME_DOCUMENTSERVICE);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_DOCUMENTSERVICE, pIt->second); xItem->replaceByName(PROPNAME_DOCUMENTSERVICE, pIt->second);
pIt = aItem.find(PROPNAME_USERDATA); pIt = copiedItem.find(PROPNAME_USERDATA);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_USERDATA, pIt->second); xItem->replaceByName(PROPNAME_USERDATA, pIt->second);
pIt = aItem.find(PROPNAME_TEMPLATENAME); pIt = copiedItem.find(PROPNAME_TEMPLATENAME);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_TEMPLATENAME, pIt->second); xItem->replaceByName(PROPNAME_TEMPLATENAME, pIt->second);
// special handling for flags! Convert it from an integer flag field back // special handling for flags! Convert it from an integer flag field back
// to a list of names ... // to a list of names ...
pIt = aItem.find(PROPNAME_FLAGS); pIt = copiedItem.find(PROPNAME_FLAGS);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
{ {
sal_Int32 nFlags = 0; sal_Int32 nFlags = 0;
pIt->second >>= nFlags; pIt->second >>= nFlags;
@@ -1867,7 +1872,7 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
#ifdef AS_ENABLE_FILTER_UINAMES #ifdef AS_ENABLE_FILTER_UINAMES
css::uno::Reference< css::container::XNameReplace > xUIName; css::uno::Reference< css::container::XNameReplace > xUIName;
xItem->getByName(PROPNAME_UINAME) >>= xUIName; xItem->getByName(PROPNAME_UINAME) >>= xUIName;
impl_savePatchUINames(xUIName, aItem); impl_savePatchUINames(xUIName, copiedItem);
#endif // AS_ENABLE_FILTER_UINAMES #endif // AS_ENABLE_FILTER_UINAMES
} }
break; break;
@@ -1876,8 +1881,8 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
case E_FRAMELOADER : case E_FRAMELOADER :
case E_CONTENTHANDLER : case E_CONTENTHANDLER :
{ {
pIt = aItem.find(PROPNAME_TYPES); pIt = copiedItem.find(PROPNAME_TYPES);
if (pIt != aItem.end()) if (pIt != copiedItem.end())
xItem->replaceByName(PROPNAME_TYPES, pIt->second); xItem->replaceByName(PROPNAME_TYPES, pIt->second);
} }
break; break;