summaryrefslogtreecommitdiffstats
path: root/filter/source/config/cache/cacheitem.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/config/cache/cacheitem.cxx')
-rw-r--r--filter/source/config/cache/cacheitem.cxx241
1 files changed, 116 insertions, 125 deletions
diff --git a/filter/source/config/cache/cacheitem.cxx b/filter/source/config/cache/cacheitem.cxx
index a406b16ff130..dddb7d464286 100644
--- a/filter/source/config/cache/cacheitem.cxx
+++ b/filter/source/config/cache/cacheitem.cxx
@@ -40,13 +40,7 @@ CacheItem::CacheItem()
void CacheItem::update(const CacheItem& rUpdateItem)
{
for (auto const& elem : rUpdateItem)
- {
- iterator pItThis = find(elem.first);
- if (pItThis == end())
- (*this)[elem.first] = elem.second; // add new prop
- else
- pItThis->second = elem.second; // change value of existing prop
- }
+ (*this)[elem.first] = elem.second;
}
@@ -83,28 +77,35 @@ void CacheItem::validateUINames(const OUString& sActLocale)
}
-css::uno::Sequence< css::beans::PropertyValue > CacheItem::getAsPackedPropertyValueList()
+css::uno::Sequence< css::beans::PropertyValue > CacheItem::getAsPackedPropertyValueList(bool bFinalized, bool bMandatory) const
{
sal_Int32 c = static_cast<sal_Int32>(size());
sal_Int32 i = 0;
- css::uno::Sequence< css::beans::PropertyValue > lList(c);
+ css::uno::Sequence< css::beans::PropertyValue > lList(c+2);
css::beans::PropertyValue* pList = lList.getArray();
for (const_iterator pProp = begin();
pProp != end() ;
++pProp )
{
- const OUString& rName = pProp->first;
+ const OUString& rName = pProp->first.maString;
const css::uno::Any& rValue = pProp->second;
if (!rValue.hasValue())
continue;
+ assert (rName != PROPNAME_FINALIZED && rName != PROPNAME_MANDATORY);
pList[i].Name = rName ;
pList[i].Value = rValue;
++i;
}
+ pList[i].Name = PROPNAME_FINALIZED ;
+ pList[i].Value <<= bFinalized;
+ ++i;
+ pList[i].Name = PROPNAME_MANDATORY ;
+ pList[i].Value <<= bMandatory;
+ ++i;
lList.realloc(i);
return lList;
@@ -122,169 +123,159 @@ static bool isSubSet(const css::uno::Any& aSubSet,
return false;
}
- css::uno::TypeClass aTypeClass = aT1.getTypeClass();
- switch(aTypeClass)
+ if (aSubSet.hasValue() && aSet.hasValue())
{
-
- case css::uno::TypeClass_BOOLEAN :
- case css::uno::TypeClass_BYTE :
- case css::uno::TypeClass_SHORT :
- case css::uno::TypeClass_UNSIGNED_SHORT :
- case css::uno::TypeClass_LONG :
- case css::uno::TypeClass_UNSIGNED_LONG :
- case css::uno::TypeClass_HYPER :
- case css::uno::TypeClass_UNSIGNED_HYPER :
- case css::uno::TypeClass_FLOAT :
- case css::uno::TypeClass_DOUBLE :
- {
- bool bIs = (aSubSet == aSet);
- return bIs;
- }
-
-
- case css::uno::TypeClass_STRING :
+ css::uno::TypeClass aTypeClass = aT1.getTypeClass();
+ switch(aTypeClass)
{
- OUString v1;
- OUString v2;
- if (
- (aSubSet >>= v1) &&
- (aSet >>= v2)
- )
+ case css::uno::TypeClass_BOOLEAN :
+ case css::uno::TypeClass_BYTE :
+ case css::uno::TypeClass_SHORT :
+ case css::uno::TypeClass_UNSIGNED_SHORT :
+ case css::uno::TypeClass_LONG :
+ case css::uno::TypeClass_UNSIGNED_LONG :
+ case css::uno::TypeClass_HYPER :
+ case css::uno::TypeClass_UNSIGNED_HYPER :
+ case css::uno::TypeClass_FLOAT :
+ case css::uno::TypeClass_DOUBLE :
{
- bool bIs = v1 == v2;
+ bool bIs = (aSubSet == aSet);
return bIs;
}
- }
- break;
- case css::uno::TypeClass_STRUCT :
- {
- css::beans::PropertyValue p1;
- css::beans::PropertyValue p2;
+ case css::uno::TypeClass_STRING :
+ return aSubSet == aSet;
+ break;
- if (
- (aSubSet >>= p1) &&
- (aSet >>= p2)
- )
- {
- bool bIs = (p1.Name == p2.Name) && isSubSet(p1.Value, p2.Value);
- return bIs;
- }
- css::beans::NamedValue n1;
- css::beans::NamedValue n2;
-
- if (
- (aSubSet >>= n1) &&
- (aSet >>= n2)
- )
+ case css::uno::TypeClass_STRUCT :
{
- bool bIs = (n1.Name == n2.Name) && isSubSet(n1.Value, n2.Value);
- return bIs;
- }
- }
- break;
+ css::beans::PropertyValue p1;
+ css::beans::PropertyValue p2;
+ if (
+ (aSubSet >>= p1) &&
+ (aSet >>= p2)
+ )
+ {
+ bool bIs = (p1.Name == p2.Name) && isSubSet(p1.Value, p2.Value);
+ return bIs;
+ }
- case css::uno::TypeClass_SEQUENCE :
- {
- css::uno::Sequence< OUString > uno_s1;
- css::uno::Sequence< OUString > uno_s2;
-
- if (
- (aSubSet >>= uno_s1) &&
- (aSet >>= uno_s2)
- )
- {
- std::vector<OUString> stl_s1(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s1));
- std::vector<OUString> stl_s2(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s2));
+ css::beans::NamedValue n1;
+ css::beans::NamedValue n2;
- for (auto const& elem : stl_s1)
+ if (
+ (aSubSet >>= n1) &&
+ (aSet >>= n2)
+ )
{
- if (::std::find(stl_s2.begin(), stl_s2.end(), elem) == stl_s2.end())
- {
- return false;
- }
+ bool bIs = (n1.Name == n2.Name) && isSubSet(n1.Value, n2.Value);
+ return bIs;
}
- return true;
}
+ break;
- css::uno::Sequence< css::beans::PropertyValue > uno_p1;
- css::uno::Sequence< css::beans::PropertyValue > uno_p2;
- if (
- (aSubSet >>= uno_p1) &&
- (aSet >>= uno_p2)
- )
+ case css::uno::TypeClass_SEQUENCE :
{
- ::comphelper::SequenceAsHashMap stl_p1(uno_p1);
- ::comphelper::SequenceAsHashMap stl_p2(uno_p2);
+ css::uno::Sequence< OUString > uno_s1;
+ css::uno::Sequence< OUString > uno_s2;
- for (auto const& elem : stl_p1)
+ if (
+ (aSubSet >>= uno_s1) &&
+ (aSet >>= uno_s2)
+ )
{
- ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_p2.find(elem.first);
- if (it2 == stl_p2.end())
- {
- return false;
- }
- if (!isSubSet(elem.second, it2->second))
+ auto s2Begin = uno_s2.getConstArray();
+ auto s2End = uno_s2.getConstArray() + uno_s2.getLength();
+
+ for (auto const& elem : uno_s1)
{
- return false;
+ if (::std::find(s2Begin, s2End, elem) == s2End)
+ {
+ return false;
+ }
}
+ return true;
}
- return true;
- }
- css::uno::Sequence< css::beans::NamedValue > uno_n1;
- css::uno::Sequence< css::beans::NamedValue > uno_n2;
+ css::uno::Sequence< css::beans::PropertyValue > uno_p1;
+ css::uno::Sequence< css::beans::PropertyValue > uno_p2;
- if (
- (aSubSet >>= uno_n1) &&
- (aSet >>= uno_n2)
- )
- {
- ::comphelper::SequenceAsHashMap stl_n1(uno_n1);
- ::comphelper::SequenceAsHashMap stl_n2(uno_n2);
-
- for (auto const& elem : stl_n1)
+ if (
+ (aSubSet >>= uno_p1) &&
+ (aSet >>= uno_p2)
+ )
{
- ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_n2.find(elem.first);
- if (it2 == stl_n2.end())
+ ::comphelper::SequenceAsHashMap stl_p1(uno_p1);
+ ::comphelper::SequenceAsHashMap stl_p2(uno_p2);
+
+ for (auto const& elem : stl_p1)
{
- return false;
+ ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_p2.find(elem.first);
+ if (it2 == stl_p2.end())
+ {
+ return false;
+ }
+ if (!isSubSet(elem.second, it2->second))
+ {
+ return false;
+ }
}
- if (!isSubSet(elem.second, it2->second))
+ return true;
+ }
+
+ css::uno::Sequence< css::beans::NamedValue > uno_n1;
+ css::uno::Sequence< css::beans::NamedValue > uno_n2;
+
+ if (
+ (aSubSet >>= uno_n1) &&
+ (aSet >>= uno_n2)
+ )
+ {
+ ::comphelper::SequenceAsHashMap stl_n1(uno_n1);
+ ::comphelper::SequenceAsHashMap stl_n2(uno_n2);
+
+ for (auto const& elem : stl_n1)
{
- return false;
+ ::comphelper::SequenceAsHashMap::const_iterator it2 = stl_n2.find(elem.first);
+ if (it2 == stl_n2.end())
+ {
+ return false;
+ }
+ if (!isSubSet(elem.second, it2->second))
+ {
+ return false;
+ }
}
+ return true;
}
- return true;
}
+ break;
+ default: break;
}
- break;
- default: break;
}
-
OSL_FAIL("isSubSet() ... this point should not be reached!");
return false;
}
-bool CacheItem::haveProps(const CacheItem& lProps) const
+bool CacheItem::haveProps(std::span< const css::beans::NamedValue > lProps) const
{
for (auto const& prop : lProps)
{
// i) one required property does not exist at this item => return false
- const_iterator pItThis = find(prop.first);
+ const_iterator pItThis = find(prop.Name);
if (pItThis == end())
{
return false;
}
// ii) one item does not have the right value => return false
- if (!isSubSet(prop.second, pItThis->second))
+ if (!isSubSet(prop.Value, pItThis->second))
{
return false;
}
@@ -297,7 +288,7 @@ bool CacheItem::haveProps(const CacheItem& lProps) const
}
-bool CacheItem::dontHaveProps(const CacheItem& lProps) const
+bool CacheItem::dontHaveProps(std::span< const css::beans::NamedValue > lProps) const
{
for (auto const& prop : lProps)
{
@@ -305,7 +296,7 @@ bool CacheItem::dontHaveProps(const CacheItem& lProps) const
// => continue with next one, because
// "excluding" means... "don't have it".
// And "not exists" matches to "don't have it".
- const_iterator pItThis = find(prop.first);
+ const_iterator pItThis = find(prop.Name);
if (pItThis == end())
{
continue;
@@ -314,7 +305,7 @@ bool CacheItem::dontHaveProps(const CacheItem& lProps) const
// ii) one item have the right value => return false
// because this item has the requested property...
// But we checked for "don't have it" here.
- if (isSubSet(prop.second, pItThis->second))
+ if (isSubSet(prop.Value, pItThis->second))
{
return false;
}