Kaydet (Commit) 195bd0f8 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

TSCP: consistently use identifier for category

When identifier is used for category, it is written into the
metadata under a different key. When loading it back, it should
fill the corresponding properties (identifier if identifier key was
used or name if name key was used), otherwise this can lead to
inconsistent behaviour when loading the classification data back
from the file.

Change-Id: Idbd9bde866d117bd7f60bcc224069f00a27fb9e2
Reviewed-on: https://gerrit.libreoffice.org/44846Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 5fd90dcf
......@@ -1144,7 +1144,8 @@ void lcl_ApplyParagraphClassification(SwDoc* pDoc,
const bool isLast = nIndex == 0;
const bool isFirst = nIndex == aResults.size() - 1;
OUString sKey;
switch(rResult.meType)
OUString sValue = rResult.msName;
switch (rResult.meType)
{
case svx::ClassificationType::TEXT:
{
......@@ -1155,10 +1156,14 @@ void lcl_ApplyParagraphClassification(SwDoc* pDoc,
case svx::ClassificationType::CATEGORY:
{
if (rResult.msIdentifier.isEmpty())
{
sKey = aKeyCreator.makeCategoryNameKey();
}
else
{
sValue = rResult.msIdentifier;
sKey = aKeyCreator.makeCategoryIdentifierKey();
}
SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xNodeSubject, ParagraphClassificationAbbrRDFName, rResult.msAbbreviatedName);
}
break;
......@@ -1182,7 +1187,7 @@ void lcl_ApplyParagraphClassification(SwDoc* pDoc,
OUString sDisplayText = (isFirst ? ("(" + rResult.msAbbreviatedName) : rResult.msAbbreviatedName);
if (isLast)
sDisplayText += ")";
lcl_UpdateParagraphClassificationField(pDoc, xModel, xParent, sKey, rResult.msName, sDisplayText);
lcl_UpdateParagraphClassificationField(pDoc, xModel, xParent, sKey, sValue, sDisplayText);
aFieldNames.emplace_back(sKey);
}
......@@ -1261,10 +1266,14 @@ std::vector<svx::ClassificationResult> lcl_CollectParagraphClassification(const
{
aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isCategoryNameKey(aName) || aKeyCreator.isCategoryIdentifierKey(aName))
else if (aKeyCreator.isCategoryNameKey(aName))
{
aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isCategoryIdentifierKey(aName))
{
aResult.push_back({ svx::ClassificationType::CATEGORY, sBlank, sBlank, aValue });
}
else if (aKeyCreator.isMarkingKey(aName))
{
aResult.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank });
......
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