diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-29 14:44:53 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-29 17:19:49 +0100 |
commit | 98f7e70aeb5c445a04a45cebce7553cb23d57e65 (patch) | |
tree | ac9fb18351f0d6c82098ceebb92bd37c2aa2c4f2 /sfx2/source/view | |
parent | 12f8d5b2d5ea76b2755cb6fe05f28928aedd148c (diff) |
sfx2 classification: fix category name duplication
A category name was stored in m_aName and also as a label value with key
name PROP_BACNAME(). Fix this by always using m_aName, and doing the
conversion in both directions in
SfxClassificationHelper::Impl::pushToObjectShell() and the
SfxClassificationHelper() ctor, as document metadata wants to work with
only key-vaulue pairs.
Change-Id: Iad386840038966e4483e3503c5fcdc046ca9effc
Diffstat (limited to 'sfx2/source/view')
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index f8d73350fe44..8fc5190a2804 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -40,6 +40,7 @@ namespace class SfxClassificationCategory { public: + /// PROP_BACNAME() is stored separately for easier lookup. OUString m_aName; std::map<OUString, OUString> m_aLabels; }; @@ -147,7 +148,6 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception) rCategory.m_aLabels["urn:bails:IntellectualProperty:Policy:Name"] = m_aPolicyName; rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Identifier"] = m_aProgramID; rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Identifier"] = aIdentifier; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Name"] = aName; // Also initialize defaults. rCategory.m_aLabels["urn:bails:IntellectualProperty:PolicyAuthority:Identifier"] = "None"; @@ -279,6 +279,12 @@ void SAL_CALL SfxClassificationParser::setDocumentLocator(const uno::Reference<x { } +const OUString& PROP_BACNAME() +{ + static OUString sProp("urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Name"); + return sProp; +} + } // anonymous namespace /// Implementation details of SfxClassificationHelper. @@ -339,7 +345,9 @@ void SfxClassificationHelper::Impl::pushToObjectShell() uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties(); uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY); uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties(); - for (const std::pair<OUString, OUString>& rLabel : m_aCategory.m_aLabels) + std::map<OUString, OUString> aLabels = m_aCategory.m_aLabels; + aLabels[PROP_BACNAME()] = m_aCategory.m_aName; + for (const std::pair<OUString, OUString>& rLabel : aLabels) { try { @@ -391,7 +399,12 @@ SfxClassificationHelper::SfxClassificationHelper(SfxObjectShell& rObjectShell) uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name); OUString aValue; if (aAny >>= aValue) - m_pImpl->m_aCategory.m_aLabels[rProperty.Name] = aValue; + { + if (rProperty.Name == PROP_BACNAME()) + m_pImpl->m_aCategory.m_aName = aValue; + else + m_pImpl->m_aCategory.m_aLabels[rProperty.Name] = aValue; + } } } @@ -399,13 +412,9 @@ SfxClassificationHelper::~SfxClassificationHelper() { } -OUString SfxClassificationHelper::GetBACName() +const OUString& SfxClassificationHelper::GetBACName() { - std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find("urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Name"); - if (it != m_pImpl->m_aCategory.m_aLabels.end()) - return it->second; - - return OUString(); + return m_pImpl->m_aCategory.m_aName; } bool SfxClassificationHelper::HasImpactLevel() @@ -526,7 +535,7 @@ void SfxClassificationHelper::SetBACName(const OUString& rName) return; } - m_pImpl->m_aCategory.m_aLabels = it->m_aLabels; + m_pImpl->m_aCategory = *it; m_pImpl->pushToObjectShell(); SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if (!pViewFrame) |