filter/source/config/cache/cacheitem.cxx | 208 ++++++++++++++----------------- starmath/source/mathml/mathmlexport.cxx | 33 ++-- 2 files changed, 119 insertions(+), 122 deletions(-)
New commits: commit 652ac2fb11adaea2ab6b07718aa86579de025a72 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 13 16:02:42 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 14 17:30:58 2022 +0200 cheaper to let Any do the comparison in isSubSet rather than constructing temporary OUStrings Change-Id: Ibb083e3fab8a465ae5288359424b297faac83617 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134317 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/filter/source/config/cache/cacheitem.cxx b/filter/source/config/cache/cacheitem.cxx index 0814e7c49733..b7993eba1b2d 100644 --- a/filter/source/config/cache/cacheitem.cxx +++ b/filter/source/config/cache/cacheitem.cxx @@ -122,151 +122,141 @@ 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; - case css::uno::TypeClass_SEQUENCE : - { - css::uno::Sequence< OUString > uno_s1; - css::uno::Sequence< OUString > uno_s2; + if ( + (aSubSet >>= p1) && + (aSet >>= p2) + ) + { + bool bIs = (p1.Name == p2.Name) && isSubSet(p1.Value, p2.Value); + return bIs; + } - if ( - (aSubSet >>= uno_s1) && - (aSet >>= uno_s2) - ) - { - auto s2Begin = uno_s2.getConstArray(); - auto s2End = uno_s2.getConstArray() + uno_s2.getLength(); + css::beans::NamedValue n1; + css::beans::NamedValue n2; - for (auto const& elem : uno_s1) + if ( + (aSubSet >>= n1) && + (aSet >>= n2) + ) { - if (::std::find(s2Begin, s2End, elem) == s2End) - { - 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; } commit 216c21050ed90a3c80c4d59abbec800e495f2a79 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 13 12:12:47 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 14 17:30:46 2022 +0200 elid some OUString construction in SmXMLExportWrapper::Export Change-Id: Icc091a7fab3c9ce368bd45536de1e75d29431c56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134314 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx index 0fb2573b5b80..64640ae0d96a 100644 --- a/starmath/source/mathml/mathmlexport.cxx +++ b/starmath/source/mathml/mathmlexport.cxx @@ -128,27 +128,31 @@ bool SmXMLExportWrapper::Export(SfxMedium& rMedium) } } + static constexpr OUStringLiteral sUsePrettyPrinting(u"UsePrettyPrinting"); + static constexpr OUStringLiteral sBaseURI(u"BaseURI"); + static constexpr OUStringLiteral sStreamRelPath(u"StreamRelPath"); + static constexpr OUStringLiteral sStreamName(u"StreamName"); + // create XPropertySet with three properties for status indicator comphelper::PropertyMapEntry aInfoMap[] - = { { OUString("UsePrettyPrinting"), 0, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), - beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), + = { { sUsePrettyPrinting, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), + { sBaseURI, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, + 0 }, + { sStreamRelPath, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, + { sStreamName, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, + 0 }, { OUString(), 0, css::uno::Type(), 0, 0 } }; uno::Reference<beans::XPropertySet> xInfoSet( comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aInfoMap))); bool bUsePrettyPrinting = bFlat || officecfg::Office::Common::Save::Document::PrettyPrinting::get(); - xInfoSet->setPropertyValue("UsePrettyPrinting", Any(bUsePrettyPrinting)); + xInfoSet->setPropertyValue(sUsePrettyPrinting, Any(bUsePrettyPrinting)); // Set base URI - OUString sPropName("BaseURI"); - xInfoSet->setPropertyValue(sPropName, Any(rMedium.GetBaseURL(true))); + xInfoSet->setPropertyValue(sBaseURI, Any(rMedium.GetBaseURL(true))); sal_Int32 nSteps = 0; if (xStatusIndicator.is()) @@ -172,8 +176,7 @@ bool SmXMLExportWrapper::Export(SfxMedium& rMedium) if (!aName.isEmpty()) { - sPropName = "StreamRelPath"; - xInfoSet->setPropertyValue(sPropName, Any(aName)); + xInfoSet->setPropertyValue(sStreamRelPath, Any(aName)); } } @@ -292,10 +295,14 @@ bool SmXMLExportWrapper::WriteThroughComponent(const Reference<embed::XStorage>& } uno::Reference<beans::XPropertySet> xSet(xStream, uno::UNO_QUERY); - xSet->setPropertyValue("MediaType", Any(OUString("text/xml"))); + static const OUStringLiteral sMediaType = u"MediaType"; + static const OUStringLiteral sTextXml = u"text/xml"; + xSet->setPropertyValue(sMediaType, Any(OUString(sTextXml))); // all streams must be encrypted in encrypted document - xSet->setPropertyValue("UseCommonStoragePasswordEncryption", Any(true)); + static const OUStringLiteral sUseCommonStoragePasswordEncryption + = u"UseCommonStoragePasswordEncryption"; + xSet->setPropertyValue(sUseCommonStoragePasswordEncryption, Any(true)); // set Base URL if (rPropSet.is())