Kaydet (Commit) db0cb392 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:mergeclasses merge SwTextAttrIterator with SwLanguageIterator

Change-Id: Iaa9184f6145625c897fa5b919e9bf0c898b41102
üst 94ea3a18
...@@ -157,7 +157,6 @@ merge SwNumberTreeNode with SwNodeNum ...@@ -157,7 +157,6 @@ merge SwNumberTreeNode with SwNodeNum
merge SwSelPaintRects with SwShellCursor merge SwSelPaintRects with SwShellCursor
merge SwSidebarItem with SwAnnotationItem merge SwSidebarItem with SwAnnotationItem
merge SwTextAdjuster with SwTextCursor merge SwTextAdjuster with SwTextCursor
merge SwTextAttrIterator with SwLanguageIterator
merge SwUnoCursor with SwUnoTableCursor merge SwUnoCursor with SwUnoTableCursor
merge SwXParaFrameEnumeration with SwXParaFrameEnumerationImpl merge SwXParaFrameEnumeration with SwXParaFrameEnumerationImpl
merge SwXParagraphEnumeration with SwXParagraphEnumerationImpl merge SwXParagraphEnumeration with SwXParagraphEnumerationImpl
......
...@@ -48,38 +48,28 @@ public: ...@@ -48,38 +48,28 @@ public:
const OUString& GetText() const { return m_rText; } const OUString& GetText() const { return m_rText; }
}; };
class SwTextAttrIterator class SwLanguageIterator
{ {
SwScriptIterator aSIter; SwScriptIterator aSIter;
std::deque<const SwTextAttr*> aStack; std::deque<const SwTextAttr*>
const SwTextNode& rTextNd; aStack;
const SfxPoolItem *pParaItem, *pCurItem; const SwTextNode& rTextNd;
size_t nAttrPos; const SfxPoolItem* pParaItem;
sal_Int32 nChgPos; const SfxPoolItem* pCurItem;
sal_uInt16 nWhichId; size_t nAttrPos;
sal_Int32 nChgPos;
sal_uInt16 nWhichId;
void AddToStack( const SwTextAttr& rAttr ); void AddToStack( const SwTextAttr& rAttr );
void SearchNextChg(); void SearchNextChg();
public: public:
SwTextAttrIterator( const SwTextNode& rTextNd, sal_uInt16 nWhichId, SwLanguageIterator( const SwTextNode& rTextNd, sal_Int32 nStart );
sal_Int32 nStart );
bool Next(); bool Next();
sal_Int32 GetChgPos() const { return nChgPos; }
const SfxPoolItem& GetAttr() const { return *pCurItem; } sal_uInt16 GetLanguage() const
sal_Int32 GetChgPos() const { return nChgPos; } { return static_cast<const SvxLanguageItem&>(*pCurItem).GetValue(); }
};
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(); }
}; };
#endif #endif
......
...@@ -93,15 +93,19 @@ bool SwScriptIterator::Next() ...@@ -93,15 +93,19 @@ bool SwScriptIterator::Next()
return bRet; return bRet;
} }
SwTextAttrIterator::SwTextAttrIterator( const SwTextNode& rTNd, sal_uInt16 nWhchId, SwLanguageIterator::SwLanguageIterator( const SwTextNode& rTNd,
sal_Int32 nStt ) sal_Int32 nStt )
: aSIter( rTNd.GetText(), nStt ), rTextNd( rTNd ), : aSIter( rTNd.GetText(), nStt ),
pParaItem( nullptr ), nAttrPos( 0 ), nChgPos( nStt ), nWhichId( nWhchId ) rTextNd( rTNd ),
pParaItem( nullptr ),
nAttrPos( 0 ),
nChgPos( nStt ),
nWhichId( RES_CHRATR_LANGUAGE )
{ {
SearchNextChg(); SearchNextChg();
} }
bool SwTextAttrIterator::Next() bool SwLanguageIterator::Next()
{ {
bool bRet = false; bool bRet = false;
if (nChgPos < aSIter.GetText().getLength()) if (nChgPos < aSIter.GetText().getLength())
...@@ -150,7 +154,7 @@ bool SwTextAttrIterator::Next() ...@@ -150,7 +154,7 @@ bool SwTextAttrIterator::Next()
return bRet; return bRet;
} }
void SwTextAttrIterator::AddToStack( const SwTextAttr& rAttr ) void SwLanguageIterator::AddToStack( const SwTextAttr& rAttr )
{ {
size_t nIns = 0; size_t nIns = 0;
const sal_Int32 nEndPos = *rAttr.End(); const sal_Int32 nEndPos = *rAttr.End();
...@@ -161,7 +165,7 @@ void SwTextAttrIterator::AddToStack( const SwTextAttr& rAttr ) ...@@ -161,7 +165,7 @@ void SwTextAttrIterator::AddToStack( const SwTextAttr& rAttr )
aStack.insert( aStack.begin() + nIns, &rAttr ); aStack.insert( aStack.begin() + nIns, &rAttr );
} }
void SwTextAttrIterator::SearchNextChg() void SwLanguageIterator::SearchNextChg()
{ {
sal_uInt16 nWh = 0; sal_uInt16 nWh = 0;
if( nChgPos == aSIter.GetScriptChgPos() ) if( nChgPos == aSIter.GetScriptChgPos() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment