diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-10-16 07:21:24 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2017-10-16 22:23:51 +0200 |
commit | 54b658d26e01f55800a2358957cde1e44e85b5a3 (patch) | |
tree | 08acdba3c3a4fef8d09afeba18488ab48db1adad /sw | |
parent | 68f8200e1cd22ad9e65d7fce6dfae8f3a24d88c7 (diff) |
TSCP: return empty when a propery is not found
Instead of throwing, since we don't want to display
empty properties in the header/footer.
Change-Id: I6ac205b7ac64ed61487472e0334260bacc2503df
Reviewed-on: https://gerrit.libreoffice.org/43427
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 74a3c6365288..3afe595b2570 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -442,8 +442,16 @@ SwTextFormatColl& SwEditShell::GetTextFormatColl(sal_uInt16 nFormatColl) const OUString lcl_getProperty(uno::Reference<beans::XPropertyContainer> const & rxPropertyContainer, const OUString& rName) { - uno::Reference<beans::XPropertySet> xPropertySet(rxPropertyContainer, uno::UNO_QUERY); - return xPropertySet->getPropertyValue(rName).get<OUString>(); + try + { + uno::Reference<beans::XPropertySet> xPropertySet(rxPropertyContainer, uno::UNO_QUERY); + return xPropertySet->getPropertyValue(rName).get<OUString>(); + } + catch (const css::uno::Exception&) + { + } + + return OUString(); } static bool lcl_containsProperty(const uno::Sequence<beans::Property> & rProperties, const OUString& rName) @@ -524,9 +532,9 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes } } - OUString sPolicy = SfxClassificationHelper::policyTypeToString(SfxClassificationHelper::getPolicyType()); + const OUString sPolicy = SfxClassificationHelper::policyTypeToString(SfxClassificationHelper::getPolicyType()); - std::vector<OUString> aUsedPageStyles = lcl_getUsedPageStyles(this); + const std::vector<OUString> aUsedPageStyles = lcl_getUsedPageStyles(this); for (const OUString& rPageStyleName : aUsedPageStyles) { uno::Reference<beans::XPropertySet> xPageStyle(xStyleFamily->getByName(rPageStyleName), uno::UNO_QUERY); @@ -654,26 +662,30 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio xPropertySet->getPropertyValue(UNO_NAME_NAME) >>= aName; if (aName.startsWith(sPolicy + "Marking:Text:")) { - OUString aValue = lcl_getProperty(xPropertyContainer, aName); - aResult.push_back({ svx::ClassificationType::TEXT, aValue, nParagraph }); + const OUString aValue = lcl_getProperty(xPropertyContainer, aName); + if (!aValue.isEmpty()) + aResult.push_back({ svx::ClassificationType::TEXT, aValue, nParagraph }); } else if (aName.startsWith(sPolicy + "BusinessAuthorizationCategory:Name")) { - OUString aValue = lcl_getProperty(xPropertyContainer, aName); - aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, nParagraph }); + const OUString aValue = lcl_getProperty(xPropertyContainer, aName); + if (!aValue.isEmpty()) + aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, nParagraph }); } else if (aName.startsWith(sPolicy + "Extension:Marking")) { - OUString aValue = lcl_getProperty(xPropertyContainer, aName); - aResult.push_back({ svx::ClassificationType::MARKING, aValue, nParagraph }); + const OUString aValue = lcl_getProperty(xPropertyContainer, aName); + if (!aValue.isEmpty()) + aResult.push_back({ svx::ClassificationType::MARKING, aValue, nParagraph }); } else if (aName.startsWith(sPolicy + "Extension:IntellectualPropertyPart")) { - OUString aValue = lcl_getProperty(xPropertyContainer, aName); - aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, nParagraph }); + const OUString aValue = lcl_getProperty(xPropertyContainer, aName); + if (!aValue.isEmpty()) + aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, nParagraph }); } } - nParagraph++; + ++nParagraph; } return aResult; @@ -687,7 +699,7 @@ void SwEditShell::SetClassification(const OUString& rName, SfxClassificationPoli SfxClassificationHelper aHelper(pDocShell->getDocProperties()); - bool bHadWatermark = !aHelper.GetDocumentWatermark().isEmpty(); + const bool bHadWatermark = !aHelper.GetDocumentWatermark().isEmpty(); // This updates the infobar as well. aHelper.SetBACName(rName, eType); |