summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-05-04 13:04:41 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-05-12 05:04:57 +0200
commitccdb98c0e590281f63a8c180a2eb87086210efbd (patch)
tree98e0b192123fa140bdf2a7bc8f826ed33d218c3c /editeng
parentd4f07d4c08724602d0a13045bec957e285d45c0d (diff)
Drop some uses of css::uno::Sequence::getConstArray
where it was obsoleted by commits 2484de6728bd11bb7949003d112f1ece2223c7a1 (Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and fb3c04bd1930eedacd406874e1a285d62bbf27d9 (Drop non-const Sequence::operator[] in internal code 2021-11-05). Change-Id: I64683093afc48ddf2307dc1dee2302cf0b3cbecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167110 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx25
-rw-r--r--editeng/source/accessibility/AccessibleStaticTextBase.cxx23
2 files changed, 19 insertions, 29 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 1ab756832ad7..da13332d9ad4 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -796,11 +796,14 @@ namespace accessibility
struct IndexCompare
{
- const PropertyValue* pValues;
- explicit IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {}
+ const uno::Sequence<beans::PropertyValue>& m_rValues;
+ explicit IndexCompare(const uno::Sequence<beans::PropertyValue>& rValues)
+ : m_rValues(rValues)
+ {
+ }
bool operator() ( sal_Int32 a, sal_Int32 b ) const
{
- return pValues[a].Name < pValues[b].Name;
+ return m_rValues[a].Name < m_rValues[b].Name;
}
};
@@ -1228,19 +1231,13 @@ namespace accessibility
//sort property values
// build sorted index array
sal_Int32 nLength = aRes.getLength();
- const beans::PropertyValue* pPairs = aRes.getConstArray();
- std::unique_ptr<sal_Int32[]> pIndices(new sal_Int32[nLength]);
- sal_Int32 i = 0;
- for( i = 0; i < nLength; i++ )
- pIndices[i] = i;
- std::sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
+ std::vector<sal_Int32> indices(nLength);
+ std::iota(indices.begin(), indices.end(), 0);
+ std::sort(indices.begin(), indices.end(), IndexCompare(aRes));
// create sorted sequences according to index array
uno::Sequence<beans::PropertyValue> aNewValues( nLength );
- beans::PropertyValue* pNewValues = aNewValues.getArray();
- for( i = 0; i < nLength; i++ )
- {
- pNewValues[i] = pPairs[pIndices[i]];
- }
+ std::transform(indices.begin(), indices.end(), aNewValues.getArray(),
+ [&aRes](sal_Int32 index) { return aRes[index]; });
return aNewValues;
}
diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
index 262c52781e0d..7d22150e1503 100644
--- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
@@ -903,13 +903,9 @@ namespace accessibility
for ( const auto& rDefAttr : aDefAttrVec )
{
- const beans::PropertyValue* pItr = aSeq.getConstArray();
- const beans::PropertyValue* pEnd = pItr + aSeq.getLength();
- const beans::PropertyValue* pFind = std::find_if( pItr, pEnd, PropertyValueEqualFunctor(rDefAttr) );
- if ( pFind != pEnd )
- {
- aIntersectionVec.push_back( *pFind );
- }
+ auto it = std::find_if(aSeq.begin(), aSeq.end(), PropertyValueEqualFunctor(rDefAttr));
+ if (it != aSeq.end())
+ aIntersectionVec.push_back(*it);
}
aDefAttrVec.swap( aIntersectionVec );
@@ -937,16 +933,13 @@ namespace accessibility
uno::Sequence< beans::PropertyValue > aIntersectionSeq = getDefaultAttributes( RequestedAttributes );
PropertyValueVector aDiffVec;
- const beans::PropertyValue* pDefAttr = aDefAttrSeq.getConstArray();
- const sal_Int32 nLength = aDefAttrSeq.getLength();
- for ( sal_Int32 i = 0; i < nLength; ++i )
+ for (auto& defAttr : aDefAttrSeq)
{
- const beans::PropertyValue* pItr = aIntersectionSeq.getConstArray();
- const beans::PropertyValue* pEnd = pItr + aIntersectionSeq.getLength();
- bool bNone = std::none_of( pItr, pEnd, PropertyValueEqualFunctor( pDefAttr[i] ) );
- if ( bNone && pDefAttr[i].Handle != 0)
+ bool bNone = std::none_of(aIntersectionSeq.begin(), aIntersectionSeq.end(),
+ PropertyValueEqualFunctor(defAttr));
+ if (bNone && defAttr.Handle != 0)
{
- aDiffVec.push_back( pDefAttr[i] );
+ aDiffVec.push_back(defAttr);
}
}