summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-17 16:01:50 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-17 16:47:36 +0100
commit6bf7f9808ddbaea5db5ca1ae1eedfe808b142503 (patch)
treebe6291af6830b587247012477637b8dd899716ae
parent946e12ac87237a1885fd3996a5549f56cc7de3a3 (diff)
sfx2 classification: color the infobar according to the impact level
Change-Id: I43c6537290aa5ce8a9dcc034d4ff6776668cde0c
-rw-r--r--include/sfx2/classificationhelper.hxx9
-rw-r--r--sfx2/source/view/classificationhelper.cxx64
-rw-r--r--sfx2/source/view/viewfrm.cxx8
3 files changed, 71 insertions, 10 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 86627429816f..c62ffac7bfc9 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -16,6 +16,10 @@
#include <sfx2/dllapi.h>
class SfxObjectShell;
+namespace basegfx
+{
+class BColor;
+}
/// Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties.
class SFX2_DLLPUBLIC SfxClassificationHelper
@@ -30,8 +34,9 @@ public:
SfxClassificationHelper(SfxObjectShell& rObjectShell);
~SfxClassificationHelper();
OUString GetBACName();
- /// Impact level is a string, as the scale can be integer-based, but can be also low/high.
- OUString GetImpactLevel();
+ /// If GetImpactLevelColor() will return something meaningful.
+ bool HasImpactLevel();
+ basegfx::BColor GetImpactLevelColor();
};
#endif
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 7ad5cb331210..9270c4616421 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -78,13 +78,67 @@ OUString SfxClassificationHelper::GetBACName()
return OUString();
}
-OUString SfxClassificationHelper::GetImpactLevel()
+bool SfxClassificationHelper::HasImpactLevel()
{
- std::map<OUString, OUString>::iterator it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
- if (it != m_pImpl->m_aLabels.end())
- return it->second;
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Scale");
+ if (it == m_pImpl->m_aLabels.end())
+ return false;
- return OUString();
+ it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ if (it == m_pImpl->m_aLabels.end())
+ return false;
+
+ return true;
+}
+
+basegfx::BColor SfxClassificationHelper::GetImpactLevelColor()
+{
+ basegfx::BColor aRet;
+
+ std::map<OUString, OUString>::iterator it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Scale");
+ if (it == m_pImpl->m_aLabels.end())
+ return aRet;
+ OUString aScale = it->second;
+
+ it = m_pImpl->m_aLabels.find("urn:bails:IntellectualProperty:Impact:Level:Confidentiality");
+ if (it == m_pImpl->m_aLabels.end())
+ return aRet;
+ OUString aLevel = it->second;
+
+ // The spec defines two valid scale values: FIPS-199 and UK-Cabinet.
+ if (aScale == "UK-Cabinet")
+ {
+ static std::map<OUString, basegfx::BColor> aColors;
+ if (aColors.empty())
+ {
+ // Green -> brown -> orange -> red.
+ aColors["0"] = basegfx::BColor(0.0, 0.5, 0.0);
+ aColors["1"] = basegfx::BColor(0.5, 0.5, 0.0);
+ aColors["2"] = basegfx::BColor(1.0, 0.5, 0.0);
+ aColors["3"] = basegfx::BColor(0.5, 0.0, 0.0);
+ }
+ std::map<OUString, basegfx::BColor>::iterator itColor = aColors.find(aLevel);
+ if (itColor == aColors.end())
+ return aRet;
+ aRet = itColor->second;
+ }
+ else if (aScale == "FIPS-199")
+ {
+ static std::map<OUString, basegfx::BColor> aColors;
+ if (aColors.empty())
+ {
+ // Green -> orange -> red.
+ aColors["Low"] = basegfx::BColor(0.0, 0.5, 0.0);
+ aColors["Moderate"] = basegfx::BColor(1.0, 0.5, 0.0);
+ aColors["High"] = basegfx::BColor(0.5, 0.0, 0.0);
+ }
+ std::map<OUString, basegfx::BColor>::iterator itColor = aColors.find(aLevel);
+ if (itColor == aColors.end())
+ return aRet;
+ aRet = itColor->second;
+ }
+
+ return aRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 46a718c8eefa..f7315c7428a4 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1349,12 +1349,14 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
// Document has BAILS properties, display an infobar accordingly.
SfxClassificationHelper aHelper(*xObjSh.get());
OUString aBACName = aHelper.GetBACName();
- OUString aImpactLevel = aHelper.GetImpactLevel();
- if (!aBACName.isEmpty() && !aImpactLevel.isEmpty())
+ bool bImpactLevel = aHelper.HasImpactLevel();
+ if (!aBACName.isEmpty() && bImpactLevel)
{
OUString aMessage = SfxResId(STR_CLASSIFIED_DOCUMENT);
aMessage = aMessage.replaceFirst("%1", aBACName);
- AppendInfoBar("classification", aMessage);
+ basegfx::BColor aBackgroundColor = aHelper.GetImpactLevelColor();
+ basegfx::BColor aForegroundColor(1.0, 1.0, 1.0);
+ AppendInfoBar("classification", aMessage, &aBackgroundColor, &aForegroundColor, &aForegroundColor, WB_CENTER);
}
}