summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-08 14:29:15 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-08 18:19:12 +0100
commit740a72e66ddf3efd4028d8268239f9a50f759499 (patch)
tree996ff3cf8f54f0fca46101c0ec6690831528bde7
parent1316543eb89a8c30edf547c76852f3e0f8ae848e (diff)
sfx2 classification: expose impact scale and level
This allows application code to prevent copypaste from a more confidential to a less confidential document. Change-Id: I121c7566c948340e7b41d3f8462b0d65a2441b0f
-rw-r--r--include/sfx2/classificationhelper.hxx6
-rw-r--r--sfx2/source/view/classificationhelper.cxx72
2 files changed, 71 insertions, 7 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 5b0070203b69..5c49db700e13 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -40,9 +40,13 @@ public:
std::vector<OUString> GetBACNames();
/// Setting this sets all the other properties, based on the policy.
void SetBACName(const OUString& rName);
- /// If GetImpactLevelColor() will return something meaningful.
+ /// If GetImpactScale() and GetImpactLevel*() will return something meaningful.
bool HasImpactLevel();
basegfx::BColor GetImpactLevelColor();
+ /// Larger value means more confidential.
+ sal_Int32 GetImpactLevel();
+ /// Comparing the GetImpactLevel() result is only meaningful when the impact scale is the same.
+ OUString GetImpactScale();
OUString GetDocumentWatermark();
/// The selected category has some content for the document header.
bool HasDocumentHeader();
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 349c33749ce9..c3161b651b93 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -56,6 +56,18 @@ const OUString& PROP_NONE()
return sProp;
}
+const OUString& PROP_IMPACTSCALE()
+{
+ static OUString sProp("urn:bails:IntellectualProperty:Impact:Scale");
+ return sProp;
+}
+
+const OUString& PROP_IMPACTLEVEL()
+{
+ static OUString sProp("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ return sProp;
+}
+
/// Represents one category of a classification policy.
class SfxClassificationCategory
{
@@ -236,7 +248,7 @@ void SAL_CALL SfxClassificationParser::endElement(const OUString& rName) throw (
{
m_bInScale = false;
if (m_pCategory)
- m_pCategory->m_aLabels["urn:bails:IntellectualProperty:Impact:Scale"] = m_aScale;
+ m_pCategory->m_aLabels[PROP_IMPACTSCALE()] = m_aScale;
}
else if (rName == "baf:ConfidentalityValue")
{
@@ -244,7 +256,7 @@ void SAL_CALL SfxClassificationParser::endElement(const OUString& rName) throw (
if (m_pCategory)
{
std::map<OUString, OUString>& rLabels = m_pCategory->m_aLabels;
- rLabels["urn:bails:IntellectualProperty:Impact:Level:Confidentiality"] = m_aConfidentalityValue;
+ rLabels[PROP_IMPACTLEVEL()] = m_aConfidentalityValue;
// Set the two other type of levels as well, if they're not set
// yet: they're optional in BAF, but not in BAILS.
if (rLabels.find("urn:bails:IntellectualProperty:Impact:Level:Integrity") == rLabels.end())
@@ -451,11 +463,11 @@ const OUString& SfxClassificationHelper::GetBACName()
bool SfxClassificationHelper::HasImpactLevel()
{
- std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find("urn:bails:IntellectualProperty:Impact:Scale");
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTSCALE());
if (it == m_pImpl->m_aCategory.m_aLabels.end())
return false;
- it = m_pImpl->m_aCategory.m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTLEVEL());
if (it == m_pImpl->m_aCategory.m_aLabels.end())
return false;
@@ -484,12 +496,12 @@ basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
{
basegfx::BColor aRet;
- std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find("urn:bails:IntellectualProperty:Impact:Scale");
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTSCALE());
if (it == m_pImpl->m_aCategory.m_aLabels.end())
return aRet;
OUString aScale = it->second;
- it = m_pImpl->m_aCategory.m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTLEVEL());
if (it == m_pImpl->m_aCategory.m_aLabels.end())
return aRet;
OUString aLevel = it->second;
@@ -530,6 +542,54 @@ basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
return aRet;
}
+sal_Int32 SfxClassificationHelper::GetImpactLevel()
+{
+ sal_Int32 nRet = -1;
+
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTSCALE());
+ if (it == m_pImpl->m_aCategory.m_aLabels.end())
+ return nRet;
+ OUString aScale = it->second;
+
+ it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTLEVEL());
+ if (it == m_pImpl->m_aCategory.m_aLabels.end())
+ return nRet;
+ OUString aLevel = it->second;
+
+ if (aScale == "UK-Cabinet")
+ {
+ sal_Int32 nValue = aLevel.toInt32();
+ if (nValue < 0 || nValue > 3)
+ return nRet;
+ nRet = nValue;
+ }
+ else if (aScale == "FIPS-199")
+ {
+ static std::map<OUString, sal_Int32> aValues;
+ if (aValues.empty())
+ {
+ aValues["Low"] = 0;
+ aValues["Moderate"] = 1;
+ aValues["High"] = 2;
+ }
+ std::map<OUString, sal_Int32>::iterator itValues = aValues.find(aLevel);
+ if (itValues == aValues.end())
+ return nRet;
+ nRet = itValues->second;
+ }
+
+ return nRet;
+}
+
+OUString SfxClassificationHelper::GetImpactScale()
+{
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find(PROP_IMPACTSCALE());
+ if (it != m_pImpl->m_aCategory.m_aLabels.end())
+ return it->second;
+
+ return OUString();
+}
+
OUString SfxClassificationHelper::GetDocumentWatermark()
{
std::map<OUString, OUString>::iterator it = m_pImpl->m_aCategory.m_aLabels.find(SfxClassificationHelper::PROP_DOCWATERMARK());