[Libreoffice-commits] core.git: 2 commits - basic/source extensions/source
Stephan Bergmann
sbergman at redhat.com
Mon Aug 19 05:16:11 PDT 2013
basic/source/classes/sbunoobj.cxx | 9 ++----
extensions/source/propctrlr/stringrepresentation.cxx | 25 ++++++++++++++++++-
2 files changed, 27 insertions(+), 7 deletions(-)
New commits:
commit 4b2c05d4f71ae9c6586b423fea802208da265765
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Aug 19 14:15:20 2013 +0200
Simplify iteration over Sequence
Change-Id: I84b79c6cc11a5cd506e22caf294423a3c0b953f0
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 6b8544b..9bc6907 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -3353,20 +3353,17 @@ void VBAConstantHelper::init()
}
aConstCache.push_back( sLeafName ); // assume constant group names are unique
Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
- Reference< XConstantTypeDescription >* pSrc = aConsts.getArray();
- sal_Int32 nLen = aConsts.getLength();
- for ( sal_Int32 index =0; index<nLen; ++pSrc, ++index )
+ for (sal_Int32 i = 0; i != aConsts.getLength(); ++i)
{
// store constant member name
- Reference< XConstantTypeDescription >& rXConst = *pSrc;
- sFullName = rXConst->getName();
+ sFullName = aConsts[i]->getName();
indexLastDot = sFullName.lastIndexOf('.');
sLeafName = sFullName;
if ( indexLastDot > -1 )
{
sLeafName = sFullName.copy( indexLastDot + 1);
}
- aConstHash[ sLeafName.toAsciiLowerCase() ] = rXConst->getConstantValue();
+ aConstHash[ sLeafName.toAsciiLowerCase() ] = aConsts[i]->getConstantValue();
}
}
}
commit def066bb6559e8c77eeb924db1356f9848f5c8a2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Aug 19 14:10:41 2013 +0200
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
diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx
index 89228a0..e39fb9c 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;
}
}
}
More information about the Libreoffice-commits
mailing list