Kaydet (Commit) db61ca5b authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

TSCP: support abbreviated classification names

Change-Id: Ib7edc491d2f8a69c48f1515ba29d79e09c88c3b7
Reviewed-on: https://gerrit.libreoffice.org/43627Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst e4c912f6
...@@ -63,6 +63,10 @@ public: ...@@ -63,6 +63,10 @@ public:
const OUString& GetBACName(SfxClassificationPolicyType eType); const OUString& GetBACName(SfxClassificationPolicyType eType);
/// Return all possible valid category names, based on the policy. /// Return all possible valid category names, based on the policy.
std::vector<OUString> GetBACNames(); std::vector<OUString> GetBACNames();
/// Get the currently selected category abbreviation for eType. Returns full name if no abbreviation defined.
const OUString& GetAbbreviatedBACName(SfxClassificationPolicyType eType);
/// Return all possible valid abbreviated category names, based on the policy.
std::vector<OUString> GetAbbreviatedBACNames();
/// Setting this sets all the other properties, based on the policy. /// Setting this sets all the other properties, based on the policy.
void SetBACName(const OUString& rName, SfxClassificationPolicyType eType); void SetBACName(const OUString& rName, SfxClassificationPolicyType eType);
/// If GetImpactScale() and GetImpactLevel*() will return something meaningful. /// If GetImpactScale() and GetImpactLevel*() will return something meaningful.
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
</xs:sequence> </xs:sequence>
<xs:attribute name="Identifier" type="xs:anyURI" use="required"/> <xs:attribute name="Identifier" type="xs:anyURI" use="required"/>
<xs:attribute name="Name" type="xs:string" use="optional"/> <xs:attribute name="Name" type="xs:string" use="optional"/>
<xs:attribute name="loextAbbreviatedName" type="xs:string" use="optional"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<!-- Impact Level --> <!-- Impact Level -->
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</baf:AdministrativeData> </baf:AdministrativeData>
<baf:Included> <baf:Included>
<!-- Translators: the Name attribute in this string can be localized --> <!-- Translators: the Name attribute in this string can be localized -->
<baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:non-business" Name="Non-Business"> <baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:non-business" Name="Non-Business" loextAbbreviatedName="NB">
<baf:LabelingRules/> <baf:LabelingRules/>
<baf:ImpactLevel> <baf:ImpactLevel>
<baf:Scale>UK-Cabinet</baf:Scale> <baf:Scale>UK-Cabinet</baf:Scale>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</baf:ImpactLevel> </baf:ImpactLevel>
</baf:BusinessAuthorizationCategory> </baf:BusinessAuthorizationCategory>
<!-- Translators: the Name attribute in this string can be localized --> <!-- Translators: the Name attribute in this string can be localized -->
<baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:general-business" Name="General Business"> <baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:general-business" Name="General Business" loextAbbreviatedName="GB">
<baf:LabelingRules> <baf:LabelingRules>
<baf:VisualMarkingPart> <baf:VisualMarkingPart>
<baf:Identifier>Document: Header</baf:Identifier> <baf:Identifier>Document: Header</baf:Identifier>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</baf:ImpactLevel> </baf:ImpactLevel>
</baf:BusinessAuthorizationCategory> </baf:BusinessAuthorizationCategory>
<!-- Translators: the Name attribute in this string can be localized --> <!-- Translators: the Name attribute in this string can be localized -->
<baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:confidential" Name="Confidential"> <baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:confidential" Name="Confidential" loextAbbreviatedName="Conf">
<baf:LabelingRules> <baf:LabelingRules>
<baf:VisualMarkingPart> <baf:VisualMarkingPart>
<baf:Identifier>Document: Header</baf:Identifier> <baf:Identifier>Document: Header</baf:Identifier>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</baf:ImpactLevel> </baf:ImpactLevel>
</baf:BusinessAuthorizationCategory> </baf:BusinessAuthorizationCategory>
<!-- Translators: the Name attribute in this string can be localized --> <!-- Translators: the Name attribute in this string can be localized -->
<baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:internal-only" Name="Internal Only"> <baf:BusinessAuthorizationCategory Identifier="urn:example:tscp:1:internal-only" Name="Internal Only" loextAbbreviatedName="IO">
<baf:LabelingRules> <baf:LabelingRules>
<baf:VisualMarkingPart> <baf:VisualMarkingPart>
<baf:Identifier>Document: Header</baf:Identifier> <baf:Identifier>Document: Header</baf:Identifier>
......
...@@ -92,6 +92,7 @@ class SfxClassificationCategory ...@@ -92,6 +92,7 @@ class SfxClassificationCategory
public: public:
/// PROP_BACNAME() is stored separately for easier lookup. /// PROP_BACNAME() is stored separately for easier lookup.
OUString m_aName; OUString m_aName;
OUString m_aAbbreviatedName;
std::map<OUString, OUString> m_aLabels; std::map<OUString, OUString> m_aLabels;
}; };
...@@ -170,7 +171,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const ...@@ -170,7 +171,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const
} }
else if (rName == "baf:BusinessAuthorizationCategory") else if (rName == "baf:BusinessAuthorizationCategory")
{ {
OUString aName = xAttribs->getValueByName("Name"); const OUString aName = xAttribs->getValueByName("Name");
const OUString aAbbreviatedName = xAttribs->getValueByName("loextAbbreviatedName");
if (!m_pCategory && !aName.isEmpty()) if (!m_pCategory && !aName.isEmpty())
{ {
OUString aIdentifier = xAttribs->getValueByName("Identifier"); OUString aIdentifier = xAttribs->getValueByName("Identifier");
...@@ -179,6 +181,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const ...@@ -179,6 +181,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const
m_aCategories.emplace_back(SfxClassificationCategory()); m_aCategories.emplace_back(SfxClassificationCategory());
SfxClassificationCategory& rCategory = m_aCategories.back(); SfxClassificationCategory& rCategory = m_aCategories.back();
rCategory.m_aName = aName; rCategory.m_aName = aName;
// Set the abbreviated name, if any, otherwise fallback on the full name.
rCategory.m_aAbbreviatedName = !aAbbreviatedName.isEmpty() ? aAbbreviatedName : aName;
rCategory.m_aLabels["PolicyAuthority:Name"] = m_aPolicyAuthorityName; rCategory.m_aLabels["PolicyAuthority:Name"] = m_aPolicyAuthorityName;
rCategory.m_aLabels["Policy:Name"] = m_aPolicyName; rCategory.m_aLabels["Policy:Name"] = m_aPolicyName;
rCategory.m_aLabels["BusinessAuthorization:Identifier"] = m_aProgramID; rCategory.m_aLabels["BusinessAuthorization:Identifier"] = m_aProgramID;
...@@ -587,6 +591,11 @@ const OUString& SfxClassificationHelper::GetBACName(SfxClassificationPolicyType ...@@ -587,6 +591,11 @@ const OUString& SfxClassificationHelper::GetBACName(SfxClassificationPolicyType
return m_pImpl->m_aCategory[eType].m_aName; return m_pImpl->m_aCategory[eType].m_aName;
} }
const OUString& SfxClassificationHelper::GetAbbreviatedBACName(SfxClassificationPolicyType eType)
{
return m_pImpl->m_aCategory[eType].m_aAbbreviatedName;
}
bool SfxClassificationHelper::HasImpactLevel() bool SfxClassificationHelper::HasImpactLevel()
{ {
auto itCategory = m_pImpl->m_aCategory.find(SfxClassificationPolicyType::IntellectualProperty); auto itCategory = m_pImpl->m_aCategory.find(SfxClassificationPolicyType::IntellectualProperty);
...@@ -754,6 +763,19 @@ std::vector<OUString> SfxClassificationHelper::GetBACNames() ...@@ -754,6 +763,19 @@ std::vector<OUString> SfxClassificationHelper::GetBACNames()
return aRet; return aRet;
} }
std::vector<OUString> SfxClassificationHelper::GetAbbreviatedBACNames()
{
if (m_pImpl->m_aCategories.empty())
m_pImpl->parsePolicy();
std::vector<OUString> aRet;
std::transform(m_pImpl->m_aCategories.begin(), m_pImpl->m_aCategories.end(), std::back_inserter(aRet), [](const SfxClassificationCategory& rCategory)
{
return rCategory.m_aAbbreviatedName;
});
return aRet;
}
void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificationPolicyType eType) void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificationPolicyType eType)
{ {
if (m_pImpl->m_aCategories.empty()) if (m_pImpl->m_aCategories.empty())
......
...@@ -178,7 +178,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult() ...@@ -178,7 +178,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
{ {
sal_Int32 nSelected = rBox.GetSelectedEntryPos(); const sal_Int32 nSelected = rBox.GetSelectedEntryPos();
if (nSelected >= 0) if (nSelected >= 0)
{ {
std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject());
...@@ -198,7 +198,7 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) ...@@ -198,7 +198,7 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
} }
} }
OUString aString = maHelper.GetBACNames()[nSelected]; const OUString aString = maHelper.GetAbbreviatedBACNames()[nSelected];
insertField(ClassificationType::CATEGORY, aString); insertField(ClassificationType::CATEGORY, aString);
m_pInternationalClassificationListBox->SelectEntryPos(nSelected); m_pInternationalClassificationListBox->SelectEntryPos(nSelected);
...@@ -228,7 +228,7 @@ IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void) ...@@ -228,7 +228,7 @@ IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void)
} }
} }
OUString aString = maHelper.GetMarkings()[nSelected]; const OUString aString = maHelper.GetMarkings()[nSelected];
insertField(ClassificationType::MARKING, aString); insertField(ClassificationType::MARKING, aString);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment