From db0cb39225c5f865c199f8aa0b3fa4aa6e721de1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 14 Oct 2016 08:08:01 +0200 Subject: loplugin:mergeclasses merge SwTextAttrIterator with SwLanguageIterator Change-Id: Iaa9184f6145625c897fa5b919e9bf0c898b41102 --- sw/inc/txatritr.hxx | 40 ++++++++++++++----------------------- sw/source/core/txtnode/txatritr.cxx | 16 +++++++++------ 2 files changed, 25 insertions(+), 31 deletions(-) (limited to 'sw') diff --git a/sw/inc/txatritr.hxx b/sw/inc/txatritr.hxx index dfb44747a810..9843094fbe7e 100644 --- a/sw/inc/txatritr.hxx +++ b/sw/inc/txatritr.hxx @@ -48,38 +48,28 @@ public: const OUString& GetText() const { return m_rText; } }; -class SwTextAttrIterator +class SwLanguageIterator { - SwScriptIterator aSIter; - std::deque aStack; - const SwTextNode& rTextNd; - const SfxPoolItem *pParaItem, *pCurItem; - size_t nAttrPos; - sal_Int32 nChgPos; - sal_uInt16 nWhichId; + SwScriptIterator aSIter; + std::deque + aStack; + const SwTextNode& rTextNd; + const SfxPoolItem* pParaItem; + const SfxPoolItem* pCurItem; + size_t nAttrPos; + sal_Int32 nChgPos; + sal_uInt16 nWhichId; void AddToStack( const SwTextAttr& rAttr ); void SearchNextChg(); public: - SwTextAttrIterator( const SwTextNode& rTextNd, sal_uInt16 nWhichId, - sal_Int32 nStart ); + SwLanguageIterator( const SwTextNode& rTextNd, sal_Int32 nStart ); - bool Next(); - - const SfxPoolItem& GetAttr() const { return *pCurItem; } - sal_Int32 GetChgPos() const { return nChgPos; } -}; - -class SwLanguageIterator : public SwTextAttrIterator -{ -public: - SwLanguageIterator( const SwTextNode& rTextNode, sal_Int32 nStart ) - : SwTextAttrIterator( rTextNode, RES_CHRATR_LANGUAGE, nStart ) - {} - - sal_uInt16 GetLanguage() const - { return static_cast(GetAttr()).GetValue(); } + bool Next(); + sal_Int32 GetChgPos() const { return nChgPos; } + sal_uInt16 GetLanguage() const + { return static_cast(*pCurItem).GetValue(); } }; #endif diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx index 1ae345863953..d98607e1e9e7 100644 --- a/sw/source/core/txtnode/txatritr.cxx +++ b/sw/source/core/txtnode/txatritr.cxx @@ -93,15 +93,19 @@ bool SwScriptIterator::Next() return bRet; } -SwTextAttrIterator::SwTextAttrIterator( const SwTextNode& rTNd, sal_uInt16 nWhchId, +SwLanguageIterator::SwLanguageIterator( const SwTextNode& rTNd, sal_Int32 nStt ) - : aSIter( rTNd.GetText(), nStt ), rTextNd( rTNd ), - pParaItem( nullptr ), nAttrPos( 0 ), nChgPos( nStt ), nWhichId( nWhchId ) + : aSIter( rTNd.GetText(), nStt ), + rTextNd( rTNd ), + pParaItem( nullptr ), + nAttrPos( 0 ), + nChgPos( nStt ), + nWhichId( RES_CHRATR_LANGUAGE ) { SearchNextChg(); } -bool SwTextAttrIterator::Next() +bool SwLanguageIterator::Next() { bool bRet = false; if (nChgPos < aSIter.GetText().getLength()) @@ -150,7 +154,7 @@ bool SwTextAttrIterator::Next() return bRet; } -void SwTextAttrIterator::AddToStack( const SwTextAttr& rAttr ) +void SwLanguageIterator::AddToStack( const SwTextAttr& rAttr ) { size_t nIns = 0; const sal_Int32 nEndPos = *rAttr.End(); @@ -161,7 +165,7 @@ void SwTextAttrIterator::AddToStack( const SwTextAttr& rAttr ) aStack.insert( aStack.begin() + nIns, &rAttr ); } -void SwTextAttrIterator::SearchNextChg() +void SwLanguageIterator::SearchNextChg() { sal_uInt16 nWh = 0; if( nChgPos == aSIter.GetScriptChgPos() ) -- cgit