summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-08-19 14:10:41 +0200
committerEike Rathke <erack@redhat.com>2013-08-19 17:51:19 +0000
commit6c17704810cbd8b937abaa915ef89c89337f713d (patch)
treec5cc9b87e95fb529db358c236d5c68238b4366a9
parentc1ba41e17fbf5039067b46df5c433a5811353d8b (diff)
fdo#67109: Order of XConstantsTypeDescription.getConstants is unspecified
...it looks like it used to be the order the constants appeared in the .idl file, while now it happens to be the lexicographical order of the constant's names. For all the constant groups in com.sun.star.report the order expected by the code appears to be the order of the constant's numeric values (which happens to coincide with the order of appearance in the .idl files), so explicitly sort them that way. Change-Id: I550401b2742fffb7c96a7787498967a7cd78fff8 (cherry picked from commit def066bb6559e8c77eeb924db1356f9848f5c8a2) Reviewed-on: https://gerrit.libreoffice.org/5513 Reviewed-by: Petr Mladek <pmladek@suse.cz> Tested-by: Petr Mladek <pmladek@suse.cz> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--extensions/source/propctrlr/stringrepresentation.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx
index a68c8d0489d4..4c8d4aa286cf 100644
--- a/extensions/source/propctrlr/stringrepresentation.cxx
+++ b/extensions/source/propctrlr/stringrepresentation.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/Time.hpp>
#include <comphelper/sequence.hxx>
+#include <comphelper/sequenceasvector.hxx>
#include <connectivity/dbconversion.hxx>
#include "formresid.hrc"
#include <tools/debug.hxx>
@@ -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<sal_Int32>()
+ < c2->getConstantValue().get<sal_Int32>();
+ }
+};
+
+}
+
// 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;
}
}
}