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

TSCP: Paragraph signature RDF namespace now urn:bails

And remove PARAGRAPH entries from ClassificationResults
to restore adding the parens correctly.

Change-Id: Id0f07758e4daad8d0736800e211e35e9c7e026cf
Reviewed-on: https://gerrit.libreoffice.org/44145Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 4bba85e0
...@@ -113,16 +113,18 @@ namespace sfx ...@@ -113,16 +113,18 @@ namespace sfx
class ClassificationKeyCreator class ClassificationKeyCreator
{ {
private: private:
SfxClassificationPolicyType m_ePolicyType; const SfxClassificationPolicyType m_ePolicyType;
const OUString m_sPolicy;
sal_Int32 m_nTextNumber; sal_Int32 m_nTextNumber;
OUString getPolicyKey() const OUString getPolicyKey() const
{ {
return SfxClassificationHelper::policyTypeToString(m_ePolicyType); return m_sPolicy;
} }
public: public:
ClassificationKeyCreator(SfxClassificationPolicyType ePolicyType) ClassificationKeyCreator(SfxClassificationPolicyType ePolicyType)
: m_ePolicyType(ePolicyType) : m_ePolicyType(ePolicyType)
, m_sPolicy(SfxClassificationHelper::policyTypeToString(m_ePolicyType))
, m_nTextNumber(1) , m_nTextNumber(1)
{} {}
...@@ -133,9 +135,7 @@ public: ...@@ -133,9 +135,7 @@ public:
OUString makeNumberedMarkingTextKey() OUString makeNumberedMarkingTextKey()
{ {
OUString sKey = makeMarkingTextKey() + ":" + OUString::number(m_nTextNumber); return makeMarkingTextKey() + ":" + OUString::number(m_nTextNumber++);
m_nTextNumber++;
return sKey;
} }
bool isMarkingTextKey(OUString const & aKey) const bool isMarkingTextKey(OUString const & aKey) const
...@@ -143,15 +143,24 @@ public: ...@@ -143,15 +143,24 @@ public:
return aKey.startsWith(makeMarkingTextKey()); return aKey.startsWith(makeMarkingTextKey());
} }
OUString makeCategoryKey() const OUString makeCategoryNameKey() const
{ {
return getPolicyKey() + "BusinessAuthorizationCategory:Name"; return getPolicyKey() + "BusinessAuthorizationCategory:Name";
} }
bool isCategoryKey(OUString const & aKey) const bool isCategoryNameKey(OUString const & aKey) const
{ {
return aKey.startsWith(makeCategoryKey()) || return aKey.startsWith(makeCategoryNameKey());
aKey.startsWith(getPolicyKey() + "BusinessAuthorizationCategory:Identifier"); }
OUString makeCategoryIdentifierKey() const
{
return getPolicyKey() + "BusinessAuthorizationCategory:Identifier";
}
bool isCategoryIdentifierKey(OUString const & aKey) const
{
return aKey.startsWith(makeCategoryIdentifierKey());
} }
OUString makeMarkingKey() const OUString makeMarkingKey() const
......
...@@ -323,7 +323,7 @@ private: ...@@ -323,7 +323,7 @@ private:
OUString aValue = lcl_getProperty(xPropertyContainer, aKey); OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
} }
else if (aKeyCreator.isCategoryKey(aKey)) else if (aKeyCreator.isCategoryNameKey(aKey) || aKeyCreator.isCategoryIdentifierKey(aKey))
{ {
OUString aValue = lcl_getProperty(xPropertyContainer, aKey); OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank }); m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
...@@ -406,7 +406,7 @@ private: ...@@ -406,7 +406,7 @@ private:
void deleteExistingObjects() void deleteExistingObjects()
{ {
sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType()); sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType());
OUString sKey = aKeyCreator.makeCategoryKey(); OUString sKey = aKeyCreator.makeCategoryNameKey();
const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard);
...@@ -498,7 +498,7 @@ public: ...@@ -498,7 +498,7 @@ public:
case svx::ClassificationType::CATEGORY: case svx::ClassificationType::CATEGORY:
{ {
OUString sKey = aKeyCreator.makeCategoryKey(); OUString sKey = aKeyCreator.makeCategoryNameKey();
pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
} }
break; break;
......
...@@ -95,11 +95,11 @@ namespace ...@@ -95,11 +95,11 @@ namespace
{ {
static const OUString MetaFilename("tscp/bails.rdf"); static const OUString MetaFilename("tscp/bails.rdf");
static const OUString MetaNS("urn:bails"); static const OUString MetaNS("urn:bails");
static const OUString ParagraphSignatureRDFName = "loext:paragraph:signature"; static const OUString ParagraphSignatureRDFName = "urn:bails:loext:paragraph:signature";
static const OUString ParagraphSignatureDateRDFName = "loext:paragraph:signature:date"; static const OUString ParagraphSignatureDateRDFName = "urn:bails:loext:paragraph:signature:date";
static const OUString ParagraphSignatureUsageRDFName = "loext:paragraph:signature:usage"; static const OUString ParagraphSignatureUsageRDFName = "urn:bails:loext:paragraph:signature:usage";
static const OUString ParagraphClassificationNameRDFName = "loext:paragraph:classification:name"; static const OUString ParagraphClassificationNameRDFName = "urn:bails:loext:paragraph:classification:name";
static const OUString ParagraphClassificationValueRDFName = "loext:paragraph:classification:value"; static const OUString ParagraphClassificationValueRDFName = "urn:bails:loext:paragraph:classification:value";
static const OUString MetadataFieldServiceName = "com.sun.star.text.textfield.MetadataField"; static const OUString MetadataFieldServiceName = "com.sun.star.text.textfield.MetadataField";
static const OUString DocInfoServiceName = "com.sun.star.text.TextField.DocInfo.Custom"; static const OUString DocInfoServiceName = "com.sun.star.text.TextField.DocInfo.Custom";
...@@ -724,7 +724,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes ...@@ -724,7 +724,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
case svx::ClassificationType::CATEGORY: case svx::ClassificationType::CATEGORY:
{ {
OUString sKey = aCreator.makeCategoryKey(); OUString sKey = aCreator.makeCategoryNameKey();
insertFieldToDocument(xMultiServiceFactory, xHeaderText, xHeaderParagraphCursor, sKey); insertFieldToDocument(xMultiServiceFactory, xHeaderText, xHeaderParagraphCursor, sKey);
insertFieldToDocument(xMultiServiceFactory, xFooterText, xFooterParagraphCursor, sKey); insertFieldToDocument(xMultiServiceFactory, xFooterText, xFooterParagraphCursor, sKey);
} }
...@@ -857,7 +857,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio ...@@ -857,7 +857,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
if (!aValue.isEmpty()) if (!aValue.isEmpty())
aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
} }
else if (aCreator.isCategoryKey(aName)) else if (aCreator.isCategoryNameKey(aName) || aCreator.isCategoryIdentifierKey(aName))
{ {
const OUString aValue = lcl_getProperty(xPropertyContainer, aName); const OUString aValue = lcl_getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty()) if (!aValue.isEmpty())
...@@ -1000,15 +1000,18 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe ...@@ -1000,15 +1000,18 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
// Since we always insert at the start of the paragraph, // Since we always insert at the start of the paragraph,
// need to insert in reverse order. // need to insert in reverse order.
std::reverse(aResults.begin(), aResults.end()); std::reverse(aResults.begin(), aResults.end());
// Ignore "PARAGRAPH" types
aResults.erase(std::remove_if(aResults.begin(),
aResults.end(),
[&](const svx::ClassificationResult& rResult)-> bool
{ return rResult.meType == svx::ClassificationType::PARAGRAPH; }),
aResults.end());
for (size_t nIndex = 0; nIndex < aResults.size(); ++nIndex) for (size_t nIndex = 0; nIndex < aResults.size(); ++nIndex)
{ {
const svx::ClassificationResult& rResult = aResults[nIndex]; const svx::ClassificationResult& rResult = aResults[nIndex];
// Ignore "PARAGRAPH" types
if (rResult.meType == svx::ClassificationType::PARAGRAPH)
continue;
const bool isLast = nIndex == 0; const bool isLast = nIndex == 0;
const bool isFirst = nIndex == aResults.size() - 1; const bool isFirst = nIndex == aResults.size() - 1;
OUString sKey; OUString sKey;
...@@ -1022,7 +1025,10 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe ...@@ -1022,7 +1025,10 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
case svx::ClassificationType::CATEGORY: case svx::ClassificationType::CATEGORY:
{ {
sKey = aKeyCreator.makeCategoryKey(); if (rResult.msIdentifier.isEmpty())
sKey = aKeyCreator.makeCategoryNameKey();
else
sKey = aKeyCreator.makeCategoryIdentifierKey();
} }
break; break;
...@@ -1098,7 +1104,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectParagraphClassificati ...@@ -1098,7 +1104,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectParagraphClassificati
{ {
aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
} }
else if (aKeyCreator.isCategoryKey(aName)) else if (aKeyCreator.isCategoryNameKey(aName) || aKeyCreator.isCategoryIdentifierKey(aName))
{ {
aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank }); aResult.push_back({ svx::ClassificationType::CATEGORY, 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