diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-14 08:08:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-14 08:17:50 +0200 |
commit | db0cb39225c5f865c199f8aa0b3fa4aa6e721de1 (patch) | |
tree | 2e4f827846e3babd795b77536dea9d07aa83c3d4 | |
parent | 94ea3a18829914aa76b5534f8a551ad37d59cf07 (diff) |
loplugin:mergeclasses merge SwTextAttrIterator with SwLanguageIterator
Change-Id: Iaa9184f6145625c897fa5b919e9bf0c898b41102
-rw-r--r-- | compilerplugins/clang/mergeclasses.results | 1 | ||||
-rw-r--r-- | sw/inc/txatritr.hxx | 40 | ||||
-rw-r--r-- | sw/source/core/txtnode/txatritr.cxx | 16 |
3 files changed, 25 insertions, 32 deletions
diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results index c81c01899af9..68088b901707 100644 --- a/compilerplugins/clang/mergeclasses.results +++ b/compilerplugins/clang/mergeclasses.results @@ -157,7 +157,6 @@ merge SwNumberTreeNode with SwNodeNum merge SwSelPaintRects with SwShellCursor merge SwSidebarItem with SwAnnotationItem merge SwTextAdjuster with SwTextCursor -merge SwTextAttrIterator with SwLanguageIterator merge SwUnoCursor with SwUnoTableCursor merge SwXParaFrameEnumeration with SwXParaFrameEnumerationImpl merge SwXParagraphEnumeration with SwXParagraphEnumerationImpl 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<const SwTextAttr*> aStack; - const SwTextNode& rTextNd; - const SfxPoolItem *pParaItem, *pCurItem; - size_t nAttrPos; - sal_Int32 nChgPos; - sal_uInt16 nWhichId; + SwScriptIterator aSIter; + std::deque<const SwTextAttr*> + 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<const SvxLanguageItem&>(GetAttr()).GetValue(); } + bool Next(); + sal_Int32 GetChgPos() const { return nChgPos; } + sal_uInt16 GetLanguage() const + { return static_cast<const SvxLanguageItem&>(*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() ) |