[Libreoffice-commits] core.git: include/sfx2 sfx2/source svx/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Fri Nov 17 03:53:16 UTC 2017
include/sfx2/classificationhelper.hxx | 2 ++
sfx2/source/view/classificationhelper.cxx | 15 +++++++++++++++
svx/source/dialog/ClassificationDialog.cxx | 22 +++++++++++++++-------
3 files changed, 32 insertions(+), 7 deletions(-)
New commits:
commit 5fd90dcf5b12af4bf8ca21866b23209aa4d3d531
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Nov 16 18:32:14 2017 +0900
TSCP: resolve identifier to name, abbr. name is for category only
In paragraph classification we store only the identifier and not
the name, but for the ClassificationDialog we use the name as an
identifier, so we need to resovle the identifier to the name when
reading in the input classification results. It might make sense
to switch to identifiers in the dialog also as they are language
independent.
Abbreviated name is only for the classification category and has
no effect for other classefication elementslike markers and IP
parts, so always fill them with the full name directly.
Change-Id: I23bd0e8e92b16807a5b4d3162e503b799aa40718
Reviewed-on: https://gerrit.libreoffice.org/44845
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index f535cf4adae9..a2699623c4be 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -67,6 +67,8 @@ public:
std::vector<OUString> GetBACIdentifiers();
/// Get the currently selected category abbreviation for eType. Returns full name if no abbreviation defined.
const OUString& GetAbbreviatedBACName(const OUString& sFullName);
+ /// Get the currently selected category for the identifier.
+ OUString GetBACNameForIdentifier(const OUString& sIdentifier);
/// 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.
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 82287da47171..a1e4aea55324 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -614,6 +614,21 @@ const OUString& SfxClassificationHelper::GetAbbreviatedBACName(const OUString& s
return sFullName;
}
+OUString SfxClassificationHelper::GetBACNameForIdentifier(const OUString& sIdentifier)
+{
+ OUString aRet;
+ if (sIdentifier.isEmpty())
+ return aRet;
+
+ for (const auto& category : m_pImpl->m_aCategories)
+ {
+ if (category.m_aIdentifier == sIdentifier)
+ return category.m_aName;
+ }
+
+ return aRet;
+}
+
OUString SfxClassificationHelper::GetHigherClass(const OUString& first, const OUString& second)
{
size_t nFirstConfidentiality = 0;
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 0bb8e7892d4e..f8cebe090042 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -410,11 +410,9 @@ void ClassificationDialog::writeRecentlyUsed()
void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInput)
{
sal_Int32 nParagraph = -1;
+
for (ClassificationResult const & rClassificationResult : rInput)
{
- OUString sAbbreviatedName = rClassificationResult.msAbbreviatedName;
- if (sAbbreviatedName.isEmpty())
- sAbbreviatedName = maHelper.GetAbbreviatedBACName(rClassificationResult.msName);
switch (rClassificationResult.meType)
{
@@ -426,24 +424,34 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
case svx::ClassificationType::CATEGORY:
{
- m_pClassificationListBox->SelectEntry(rClassificationResult.msName);
+ OUString sName;
+ if (rClassificationResult.msName.isEmpty())
+ sName = maHelper.GetBACNameForIdentifier(rClassificationResult.msIdentifier);
+ else
+ sName = rClassificationResult.msName;
+
+ OUString sAbbreviatedName = rClassificationResult.msAbbreviatedName;
+ if (sAbbreviatedName.isEmpty())
+ sAbbreviatedName = maHelper.GetAbbreviatedBACName(sName);
+
+ m_pClassificationListBox->SelectEntry(sName);
m_nCurrentSelectedCategory = m_pClassificationListBox->GetSelectedEntryPos();
m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos());
- insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, sAbbreviatedName, sName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::MARKING:
{
m_pMarkingListBox->SelectEntry(rClassificationResult.msName);
- insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
- insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
More information about the Libreoffice-commits
mailing list