[Libreoffice-commits] core.git: include/sfx2 include/svx sd/source sfx2/source svx/source sw/source
Ashod Nakashian
ashodnakashian at yahoo.com
Fri Nov 3 10:16:20 UTC 2017
include/sfx2/classificationhelper.hxx | 5 +-
include/svx/ClassificationDialog.hxx | 2
include/svx/ClassificationField.hxx | 14 ++++--
sd/source/ui/view/drviews2.cxx | 10 ++--
sfx2/source/view/classificationhelper.cxx | 21 ++++++++-
svx/source/dialog/ClassificationDialog.cxx | 20 +++++----
sw/source/core/edit/edfcol.cxx | 62 +++++++++++++++++++----------
7 files changed, 91 insertions(+), 43 deletions(-)
New commits:
commit 2ecd194d091fd33c2554bfff960985b2bd5e654e
Author: Ashod Nakashian <ashodnakashian at yahoo.com>
Date: Mon Oct 30 06:05:09 2017 -0400
TSCP: use the BAC identifier as the RDF key
DOCX RDF -> SmartTag logic expects urn:bails
namespace to dump the RDF, and it also needs
to have the rdf file in tscp/bails.rdf, hence
the move.
Change-Id: I9ae496c97abe97d3596de46ffccd5f7c80e37d34
Reviewed-on: https://gerrit.libreoffice.org/44116
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index a389ec7e4ac0..11782247ca23 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -63,6 +63,8 @@ public:
const OUString& GetBACName(SfxClassificationPolicyType eType);
/// Return all possible valid category names, based on the policy.
std::vector<OUString> GetBACNames();
+ /// Return all possible valid category identifiers, based on the policy.
+ 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);
/// Return all possible valid abbreviated category names, based on the policy.
@@ -148,7 +150,8 @@ public:
bool isCategoryKey(OUString const & aKey) const
{
- return aKey.startsWith(makeCategoryKey());
+ return aKey.startsWith(makeCategoryKey()) ||
+ aKey.startsWith(getPolicyKey() + "BusinessAuthorizationCategory:Identifier");
}
OUString makeMarkingKey() const
diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx
index ddea7af12592..85a70eb95f95 100644
--- a/include/svx/ClassificationDialog.hxx
+++ b/include/svx/ClassificationDialog.hxx
@@ -55,7 +55,7 @@ private:
DECL_LINK(SelectRecentlyUsedHdl, ListBox&, void);
DECL_LINK(SelectIPPartHdl, ListBox&, void);
- void insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString);
+ void insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier = OUString());
std::vector<std::vector<ClassificationResult>> m_aRecentlyUsedValuesCollection;
std::vector<ClassificationResult> m_aInitialValues;
diff --git a/include/svx/ClassificationField.hxx b/include/svx/ClassificationField.hxx
index b57f29cbafbe..4d4588c68177 100644
--- a/include/svx/ClassificationField.hxx
+++ b/include/svx/ClassificationField.hxx
@@ -32,17 +32,19 @@ public:
ClassificationType meType;
OUString msDescription;
OUString msFullClassName;
+ OUString msIdentifier;
- ClassificationField(ClassificationType eType, OUString const & sDescription, OUString const & sFullClassName)
+ ClassificationField(ClassificationType eType, OUString const & sDescription, OUString const & sFullClassName, OUString const & sIdentifier = "")
: SvxFieldData()
, meType(eType)
, msDescription(sDescription)
, msFullClassName(sFullClassName)
+ , msIdentifier(sIdentifier)
{}
ClassificationField* Clone() const override
{
- return new ClassificationField(meType, msDescription, msFullClassName);
+ return new ClassificationField(meType, msDescription, msFullClassName, msIdentifier);
}
bool operator==(const SvxFieldData& rOther) const override
@@ -53,15 +55,17 @@ public:
const ClassificationField& rOtherField = static_cast<const ClassificationField&>(rOther);
return (meType == rOtherField.meType &&
msDescription == rOtherField.msDescription &&
- msFullClassName == rOtherField.msFullClassName);
+ msFullClassName == rOtherField.msFullClassName &&
+ msIdentifier == rOtherField.msIdentifier);
}
};
struct SVX_DLLPUBLIC ClassificationResult
{
ClassificationType meType;
- OUString msString;
- OUString msAbbreviatedString;
+ OUString msString; //< Display text or 'Name' field (from example.xml).
+ OUString msAbbreviatedString; //< Abbreviated name, displayed instead of msString.
+ OUString msIdentifier; //< The identifier of this entry (from example.xml).
};
} // end svx namespace
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index fa89000bddca..992e6608f961 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -308,7 +308,7 @@ private:
// Get Weight of current paragraph
OUString sWeightProperty = getWeightString(rEditText.GetParaAttribs(nCurrentParagraph));
// Insert new paragraph into collection
- m_aResults.push_back({ svx::ClassificationType::PARAGRAPH, sWeightProperty, sBlank });
+ m_aResults.push_back({ svx::ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank });
}
const SvxFieldItem* pFieldItem = findField(rSection);
@@ -321,22 +321,22 @@ private:
if (aKeyCreator.isMarkingTextKey(aKey))
{
OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
- m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank });
+ m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isCategoryKey(aKey))
{
OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
- m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank });
+ m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isMarkingKey(aKey))
{
OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
- m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank });
+ m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isIntellectualPropertyPartKey(aKey))
{
OUString aValue = lcl_getProperty(xPropertyContainer, aKey);
- m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank });
+ m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank });
}
}
}
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 5e38e3885bb1..e5748a61c3ab 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -92,7 +92,8 @@ class SfxClassificationCategory
public:
/// PROP_BACNAME() is stored separately for easier lookup.
OUString m_aName;
- OUString m_aAbbreviatedName;
+ OUString m_aAbbreviatedName; //< An abbreviation to display instead of m_aName.
+ OUString m_aIdentifier; //< The Identifier of this entry.
size_t m_nConfidentiality; //< 0 is the lowest (least-sensitive).
std::map<OUString, OUString> m_aLabels;
};
@@ -173,7 +174,6 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const
else if (rName == "baf:BusinessAuthorizationCategory")
{
const OUString aName = xAttribs->getValueByName("Name");
- const OUString aAbbreviatedName = xAttribs->getValueByName("loextAbbreviatedName");
if (!m_pCategory && !aName.isEmpty())
{
OUString aIdentifier = xAttribs->getValueByName("Identifier");
@@ -181,9 +181,13 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const
// Create a new category and initialize it with the data that's true for all categories.
m_aCategories.emplace_back(SfxClassificationCategory());
SfxClassificationCategory& rCategory = m_aCategories.back();
+
rCategory.m_aName = aName;
// Set the abbreviated name, if any, otherwise fallback on the full name.
+ const OUString aAbbreviatedName = xAttribs->getValueByName("loextAbbreviatedName");
rCategory.m_aAbbreviatedName = !aAbbreviatedName.isEmpty() ? aAbbreviatedName : aName;
+ rCategory.m_aIdentifier = aIdentifier;
+
rCategory.m_aLabels["PolicyAuthority:Name"] = m_aPolicyAuthorityName;
rCategory.m_aLabels["Policy:Name"] = m_aPolicyName;
rCategory.m_aLabels["BusinessAuthorization:Identifier"] = m_aProgramID;
@@ -789,6 +793,19 @@ std::vector<OUString> SfxClassificationHelper::GetBACNames()
return aRet;
}
+std::vector<OUString> SfxClassificationHelper::GetBACIdentifiers()
+{
+ 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_aIdentifier;
+ });
+ return aRet;
+}
+
std::vector<OUString> SfxClassificationHelper::GetAbbreviatedBACNames()
{
if (m_pImpl->m_aCategories.empty())
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index ef7ef7010ada..57c29847d3b1 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -246,9 +246,9 @@ short ClassificationDialog::Execute()
return nResult;
}
-void ClassificationDialog::insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString)
+void ClassificationDialog::insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier)
{
- ClassificationField aField(eType, rString, rFullString);
+ ClassificationField aField(eType, rString, rFullString, rIdentifier);
m_pEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
}
@@ -387,20 +387,20 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
{
m_pClassificationListBox->SelectEntry(rClassificationResult.msString);
m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos());
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString);
+ insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::MARKING:
{
m_pMarkingListBox->SelectEntry(rClassificationResult.msString);
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString);
+ insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString);
+ insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
}
break;
@@ -456,7 +456,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
sWeightProperty = "BOLD";
// Insert into collection
OUString sBlank;
- aClassificationResults.push_back({ ClassificationType::PARAGRAPH, sWeightProperty, sBlank });
+ aClassificationResults.push_back({ ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank });
}
const SvxFieldItem* pFieldItem = findField(rSection);
@@ -469,11 +469,12 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
if (pClassificationField)
{
- aClassificationResults.push_back({ pClassificationField->meType, pClassificationField->msFullClassName, sDisplayString });
+ aClassificationResults.push_back({ pClassificationField->meType, pClassificationField->msFullClassName,
+ sDisplayString, pClassificationField->msIdentifier });
}
else
{
- aClassificationResults.push_back({ ClassificationType::TEXT, sDisplayString, sDisplayString });
+ aClassificationResults.push_back({ ClassificationType::TEXT, sDisplayString, sDisplayString, OUString() });
}
}
}
@@ -505,7 +506,8 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
const OUString aFullString = maHelper.GetBACNames()[nSelected];
const OUString aAbbreviatedString = maHelper.GetAbbreviatedBACNames()[nSelected];
- insertField(ClassificationType::CATEGORY, aAbbreviatedString, aFullString);
+ const OUString aIdentifierString = maHelper.GetBACIdentifiers()[nSelected];
+ insertField(ClassificationType::CATEGORY, aAbbreviatedString, aFullString, aIdentifierString);
m_pInternationalClassificationListBox->SelectEntryPos(nSelected);
m_pClassificationListBox->SelectEntryPos(nSelected);
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index fdc88456f822..0120eee919c1 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -93,7 +93,7 @@
namespace
{
-static const OUString MetaFilename("bails.rdf");
+static const OUString MetaFilename("tscp/bails.rdf");
static const OUString MetaNS("urn:bails");
static const OUString ParagraphSignatureRDFName = "loext:paragraph:signature";
static const OUString ParagraphSignatureDateRDFName = "loext:paragraph:signature:date";
@@ -244,6 +244,22 @@ OString lcl_getParagraphBodyText(const uno::Reference<text::XTextContent>& xText
}
/// Returns RDF (key, value) pair associated with the field, if any.
+std::pair<OUString, OUString> lcl_getFieldRDFByPrefix(const uno::Reference<frame::XModel>& xModel,
+ const uno::Reference<css::text::XTextField>& xField,
+ const OUString& rsPrefix)
+{
+ const css::uno::Reference<css::rdf::XResource> xSubject(xField, uno::UNO_QUERY);
+ std::map<OUString, OUString> aStatements = SwRDFHelper::getStatements(xModel, MetaNS, xSubject);
+ for (const auto& pair : aStatements)
+ {
+ if (pair.first.startsWith(rsPrefix))
+ return pair;
+ }
+
+ return std::make_pair(OUString(), OUString());
+}
+
+/// Returns RDF (key, value) pair associated with the field, if any.
std::pair<OUString, OUString> lcl_getFieldRDF(const uno::Reference<frame::XModel>& xModel,
const uno::Reference<css::text::XTextField>& xField,
const OUString& rRDFName)
@@ -434,7 +450,7 @@ uno::Reference<text::XTextField> lcl_InsertParagraphClassification(const uno::Re
/// Updates the paragraph classification field text if changed and returns true only iff updated.
bool lcl_UpdateParagraphClassificationField(SwDoc* pDoc,
const uno::Reference<frame::XModel>& xModel,
- const uno::Reference<css::text::XTextField>& xField,
+ const uno::Reference<css::text::XTextContent>& xTextNode,
const OUString& sKey,
const OUString& sValue,
const OUString& sDisplayText)
@@ -446,9 +462,13 @@ bool lcl_UpdateParagraphClassificationField(SwDoc* pDoc,
pDoc->GetIDocumentUndoRedo().DoUndo(isUndoEnabled);
});
- const css::uno::Reference<css::rdf::XResource> xSubject(xField, uno::UNO_QUERY);
- SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xSubject, ParagraphClassificationNameRDFName, sKey);
- SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xSubject, ParagraphClassificationValueRDFName, sValue);
+ uno::Reference<text::XTextField> xField = lcl_InsertParagraphClassification(xModel, xTextNode);
+ css::uno::Reference<css::rdf::XResource> xFieldSubject(xField, uno::UNO_QUERY);
+ SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xFieldSubject, sKey, sValue);
+ css::uno::Reference<css::rdf::XResource> xNodeSubject(xTextNode, uno::UNO_QUERY);
+ SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xNodeSubject, sKey, sValue);
+ SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xFieldSubject, ParagraphClassificationNameRDFName, sKey);
+ SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xFieldSubject, ParagraphClassificationValueRDFName, sValue);
uno::Reference<css::text::XTextRange> xText(xField, uno::UNO_QUERY);
const OUString curDisplayText = xText->getString();
@@ -811,7 +831,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
OUString sWeight = (aAny.get<float>() >= awt::FontWeight::BOLD) ? OUString("BOLD") : OUString("NORMAL");
- aResult.push_back({ svx::ClassificationType::PARAGRAPH, sWeight, sBlank });
+ aResult.push_back({ svx::ClassificationType::PARAGRAPH, sWeight, sBlank, sBlank });
// Process portions
while (xTextPortions->hasMoreElements())
@@ -835,25 +855,25 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
{
const OUString aValue = lcl_getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty())
- aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
}
else if (aCreator.isCategoryKey(aName))
{
const OUString aValue = lcl_getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty())
- aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
}
else if (aCreator.isMarkingKey(aName))
{
const OUString aValue = lcl_getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty())
- aResult.push_back({ svx::ClassificationType::MARKING, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank });
}
else if (aCreator.isIntellectualPropertyPartKey(aName))
{
const OUString aValue = lcl_getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty())
- aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank });
}
}
}
@@ -1022,11 +1042,10 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
break;
}
- uno::Reference<text::XTextField> xTextField = lcl_InsertParagraphClassification(xModel, xParent);
OUString sDisplayText = (isFirst ? ("(" + rResult.msAbbreviatedString) : rResult.msAbbreviatedString);
if (isLast)
sDisplayText += ")";
- lcl_UpdateParagraphClassificationField(GetDoc(), xModel, xTextField, sKey, rResult.msString, sDisplayText);
+ lcl_UpdateParagraphClassificationField(GetDoc(), xModel, xParent, sKey, rResult.msString, sDisplayText);
}
}
@@ -1068,28 +1087,28 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectParagraphClassificati
continue;
uno::Reference<text::XTextField> xTextField(xField, uno::UNO_QUERY);
- const std::pair<OUString, OUString> rdfNamePair = lcl_getFieldRDF(xModel, xTextField, ParagraphClassificationNameRDFName);
- const std::pair<OUString, OUString> rdfValuePair = lcl_getFieldRDF(xModel, xTextField, ParagraphClassificationValueRDFName);
+ const OUString sPolicy = SfxClassificationHelper::policyTypeToString(SfxClassificationHelper::getPolicyType());
+ const std::pair<OUString, OUString> rdfNamePair = lcl_getFieldRDFByPrefix(xModel, xTextField, sPolicy);
uno::Reference<text::XTextRange> xTextRange(xField, uno::UNO_QUERY);
- const OUString aName = rdfNamePair.second;
- const OUString aValue = rdfValuePair.second;
+ const OUString aName = rdfNamePair.first;
+ const OUString aValue = rdfNamePair.second;
const OUString sBlank("");
if (aKeyCreator.isMarkingTextKey(aName))
{
- aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isCategoryKey(aName))
{
- aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isMarkingKey(aName))
{
- aResult.push_back({ svx::ClassificationType::MARKING, aValue, sBlank });
+ aResult.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank });
}
else if (aKeyCreator.isIntellectualPropertyPartKey(aName))
{
- aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, xTextRange->getString(), sBlank });
+ aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, xTextRange->getString(), sBlank, sBlank });
}
}
@@ -1673,6 +1692,9 @@ OUString lcl_GetParagraphClassification(const uno::Reference<frame::XModel>& xMo
{
const OUString sPolicy = SfxClassificationHelper::policyTypeToString(SfxClassificationHelper::getPolicyType());
uno::Reference<text::XTextField> xTextField = lcl_FindParagraphClassificationField(xModel, xParagraph, sPolicy + "BusinessAuthorizationCategory:Name");
+ if (!xTextField.is())
+ xTextField = lcl_FindParagraphClassificationField(xModel, xParagraph, sPolicy + "BusinessAuthorizationCategory:Identifier");
+
if (xTextField.is())
{
const std::pair<OUString, OUString> rdfValuePair = lcl_getFieldRDF(xModel, xTextField, ParagraphClassificationValueRDFName);
More information about the Libreoffice-commits
mailing list