summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-05-17 15:56:05 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-05-18 07:03:14 +0000
commit11f27739ffb0f069a145e411b2ae6b6fb5e16f7a (patch)
tree8be031a02dd55ade1558fbe46efd37fd37869d61
parent45ec74a080e17fc1b521d009d9a5a630a6434bab (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--include/sfx2/classificationhelper.hxx10
-rw-r--r--sc/source/ui/view/formatsh.cxx2
-rw-r--r--sd/source/ui/view/drviews2.cxx2
-rw-r--r--sfx2/source/view/classificationhelper.cxx35
-rw-r--r--sw/source/core/edit/edfcol.cxx2
5 files changed, 45 insertions, 6 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 0ece553235c7..de889fef34b0 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 7b4ba77fbd20..4bec4fbb58b2 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 0be3b6a7c8bb..d3bf56761e22 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 f1e721283c4b..bb6febe015c9 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 4ed3dbc8f0ec..ee6d2428d340 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();