tdf#123919 - Sort custom document properties
Sort custom document properties on opening the dialog under File >
Properties > Custom Properties. The sorting order in the document's xml
still depends on the generated handle of the document property itself.
Change-Id: I12c4f641d22ca0a3db2f4c6ef54f41c113aeeaa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115780
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 13349d3..82265a0 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1973,6 +1973,15 @@ void SfxCustomPropertiesPage::Reset( const SfxItemSet* rItemSet )
m_xPropertiesCtrl->ClearAllLines();
const SfxDocumentInfoItem& rInfoItem = rItemSet->Get(SID_DOCINFO);
std::vector< std::unique_ptr<CustomProperty> > aCustomProps = rInfoItem.GetCustomProperties();
// tdf#123919 - sort custom document properties
auto const sort = comphelper::string::NaturalStringSorter(
comphelper::getProcessComponentContext(),
Application::GetSettings().GetLanguageTag().getLocale());
std::sort(aCustomProps.begin(), aCustomProps.end(),
[&sort](const std::unique_ptr<CustomProperty>& rLHS,
const std::unique_ptr<CustomProperty>& rRHS) {
return sort.compare(rLHS->m_sName, rRHS->m_sName) < 0;
});
m_xPropertiesCtrl->SetCustomProperties(std::move(aCustomProps));
}
diff --git a/sw/qa/uitest/writer_tests/tdf81457.py b/sw/qa/uitest/writer_tests/tdf81457.py
index 52db731..ff021a4 100644
--- a/sw/qa/uitest/writer_tests/tdf81457.py
+++ b/sw/qa/uitest/writer_tests/tdf81457.py
@@ -20,18 +20,21 @@ class tdf81457(UITestCase):
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "2") #tab Custom properties
aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11',
'BookMarkInfo12', 'BookMarkInfo13']
aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0',
'00FF0000FF210', '00FF0000FF230']
# tdf#123919 - custom document properties are sorted now
aExpectedDocProp = {
2: {'aAndra': 'Ja'},
4: {'BookMarkCount': '78'},
5: {'BookMarkInfo1': '00FF0000FF010'},
6: {'BookMarkInfo2': '00FF0000FF030'}}
for i in range(6):
xNameBox = xDialog.getChild("namebox" + str(i + 1))
xTypeBox = xDialog.getChild("typebox" + str(i + 1))
xValueEdit = xDialog.getChild("valueedit" + str(i + 1))
self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text'])
for pos, aDocProp in aExpectedDocProp.items():
xNameBox = xDialog.getChild("namebox" + str(pos))
xTypeBox = xDialog.getChild("typebox" + str(pos))
xValueEdit = xDialog.getChild("valueedit" + str(pos))
name, value = aDocProp.popitem()
self.assertEqual(name, get_state_as_dict(xNameBox)['Text'])
self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText'])
self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13])
self.assertEqual(value, get_state_as_dict(xValueEdit)['Text'][:13])