diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx index 89228a0cc15d..e39fb9c616cc 100644 --- a/extensions/source/propctrlr/stringrepresentation.cxx +++ b/extensions/source/propctrlr/stringrepresentation.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "formresid.hrc" #include @@ -223,6 +224,24 @@ uno::Any SAL_CALL StringRepresentation::convertToPropertyValue(const OUString & return aReturn; } +namespace { + +// This comparison functor assumes an underlying set of constants with pairwise +// unequal values that are all of UNO SHORT or LONG type: +struct CompareConstants { + bool operator ()( + css::uno::Reference< css::reflection::XConstantTypeDescription > const & + c1, + css::uno::Reference< css::reflection::XConstantTypeDescription > const & + c2) const + { + return c1->getConstantValue().get() + < c2->getConstantValue().get(); + } +}; + +} + // lang::XInitialization: void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception) { @@ -244,7 +263,11 @@ void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & uno::UNO_QUERY_THROW ); m_xTypeDescription.set( xTypeDescProv->getByHierarchicalName( sConstantName ), uno::UNO_QUERY_THROW ); - m_aConstants = m_xTypeDescription->getConstants(); + comphelper::SequenceAsVector< + uno::Reference< reflection::XConstantTypeDescription > > + cs(m_xTypeDescription->getConstants()); + std::sort(cs.begin(), cs.end(), CompareConstants()); + cs >> m_aConstants; } } }