summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2017-10-30 14:25:23 -0400
committerAshod Nakashian <ashnakash@gmail.com>2017-11-03 11:16:25 +0100
commit25a26b66b398d127842369e06c3ef95fe901e305 (patch)
tree4ed12732e4d478d68f8591212893e341a87aa6c4
parent2ecd194d091fd33c2554bfff960985b2bd5e654e (diff)
TSCP: flesh out ClassificationResult
Change-Id: Ie6ee33cc21f6f27ae1d58a0e47f367b0539e4378 Reviewed-on: https://gerrit.libreoffice.org/44117 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--include/svx/ClassificationField.hxx40
-rw-r--r--sd/source/ui/view/drviews2.cxx18
-rw-r--r--svx/source/dialog/ClassificationDialog.cxx20
-rw-r--r--sw/source/core/edit/edfcol.cxx16
4 files changed, 59 insertions, 35 deletions
diff --git a/include/svx/ClassificationField.hxx b/include/svx/ClassificationField.hxx
index 4d4588c68177..32f783eb1896 100644
--- a/include/svx/ClassificationField.hxx
+++ b/include/svx/ClassificationField.hxx
@@ -26,6 +26,38 @@ enum class ClassificationType
PARAGRAPH,
};
+class SVX_DLLPUBLIC ClassificationResult
+{
+public:
+ ClassificationType meType;
+ OUString msName; //< Display text or 'Name' field (from example.xml).
+ OUString msAbbreviatedName; //< Abbreviated name, displayed instead of Name.
+ OUString msIdentifier; //< The identifier of this entry (from example.xml).
+
+ ClassificationResult(ClassificationType eType, const OUString& sName,
+ const OUString& sAbbreviatedName = "", const OUString& sIdentifier = "")
+ : meType(eType)
+ , msName(sName)
+ , msAbbreviatedName(sAbbreviatedName)
+ , msIdentifier(sIdentifier)
+ {
+ }
+
+ /// Returns the text to display, which is the Abbreviated Name, if provided, otherwise Name.
+ OUString getDisplayText() const
+ {
+ return !msAbbreviatedName.isEmpty() ? msAbbreviatedName : msName;
+ }
+
+ bool operator==(const ClassificationResult& rOther) const
+ {
+ return (meType == rOther.meType &&
+ msName == rOther.msName &&
+ msAbbreviatedName == rOther.msAbbreviatedName &&
+ msIdentifier == rOther.msIdentifier);
+ }
+};
+
class SVX_DLLPUBLIC ClassificationField : public SvxFieldData
{
public:
@@ -60,14 +92,6 @@ public:
}
};
-struct SVX_DLLPUBLIC ClassificationResult
-{
- ClassificationType meType;
- 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
#endif // INCLUDED_SVX_CLASSIFICATIONFIELD_HXX
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 992e6608f961..3ccbe562ccf8 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -470,7 +470,7 @@ public:
for (svx::ClassificationResult const & rResult : rResults)
{
if (rResult.meType == svx::ClassificationType::CATEGORY)
- aHelper.SetBACName(rResult.msString, SfxClassificationHelper::getPolicyType());
+ aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType());
}
sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType());
@@ -491,31 +491,31 @@ public:
case svx::ClassificationType::TEXT:
{
OUString sKey = aKeyCreator.makeNumberedMarkingTextKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
}
break;
case svx::ClassificationType::CATEGORY:
{
OUString sKey = aKeyCreator.makeCategoryKey();
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
}
break;
case svx::ClassificationType::MARKING:
{
OUString sKey = aKeyCreator.makeMarkingKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
}
break;
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
OUString sKey = aKeyCreator.makeIntellectualPropertyPartKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
- pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msString), EE_FEATURE_FIELD), aPosition);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
+ pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
}
break;
@@ -526,7 +526,7 @@ public:
SfxItemSet aItemSet(m_rDrawViewShell.GetDoc()->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{});
- if (rResult.msString == "BOLD")
+ if (rResult.msName == "BOLD")
aItemSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
else
aItemSet.Put(SvxWeightItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT));
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 57c29847d3b1..7eed3b94e424 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -371,36 +371,36 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
sal_Int32 nParagraph = -1;
for (ClassificationResult const & rClassificationResult : rInput)
{
- OUString msAbbreviatedString = rClassificationResult.msAbbreviatedString;
- if (msAbbreviatedString.isEmpty())
- msAbbreviatedString = maHelper.GetAbbreviatedBACName(rClassificationResult.msString);
+ OUString msAbbreviatedName = rClassificationResult.msAbbreviatedName;
+ if (msAbbreviatedName.isEmpty())
+ msAbbreviatedName = maHelper.GetAbbreviatedBACName(rClassificationResult.msName);
switch (rClassificationResult.meType)
{
case svx::ClassificationType::TEXT:
{
- m_pEditWindow->pEdView->InsertText(rClassificationResult.msString);
+ m_pEditWindow->pEdView->InsertText(rClassificationResult.msName);
}
break;
case svx::ClassificationType::CATEGORY:
{
- m_pClassificationListBox->SelectEntry(rClassificationResult.msString);
+ m_pClassificationListBox->SelectEntry(rClassificationResult.msName);
m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos());
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::MARKING:
{
- m_pMarkingListBox->SelectEntry(rClassificationResult.msString);
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
+ m_pMarkingListBox->SelectEntry(rClassificationResult.msName);
+ insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
- insertField(rClassificationResult.meType, msAbbreviatedString, rClassificationResult.msString, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
@@ -412,7 +412,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
m_pEditWindow->pEdView->InsertParaBreak();
// Set paragraph font weight
- FontWeight eWeight = (rClassificationResult.msString == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL;
+ FontWeight eWeight = (rClassificationResult.msName == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL;
std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_pEditWindow->pEdEngine->GetParaAttribs(nParagraph)));
pSet->Put(SvxWeightItem(eWeight, EE_CHAR_WEIGHT));
m_pEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet);
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 0120eee919c1..2e0fa19c32e7 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -677,7 +677,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
{
if (rResult.meType == svx::ClassificationType::CATEGORY)
{
- aHelper.SetBACName(rResult.msString, SfxClassificationHelper::getPolicyType());
+ aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType());
}
}
@@ -716,7 +716,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
{
OUString sKey = aCreator.makeNumberedMarkingTextKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
insertFieldToDocument(xMultiServiceFactory, xHeaderText, xHeaderParagraphCursor, sKey);
insertFieldToDocument(xMultiServiceFactory, xFooterText, xFooterParagraphCursor, sKey);
}
@@ -733,7 +733,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
case svx::ClassificationType::MARKING:
{
OUString sKey = aCreator.makeMarkingKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
insertFieldToDocument(xMultiServiceFactory, xHeaderText, xHeaderParagraphCursor, sKey);
insertFieldToDocument(xMultiServiceFactory, xFooterText, xFooterParagraphCursor, sKey);
}
@@ -742,7 +742,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
OUString sKey = aCreator.makeIntellectualPropertyPartKey();
- addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msString);
+ addOrInsertDocumentProperty(xPropertyContainer, sKey, rResult.msName);
insertFieldToDocument(xMultiServiceFactory, xHeaderText, xHeaderParagraphCursor, sKey);
insertFieldToDocument(xMultiServiceFactory, xFooterText, xFooterParagraphCursor, sKey);
}
@@ -763,7 +763,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
uno::Reference<beans::XPropertySet> xHeaderPropertySet(xHeaderParagraphCursor, uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xFooterPropertySet(xFooterParagraphCursor, uno::UNO_QUERY_THROW);
- if (rResult.msString == "BOLD")
+ if (rResult.msName == "BOLD")
{
xHeaderPropertySet->setPropertyValue("CharWeight", uno::makeAny(awt::FontWeight::BOLD));
xFooterPropertySet->setPropertyValue("CharWeight", uno::makeAny(awt::FontWeight::BOLD));
@@ -1042,10 +1042,10 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
break;
}
- OUString sDisplayText = (isFirst ? ("(" + rResult.msAbbreviatedString) : rResult.msAbbreviatedString);
+ OUString sDisplayText = (isFirst ? ("(" + rResult.msAbbreviatedName) : rResult.msAbbreviatedName);
if (isLast)
sDisplayText += ")";
- lcl_UpdateParagraphClassificationField(GetDoc(), xModel, xParent, sKey, rResult.msString, sDisplayText);
+ lcl_UpdateParagraphClassificationField(GetDoc(), xModel, xParent, sKey, rResult.msName, sDisplayText);
}
}
@@ -1750,7 +1750,7 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass()
{
case svx::ClassificationType::CATEGORY:
{
- const OUString sHighestClass = aHelper.GetHigherClass(sHighestParaClass, rResult.msString);
+ const OUString sHighestClass = aHelper.GetHigherClass(sHighestParaClass, rResult.msName);
const auto eType = SfxClassificationHelper::stringToPolicyType(sHighestClass);
SetClassification(sHighestClass, eType);
}