sw/source/core/access/accpara.cxx | 38 +++++---------- sw/source/core/access/accpara.hxx | 2 sw/source/core/unocore/unofield.cxx | 37 +++----------- writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx | 8 +-- writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx | 3 - 5 files changed, 30 insertions(+), 58 deletions(-)
New commits: commit e72c80c01629798a93948d4419f109ac324de4ef Author: Noel Grandin <[email protected]> Date: Sun Apr 3 17:56:12 2016 +0200 sequence->vector in writerfilter Change-Id: Ibc86ecc2b5dbeefd4d0411491a73f388ce303b4b Reviewed-on: https://gerrit.libreoffice.org/23763 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx index 734e55a..2df5a17 100644 --- a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx +++ b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.cxx @@ -50,9 +50,9 @@ void OOXMLBinaryObjectReference::read() { nOldSize = nSize; nSize += nBytesRead; - mSequence.realloc(nSize); + mSequence.resize(nSize); - memcpy(&mSequence[nOldSize], aSeq.getArray(), nBytesRead); + memcpy(&mSequence.data()[nOldSize], aSeq.getArray(), nBytesRead); } mbRead = true; @@ -66,8 +66,8 @@ void OOXMLBinaryObjectReference::resolve(BinaryObj & rHandler) writerfilter::Reference<Properties>::Pointer_t pRef = writerfilter::Reference<Properties>::Pointer_t(); - rHandler.data(reinterpret_cast<sal_uInt8 *>(&mSequence[0]), - mSequence.getLength(), pRef); + rHandler.data(reinterpret_cast<sal_uInt8 *>(mSequence.data()), + mSequence.size(), pRef); } }} diff --git a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx index 3a1cc03..d77de26 100644 --- a/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx +++ b/writerfilter/source/ooxml/OOXMLBinaryObjectReference.hxx @@ -21,6 +21,7 @@ #include <dmapper/resourcemodel.hxx> #include <ooxml/OOXMLDocument.hxx> +#include <vector> namespace writerfilter { namespace ooxml @@ -29,7 +30,7 @@ class OOXMLBinaryObjectReference : public writerfilter::Reference<BinaryObj> { OOXMLStream::Pointer_t mpStream; - css::uno::Sequence<sal_Int8> mSequence; + std::vector<sal_Int8> mSequence; bool mbRead; void read(); commit 55d146b732bf30f6a83a962b4394df8f2563a4b7 Author: Noel Grandin <[email protected]> Date: Sun Apr 3 16:40:26 2016 +0200 sequence->vector in sw Change-Id: I042fd1ce0fd9a55ebe4372599fede97990712528 Reviewed-on: https://gerrit.libreoffice.org/23758 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index c825638..b30442f 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1641,8 +1641,7 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( _getRunAttributesImpl( nIndex, aNames, aRunAttrSeq ); // merge default and run attributes - uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); - PropertyValue* pValues = aValues.getArray(); + std::vector< PropertyValue > aValues( aDefAttrSeq.size() ); sal_Int32 i = 0; for ( tAccParaPropValMap::const_iterator aDefIter = aDefAttrSeq.begin(); aDefIter != aDefAttrSeq.end(); @@ -1652,11 +1651,11 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( aRunAttrSeq.find( aDefIter->first ); if ( aRunIter != aRunAttrSeq.end() ) { - pValues[i] = aRunIter->second; + aValues[i] = aRunIter->second; } else { - pValues[i] = aDefIter->second; + aValues[i] = aDefIter->second; } ++i; } @@ -1669,29 +1668,25 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( tAccParaPropValMap aSupplementalAttrSeq; _getSupplementalAttributesImpl( nIndex, aSupplementalNames, aSupplementalAttrSeq ); - aValues.realloc( aValues.getLength() + aSupplementalAttrSeq.size() ); - pValues = aValues.getArray(); + aValues.resize( aValues.size() + aSupplementalAttrSeq.size() ); for ( tAccParaPropValMap::const_iterator aSupplementalIter = aSupplementalAttrSeq.begin(); aSupplementalIter != aSupplementalAttrSeq.end(); ++aSupplementalIter ) { - pValues[i] = aSupplementalIter->second; + aValues[i] = aSupplementalIter->second; ++i; } _correctValues( nIndex, aValues ); - aValues.realloc( aValues.getLength() + 1 ); - - pValues = aValues.getArray(); + aValues.resize( aValues.size() + 1 ); OUString strTypeName = GetFieldTypeNameAtIndex(nIndex); if (!strTypeName.isEmpty()) { - aValues.realloc( aValues.getLength() + 1 ); - pValues = aValues.getArray(); - PropertyValue& rValueFT = pValues[aValues.getLength() - 1]; + aValues.resize( aValues.size() + 1 ); + PropertyValue& rValueFT = aValues[aValues.size() - 1]; rValueFT.Name = "FieldType"; rValueFT.Value <<= strTypeName.toAsciiLowerCase(); rValueFT.Handle = -1; @@ -1700,24 +1695,23 @@ uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( //sort property values // build sorted index array - sal_Int32 nLength = aValues.getLength(); - const PropertyValue* pPairs = aValues.getConstArray(); + sal_Int32 nLength = aValues.size(); sal_Int32* pIndices = new sal_Int32[nLength]; for( i = 0; i < nLength; i++ ) pIndices[i] = i; - sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); + sort( &pIndices[0], &pIndices[nLength], IndexCompare(aValues.data()) ); // create sorted sequences according to index array uno::Sequence<PropertyValue> aNewValues( nLength ); PropertyValue* pNewValues = aNewValues.getArray(); for( i = 0; i < nLength; i++ ) { - pNewValues[i] = pPairs[pIndices[i]]; + pNewValues[i] = aValues[pIndices[i]]; } delete[] pIndices; return aNewValues; } - return aValues; + return comphelper::containerToSequence(aValues); } static void SetPutRecursive(SfxItemSet &targetSet, const SfxItemSet &sourceSet) @@ -2144,7 +2138,7 @@ void SwAccessibleParagraph::_getSupplementalAttributesImpl( } void SwAccessibleParagraph::_correctValues( const sal_Int32 nIndex, - uno::Sequence< PropertyValue >& rValues) + std::vector< PropertyValue >& rValues) { PropertyValue ChangeAttr, ChangeAttrColor; @@ -2209,14 +2203,12 @@ void SwAccessibleParagraph::_correctValues( const sal_Int32 nIndex, } } - PropertyValue* pValues = rValues.getArray(); - const SwTextNode* pTextNode( GetTextNode() ); - sal_Int32 nValues = rValues.getLength(); + sal_Int32 nValues = rValues.size(); for (sal_Int32 i = 0; i < nValues; ++i) { - PropertyValue& rValue = pValues[i]; + PropertyValue& rValue = rValues[i]; if (rValue.Name == ChangeAttr.Name ) { diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 9051f2a..bceb0b1 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -157,7 +157,7 @@ class SwAccessibleParagraph : void _correctValues( const sal_Int32 nIndex, - css::uno::Sequence< css::beans::PropertyValue >& rValues ); + std::vector< css::beans::PropertyValue >& rValues ); public: SwTOXSortTabBase* GetTOXSortTabBase(); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 55e3d98..b777045 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2960,7 +2960,7 @@ class SwXFieldEnumeration::Impl public: SwDoc * m_pDoc; - uno::Sequence< uno::Reference<text::XTextField> > m_Items; + std::vector< uno::Reference<text::XTextField> > m_Items; sal_Int32 m_nNextIndex; ///< index of next element to be returned explicit Impl(SwDoc & rDoc) @@ -2997,10 +2997,7 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc) : m_pImpl(new Impl(rDoc)) { // build sequence - sal_Int32 nSize = 32; - m_pImpl->m_Items.realloc( nSize ); - uno::Reference< text::XTextField > *pItems = m_pImpl->m_Items.getArray(); - sal_Int32 nFillPos = 0; + m_pImpl->m_Items.clear(); const SwFieldTypes* pFieldTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldTypes(); const size_t nCount = pFieldTypes->size(); @@ -3017,16 +3014,9 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc) bool bSkip = !pTextField || !pTextField->GetpTextNode()->GetNodes().IsDocNodes(); if (!bSkip) - pItems[ nFillPos++ ] = SwXTextField::CreateXTextField( - m_pImpl->m_pDoc, pCurFieldFormat); + m_pImpl->m_Items.push_back( SwXTextField::CreateXTextField( + m_pImpl->m_pDoc, pCurFieldFormat)); pCurFieldFormat = aIter.Next(); - - // enlarge sequence if necessary - if (m_pImpl->m_Items.getLength() == nFillPos) - { - m_pImpl->m_Items.realloc( 2 * m_pImpl->m_Items.getLength() ); - pItems = m_pImpl->m_Items.getArray(); - } } } // now handle meta-fields, which are not SwFields @@ -3034,19 +3024,8 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc) m_pImpl->m_pDoc->GetMetaFieldManager().getMetaFields() ); for (size_t i = 0; i < MetaFields.size(); ++i) { - pItems[ nFillPos ] = MetaFields[i]; - nFillPos++; - - //FIXME UGLY - // enlarge sequence if necessary - if (m_pImpl->m_Items.getLength() == nFillPos) - { - m_pImpl->m_Items.realloc( 2 * m_pImpl->m_Items.getLength() ); - pItems = m_pImpl->m_Items.getArray(); - } + m_pImpl->m_Items.push_back( MetaFields[i] ); } - // resize sequence to actual used size - m_pImpl->m_Items.realloc( nFillPos ); } SwXFieldEnumeration::~SwXFieldEnumeration() @@ -3058,7 +3037,7 @@ throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - return m_pImpl->m_nNextIndex < m_pImpl->m_Items.getLength(); + return m_pImpl->m_nNextIndex < (sal_Int32)m_pImpl->m_Items.size(); } uno::Any SAL_CALL SwXFieldEnumeration::nextElement() @@ -3067,7 +3046,7 @@ throw (container::NoSuchElementException, lang::WrappedTargetException, { SolarMutexGuard aGuard; - if (!(m_pImpl->m_nNextIndex < m_pImpl->m_Items.getLength())) + if (!(m_pImpl->m_nNextIndex < (sal_Int32)m_pImpl->m_Items.size())) throw container::NoSuchElementException( "SwXFieldEnumeration::nextElement", css::uno::Reference<css::uno::XInterface>()); @@ -3077,7 +3056,7 @@ throw (container::NoSuchElementException, lang::WrappedTargetException, (void)pItems; #endif uno::Reference< text::XTextField > &rxField = - m_pImpl->m_Items.getArray()[ m_pImpl->m_nNextIndex++ ]; + m_pImpl->m_Items[ m_pImpl->m_nNextIndex++ ]; uno::Any aRet; aRet <<= rxField; rxField = nullptr; // free memory for item that is not longer used _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
