Kaydet (Commit) b47bca7f authored tarafından Noel Grandin's avatar Noel Grandin

OSequenceIterator is not necessary anymore

we have been able to iterate over a sequence for a long time now

Change-Id: Ie7ed6ec25682f631e01170029f7c9f0089448836
Reviewed-on: https://gerrit.libreoffice.org/68666
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 96af93e5
...@@ -644,12 +644,14 @@ void ODBExport::exportConnectionData() ...@@ -644,12 +644,14 @@ void ODBExport::exportConnectionData()
template< typename T > void ODBExport::exportDataSourceSettingsSequence( template< typename T > void ODBExport::exportDataSourceSettingsSequence(
std::vector< TypedPropertyValue >::iterator const & in) std::vector< TypedPropertyValue >::iterator const & in)
{ {
OSequenceIterator< T > i( in->Value ); css::uno::Sequence<T> anySeq;
while (i.hasMoreElements()) bool bSuccess = in->Value >>= anySeq;
assert(bSuccess); (void)bSuccess;
for (T const & i : anySeq )
{ {
SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false); SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false);
// (no whitespace inside the tag) // (no whitespace inside the tag)
Characters(implConvertAny(i.nextElement())); Characters(implConvertAny(css::uno::Any(i)));
} }
} }
......
...@@ -97,79 +97,6 @@ namespace comphelper ...@@ -97,79 +97,6 @@ namespace comphelper
_rSeq.realloc(nLength-1); _rSeq.realloc(nLength-1);
} }
//= iterating through sequences
/** a helper class for iterating through a sequence
*/
template <class TYPE>
class OSequenceIterator
{
const TYPE* m_pElements;
sal_Int32 m_nLen;
const TYPE* m_pCurrent;
public:
/** construct a sequence iterator from a sequence
*/
OSequenceIterator(const css::uno::Sequence< TYPE >& _rSeq);
/** construct a sequence iterator from a Any containing a sequence
*/
OSequenceIterator(const css::uno::Any& _rSequenceAny);
bool hasMoreElements() const;
css::uno::Any nextElement();
private:
inline void construct(const css::uno::Sequence< TYPE >& _rSeq);
};
template <class TYPE>
inline OSequenceIterator<TYPE>::OSequenceIterator(const css::uno::Sequence< TYPE >& _rSeq)
:m_pElements(nullptr)
,m_nLen(0)
,m_pCurrent(nullptr)
{
construct(_rSeq);
}
template <class TYPE>
inline OSequenceIterator<TYPE>::OSequenceIterator(const css::uno::Any& _rSequenceAny)
:m_pElements(nullptr)
,m_nLen(0)
,m_pCurrent(nullptr)
{
css::uno::Sequence< TYPE > aContainer;
bool bSuccess = _rSequenceAny >>= aContainer;
OSL_ENSURE(bSuccess, "OSequenceIterator::OSequenceIterator: invalid Any!");
construct(aContainer);
}
template <class TYPE>
void OSequenceIterator<TYPE>::construct(const css::uno::Sequence< TYPE >& _rSeq)
{
m_pElements = _rSeq.getConstArray();
m_nLen = _rSeq.getLength();
m_pCurrent = m_pElements;
}
template <class TYPE>
inline bool OSequenceIterator<TYPE>::hasMoreElements() const
{
return m_pCurrent - m_pElements < m_nLen;
}
template <class TYPE>
inline css::uno::Any OSequenceIterator<TYPE>::nextElement()
{
return css::uno::toAny(*m_pCurrent++);
}
/** Copy from a plain C/C++ array into a Sequence. /** Copy from a plain C/C++ array into a Sequence.
@tpl SrcType @tpl SrcType
......
...@@ -43,10 +43,8 @@ bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/) ...@@ -43,10 +43,8 @@ bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
if (rVal >>= aValue) if (rVal >>= aValue)
{ {
m_aMap.clear(); m_aMap.clear();
comphelper::OSequenceIterator<beans::PropertyValue> i(aValue); for (beans::PropertyValue const& aPropertyValue : aValue)
while (i.hasMoreElements())
{ {
auto aPropertyValue = i.nextElement().get<beans::PropertyValue>();
m_aMap[aPropertyValue.Name] = aPropertyValue.Value; m_aMap[aPropertyValue.Name] = aPropertyValue.Value;
} }
return true; return true;
......
...@@ -93,10 +93,12 @@ namespace xmloff ...@@ -93,10 +93,12 @@ namespace xmloff
OPropertyExport::exportRemainingPropertiesSequence( OPropertyExport::exportRemainingPropertiesSequence(
Any const & value, token::XMLTokenEnum eValueAttName) Any const & value, token::XMLTokenEnum eValueAttName)
{ {
OSequenceIterator< T > i(value); css::uno::Sequence<T> anySeq;
while (i.hasMoreElements()) bool bSuccess = value >>= anySeq;
assert(bSuccess); (void)bSuccess;
for (T const & i : anySeq)
{ {
OUString sValue(implConvertAny(i.nextElement())); OUString sValue(implConvertAny(makeAny(i)));
AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue ); AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
SvXMLElementExport aValueTag( SvXMLElementExport aValueTag(
m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, m_rContext.getGlobalContext(), XML_NAMESPACE_FORM,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment