[Libreoffice-commits] core.git: sw/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Oct 16 20:24:16 UTC 2017


 sw/source/core/edit/edfcol.cxx |   40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

New commits:
commit 54b658d26e01f55800a2358957cde1e44e85b5a3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Oct 16 07:21:24 2017 -0400

    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 at libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

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);


More information about the Libreoffice-commits mailing list