[Libreoffice-commits] core.git: include/sfx2 sc/source sd/source sfx2/source sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed May 18 07:03:34 UTC 2016
include/sfx2/classificationhelper.hxx | 10 +++++++-
sc/source/ui/view/formatsh.cxx | 2 -
sd/source/ui/view/drviews2.cxx | 2 -
sfx2/source/view/classificationhelper.cxx | 35 ++++++++++++++++++++++++++++--
sw/source/core/edit/edfcol.cxx | 2 -
5 files changed, 45 insertions(+), 6 deletions(-)
New commits:
commit 11f27739ffb0f069a145e411b2ae6b6fb5e16f7a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue May 17 15:56:05 2016 +0200
sfx2 classification: specify policy type when setting a category
This will allow specifying multiple categories for multiple policy
types.
Separate storage and .uno: command support is still missing, though.
Change-Id: I47f6ac2e2b0ba2632b32349e4e004ffade05784a
Reviewed-on: https://gerrit.libreoffice.org/25064
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 0ece553..de889fe 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -33,6 +33,14 @@ enum class SfxClassificationCheckPasteResult
DocClassificationTooLow = 3
};
+/// Specifies a policy type, to be used with SetBACName(). Getters always use IntellectualProperty for now.
+enum class SfxClassificationPolicyType
+{
+ ExportControl,
+ NationalSecurity,
+ IntellectualProperty
+};
+
/// Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties.
class SFX2_DLLPUBLIC SfxClassificationHelper
{
@@ -54,7 +62,7 @@ public:
/// Return all possible valid category names, based on the policy.
std::vector<OUString> GetBACNames();
/// Setting this sets all the other properties, based on the policy.
- void SetBACName(const OUString& rName);
+ void SetBACName(const OUString& rName, SfxClassificationPolicyType eType);
/// If GetImpactScale() and GetImpactLevel*() will return something meaningful.
bool HasImpactLevel();
basegfx::BColor GetImpactLevelColor();
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 7b4ba77..4bec4fb 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -974,7 +974,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
{
const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
SfxClassificationHelper aHelper(pDocSh->getDocProperties());
- aHelper.SetBACName(rName);
+ aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
}
else
SAL_WARN("sc.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 0be3b6a..d3bf567 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1156,7 +1156,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
if (SfxObjectShell* pObjectShell = pViewFrame->GetObjectShell())
{
SfxClassificationHelper aHelper(pObjectShell->getDocProperties());
- aHelper.SetBACName(rName);
+ aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
}
}
}
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index f1e7212..bb6febe 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -70,6 +70,36 @@ const OUString& PROP_IMPACTLEVEL()
return sProp;
}
+const OUString& PROP_PREFIX_EXPORTCONTROL()
+{
+ static OUString sProp("urn:bails:ExportControl:");
+ return sProp;
+}
+
+const OUString& PROP_PREFIX_NATIONALSECURITY()
+{
+ static OUString sProp("urn:bails:NationalSecurity:");
+ return sProp;
+}
+
+/// Converts a SfxClassificationPolicyType to a TSCP_BAILSv1 string value.
+const OUString& policyTypeToString(SfxClassificationPolicyType eType)
+{
+ switch (eType)
+ {
+ case SfxClassificationPolicyType::ExportControl:
+ return PROP_PREFIX_EXPORTCONTROL();
+ break;
+ case SfxClassificationPolicyType::NationalSecurity:
+ return PROP_PREFIX_NATIONALSECURITY();
+ break;
+ default:
+ break;
+ }
+
+ return SfxClassificationHelper::PROP_PREFIX_INTELLECTUALPROPERTY();
+}
+
/// Represents one category of a classification policy.
class SfxClassificationCategory
{
@@ -669,7 +699,7 @@ std::vector<OUString> SfxClassificationHelper::GetBACNames()
return aRet;
}
-void SfxClassificationHelper::SetBACName(const OUString& rName)
+void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificationPolicyType eType)
{
if (m_pImpl->m_aCategories.empty())
m_pImpl->parsePolicy();
@@ -686,8 +716,9 @@ void SfxClassificationHelper::SetBACName(const OUString& rName)
m_pImpl->m_aCategory.m_aName = it->m_aName;
m_pImpl->m_aCategory.m_aLabels.clear();
+ const OUString& rPrefix = policyTypeToString(eType);
for (const auto& rLabel : it->m_aLabels)
- m_pImpl->m_aCategory.m_aLabels[PROP_PREFIX_INTELLECTUALPROPERTY() + rLabel.first] = rLabel.second;
+ m_pImpl->m_aCategory.m_aLabels[rPrefix + rLabel.first] = rLabel.second;
m_pImpl->setStartValidity();
m_pImpl->pushToDocumentProperties();
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 4ed3dbc..ee6d242 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -182,7 +182,7 @@ void SwEditShell::SetClassification(const OUString& rName)
bool bHadWatermark = !aHelper.GetDocumentWatermark().isEmpty();
// This updates the infobar as well.
- aHelper.SetBACName(rName);
+ aHelper.SetBACName(rName, SfxClassificationPolicyType::IntellectualProperty);
bool bHeaderIsNeeded = aHelper.HasDocumentHeader();
bool bFooterIsNeeded = aHelper.HasDocumentFooter();
More information about the Libreoffice-commits
mailing list