loplugin:mergeclasses merge SwTextAttrIterator with SwLanguageIterator

Change-Id: Iaa9184f6145625c897fa5b919e9bf0c898b41102
This commit is contained in:
Noel Grandin
2016-10-14 08:08:01 +02:00
parent 94ea3a1882
commit db0cb39225
3 changed files with 25 additions and 32 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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() )