From ae5c80502b4f7d9bfb6a09cd28ab72594552037d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 3 Mar 2016 10:06:07 +0100 Subject: sfx2 classification: replace default start date with current time ... ... unless the policy changes the default already. This was the date of the classification is stored in the document, and can be inserted as a field as well, but if the policy has an explicit classification start date, we don't overwrite that. Change-Id: I17974d73a415a2c8032df48aa7b7f4eebb7178ab --- sfx2/source/view/classificationhelper.cxx | 68 +++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index f086ade5ed00..349c33749ce9 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -29,7 +29,8 @@ #include #include #include -#include +#include +#include #include using namespace com::sun::star; @@ -37,6 +38,24 @@ using namespace com::sun::star; namespace { +const OUString& PROP_BACNAME() +{ + static OUString sProp("urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Name"); + return sProp; +} + +const OUString& PROP_STARTVALIDITY() +{ + static OUString sProp("urn:bails:IntellectualProperty:Authorization:StartValidity"); + return sProp; +} + +const OUString& PROP_NONE() +{ + static OUString sProp("None"); + return sProp; +} + /// Represents one category of a classification policy. class SfxClassificationCategory { @@ -151,15 +170,15 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception) rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Identifier"] = aIdentifier; // Also initialize defaults. - rCategory.m_aLabels["urn:bails:IntellectualProperty:PolicyAuthority:Identifier"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:PolicyAuthority:Country"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:Policy:Identifier"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Name"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Locator"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Identifier:OID"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Locator"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Locator"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:MarkingPrecedence"] = "None"; + rCategory.m_aLabels["urn:bails:IntellectualProperty:PolicyAuthority:Identifier"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:PolicyAuthority:Country"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:Policy:Identifier"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Name"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Locator"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Identifier:OID"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorizationCategory:Locator"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:BusinessAuthorization:Locator"] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:MarkingPrecedence"] = PROP_NONE(); rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:general-summary"].clear(); rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:general-warning-statement"].clear(); rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:general-warning-statement:ext:2"].clear(); @@ -176,8 +195,8 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception) rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:email-last-line-of-text"].clear(); rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:email-subject-prefix"].clear(); rCategory.m_aLabels["urn:bails:IntellectualProperty:Marking:email-subject-suffix"].clear(); - rCategory.m_aLabels["urn:bails:IntellectualProperty:Authorization:StartValidity"] = "None"; - rCategory.m_aLabels["urn:bails:IntellectualProperty:Authorization:StopValidity"] = "None"; + rCategory.m_aLabels[PROP_STARTVALIDITY()] = PROP_NONE(); + rCategory.m_aLabels["urn:bails:IntellectualProperty:Authorization:StopValidity"] = PROP_NONE(); m_pCategory = &rCategory; } } @@ -280,12 +299,6 @@ void SAL_CALL SfxClassificationParser::setDocumentLocator(const uno::Reference& rProperties, con }) != rProperties.end(); } +void SfxClassificationHelper::Impl::setStartValidity() +{ + std::map::iterator it = m_aCategory.m_aLabels.find(PROP_STARTVALIDITY()); + if (it != m_aCategory.m_aLabels.end()) + { + if (it->second == PROP_NONE()) + { + // The policy left the start date unchanged, replace it with the system time. + util::DateTime aDateTime = DateTime(DateTime::SYSTEM).GetUNODateTime(); + OUStringBuffer aBuffer = utl::toISO8601(aDateTime); + it->second = aBuffer.toString(); + } + } +} + void SfxClassificationHelper::Impl::pushToObjectShell() { uno::Reference xDocumentProperties = m_rObjectShell.getDocProperties(); @@ -538,6 +568,8 @@ void SfxClassificationHelper::SetBACName(const OUString& rName) } m_pImpl->m_aCategory = *it; + + m_pImpl->setStartValidity(); m_pImpl->pushToObjectShell(); SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if (!pViewFrame) -- cgit