[Libreoffice-commits] core.git: 4 commits - sw/source
Michael Stahl
Michael.Stahl at cib.de
Fri May 11 15:00:20 UTC 2018
sw/source/core/doc/docedt.cxx | 7 +
sw/source/core/text/itrtxt.cxx | 2
sw/source/core/text/redlnitr.cxx | 152 ++++++++++++++++++++-------------------
sw/source/core/text/redlnitr.hxx | 47 ++++++------
sw/source/core/text/txtdrop.cxx | 2
5 files changed, 109 insertions(+), 101 deletions(-)
New commits:
commit caeda2233e648fb7537baee522410416dada39ea
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:29:33 2018 +0200
sw: fix invalid 16-bit downcast in SwTextIter::TruncLines()
Change-Id: I0a19e730d58c01b55a9de926aaaadb8ef4022317
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 11dd062e0cfd..15e2762b7323 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -351,7 +351,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
if( RES_TXTATR_FLYCNT == pHt->Which() )
{
// check, if hint is in our range
- const sal_uInt16 nTmpPos = pHt->GetStart();
+ const sal_Int32 nTmpPos = pHt->GetStart();
if ( nEnd <= nTmpPos && nTmpPos < nRangeEnd )
pFollow->InvalidateRange_(
SwCharRange( nTmpPos, nTmpPos ) );
commit 5bc362cb9619617cdc347ee7a3475d8e78b3a109
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Thu May 3 13:40:10 2018 +0200
sw: remove pointless indirection to SwTextSizeInfo::HasHint_
Change-Id: I0a6f329c2bc2d10fb993d42e07e71a7b5c5fd5e2
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 61160582db45..31b3eac7654c 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -162,7 +162,7 @@ sal_Int32 SwTextNode::GetDropLen( sal_Int32 nWishLen ) const
sal_Unicode const cChar = GetText()[i];
if( CH_TAB == cChar || CH_BREAK == cChar ||
(( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar )
- && SwTextSizeInfo::HasHint_( this, i ) ) )
+ && GetTextAttrForCharAt(i)) )
break;
}
return i;
commit bb7700d844152c7ba219ee7cfeee39ef1f6ca8d8
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri Apr 27 18:40:09 2018 +0200
sw: cosmetics
Change-Id: Ieed3c8251ab61d7c47314137f5f67cb736b1b158
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 4c0b7e885148..a139293fec7c 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -348,7 +348,7 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
if( bJoinPrev )
{
// We do not need to handle xmlids in this case, because
- // it is only invoked if one paragraph is completely empty
+ // it is only invoked if one paragraph is/becomes completely empty
// (see sw_GetJoinFlags)
{
// If PageBreaks are deleted/set, it must not be added to the Undo history!
@@ -360,8 +360,9 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
// PageDesc, etc. we also have to change SwUndoDelete.
// There, we copy the AUTO PageBreak from the GetMarkNode!
- /* The GetMarkNode */
- if( ( pTextNd = aIdx.GetNode().GetTextNode())->HasSwAttrSet() )
+ /* The MarkNode */
+ pTextNd = aIdx.GetNode().GetTextNode();
+ if (pTextNd->HasSwAttrSet())
{
const SfxPoolItem* pItem;
if( SfxItemState::SET == pTextNd->GetpSwAttrSet()->GetItemState(
commit 37c21f3cc49e262d20bbc592dbbeefcd9ba1597d
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon Apr 23 14:14:01 2018 +0200
SwRedlineItr: prefix members
Change-Id: If4e0dde34004766862240c10c41643c2919a6b18
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index acd4584054b2..89f981bf9734 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -153,34 +153,38 @@ void SwAttrIter::CtorInitAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf,
// The Redline-Iterator
// The following information/states exist in RedlineIterator:
//
-// nFirst is the first index of RedlineTable, which overlaps with the paragraph.
+// m_nFirst is the first index of RedlineTable, which overlaps with the paragraph.
//
-// nAct is the currently active (if bOn is set) or the next possible index.
-// nStart and nEnd give you the borders of the object within the paragraph.
+// m_nAct is the currently active (if m_bOn is set) or the next possible index.
+// m_nStart and m_nEnd give you the borders of the object within the paragraph.
//
-// If bOn is set, the font has been manipulated according to it.
+// If m_bOn is set, the font has been manipulated according to it.
//
-// If nAct is set to COMPLETE_STRING (via Reset()), then currently no
-// Redline is active, nStart and nEnd are invalid.
+// If m_nAct is set to COMPLETE_STRING (via Reset()), then currently no
+// Redline is active, m_nStart and m_nEnd are invalid.
SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
- SwAttrHandler& rAH, sal_Int32 nRed, bool bShw,
+ SwAttrHandler& rAH, sal_Int32 nRed, bool bShow,
const std::vector<ExtTextInputAttr> *pArr,
sal_Int32 nExtStart )
- : rDoc( *rTextNd.GetDoc() ), rAttrHandler( rAH ),
- nNdIdx( rTextNd.GetIndex() ), nFirst( nRed ),
- nAct( COMPLETE_STRING ), bOn( false ), bShow( bShw )
+ : m_rDoc( *rTextNd.GetDoc() )
+ , m_rAttrHandler( rAH )
+ , m_nNdIdx( rTextNd.GetIndex() )
+ , m_nFirst( nRed )
+ , m_nAct( COMPLETE_STRING )
+ , m_bOn( false )
+ , m_bShow( bShow )
{
if( pArr )
- pExt = new SwExtend( *pArr, nExtStart );
+ m_pExt = new SwExtend( *pArr, nExtStart );
else
- pExt = nullptr;
+ m_pExt = nullptr;
Seek (rFnt, 0, COMPLETE_STRING);
}
SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
{
Clear( nullptr );
- delete pExt;
+ delete m_pExt;
}
// The return value of SwRedlineItr::Seek tells you if the current font
@@ -191,72 +195,72 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
if( ExtOn() )
return 0; // Abbreviation: if we're within an ExtendTextInputs
// there can't be other changes of attributes (not even by redlining)
- if( bShow )
+ if (m_bShow)
{
- if( bOn )
+ if (m_bOn)
{
- if( nNew >= nEnd )
+ if (nNew >= m_nEnd)
{
--nRet;
Clear_( &rFnt ); // We go behind the current section
- ++nAct; // and check the next one
+ ++m_nAct; // and check the next one
}
- else if( nNew < nStart )
+ else if (nNew < m_nStart)
{
--nRet;
Clear_( &rFnt ); // We go in front of the current section
- if( nAct > nFirst )
- nAct = nFirst; // the test has to run from the beginning
+ if (m_nAct > m_nFirst)
+ m_nAct = m_nFirst; // the test has to run from the beginning
else
return nRet + EnterExtend( rFnt, nNew ); // There's none prior to us
}
else
return nRet + EnterExtend( rFnt, nNew ); // We stayed in the same section
}
- if( COMPLETE_STRING == nAct || nOld > nNew )
- nAct = nFirst;
+ if (COMPLETE_STRING == m_nAct || nOld > nNew)
+ m_nAct = m_nFirst;
- nStart = COMPLETE_STRING;
- nEnd = COMPLETE_STRING;
+ m_nStart = COMPLETE_STRING;
+ m_nEnd = COMPLETE_STRING;
- for( ; nAct < static_cast<sal_Int32>(rDoc.getIDocumentRedlineAccess().GetRedlineTable().size()) ; ++nAct )
+ for ( ; m_nAct < static_cast<sal_Int32>(m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size()) ; ++m_nAct)
{
- rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ]->CalcStartEnd( nNdIdx, nStart, nEnd );
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ]->CalcStartEnd(m_nNdIdx, m_nStart, m_nEnd);
- if( nNew < nEnd )
+ if (nNew < m_nEnd)
{
- if( nNew >= nStart ) // only possible candidate
+ if (nNew >= m_nStart) // only possible candidate
{
- bOn = true;
- const SwRangeRedline *pRed = rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ];
+ m_bOn = true;
+ const SwRangeRedline *pRed = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ];
- if (pSet)
- pSet->ClearItem();
+ if (m_pSet)
+ m_pSet->ClearItem();
else
{
SwAttrPool& rPool =
- const_cast<SwDoc&>(rDoc).GetAttrPool();
- pSet = o3tl::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{});
+ const_cast<SwDoc&>(m_rDoc).GetAttrPool();
+ m_pSet = o3tl::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{});
}
if( 1 < pRed->GetStackCount() )
FillHints( pRed->GetAuthor( 1 ), pRed->GetType( 1 ) );
FillHints( pRed->GetAuthor(), pRed->GetType() );
- SfxWhichIter aIter( *pSet );
+ SfxWhichIter aIter( *m_pSet );
sal_uInt16 nWhich = aIter.FirstWhich();
while( nWhich )
{
const SfxPoolItem* pItem;
if( ( nWhich < RES_CHRATR_END ) &&
- ( SfxItemState::SET == pSet->GetItemState( nWhich, true, &pItem ) ) )
+ ( SfxItemState::SET == m_pSet->GetItemState( nWhich, true, &pItem ) ) )
{
SwTextAttr* pAttr = MakeRedlineTextAttr(
- const_cast<SwDoc&>(rDoc),
+ const_cast<SwDoc&>(m_rDoc),
*const_cast<SfxPoolItem*>(pItem) );
pAttr->SetPriorityAttr( true );
m_Hints.push_back(pAttr);
- rAttrHandler.PushAndChg( *pAttr, rFnt );
+ m_rAttrHandler.PushAndChg( *pAttr, rFnt );
}
nWhich = aIter.NextWhich();
}
@@ -265,8 +269,8 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
}
break;
}
- nStart = COMPLETE_STRING;
- nEnd = COMPLETE_STRING;
+ m_nStart = COMPLETE_STRING;
+ m_nEnd = COMPLETE_STRING;
}
}
return nRet + EnterExtend( rFnt, nNew );
@@ -277,14 +281,14 @@ void SwRedlineItr::FillHints( std::size_t nAuthor, RedlineType_t eType )
switch ( eType )
{
case nsRedlineType_t::REDLINE_INSERT:
- SW_MOD()->GetInsertAuthorAttr(nAuthor, *pSet);
+ SW_MOD()->GetInsertAuthorAttr(nAuthor, *m_pSet);
break;
case nsRedlineType_t::REDLINE_DELETE:
- SW_MOD()->GetDeletedAuthorAttr(nAuthor, *pSet);
+ SW_MOD()->GetDeletedAuthorAttr(nAuthor, *m_pSet);
break;
case nsRedlineType_t::REDLINE_FORMAT:
case nsRedlineType_t::REDLINE_FMTCOLL:
- SW_MOD()->GetFormatAuthorAttr(nAuthor, *pSet);
+ SW_MOD()->GetFormatAuthorAttr(nAuthor, *m_pSet);
break;
default:
break;
@@ -295,34 +299,34 @@ void SwRedlineItr::ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bCh
{
OSL_ENSURE( IsOn(), "SwRedlineItr::ChangeTextAttr: Off?" );
- if( !bShow && !pExt )
+ if (!m_bShow && !m_pExt)
return;
if( bChg )
{
- if ( pExt && pExt->IsOn() )
- rAttrHandler.PushAndChg( rHt, *pExt->GetFont() );
+ if (m_pExt && m_pExt->IsOn())
+ m_rAttrHandler.PushAndChg( rHt, *m_pExt->GetFont() );
else
- rAttrHandler.PushAndChg( rHt, *pFnt );
+ m_rAttrHandler.PushAndChg( rHt, *pFnt );
}
else
{
- OSL_ENSURE( ! pExt || ! pExt->IsOn(), "Pop of attribute during opened extension" );
- rAttrHandler.PopAndChg( rHt, *pFnt );
+ OSL_ENSURE( ! m_pExt || ! m_pExt->IsOn(), "Pop of attribute during opened extension" );
+ m_rAttrHandler.PopAndChg( rHt, *pFnt );
}
}
void SwRedlineItr::Clear_( SwFont* pFnt )
{
- OSL_ENSURE( bOn, "SwRedlineItr::Clear: Off?" );
- bOn = false;
+ OSL_ENSURE( m_bOn, "SwRedlineItr::Clear: Off?" );
+ m_bOn = false;
for (auto const& hint : m_Hints)
{
if( pFnt )
- rAttrHandler.PopAndChg( *hint, *pFnt );
+ m_rAttrHandler.PopAndChg( *hint, *pFnt );
else
- rAttrHandler.Pop( *hint );
- SwTextAttr::Destroy(hint, const_cast<SwDoc&>(rDoc).GetAttrPool() );
+ m_rAttrHandler.Pop( *hint );
+ SwTextAttr::Destroy(hint, const_cast<SwDoc&>(m_rDoc).GetAttrPool() );
}
m_Hints.clear();
}
@@ -330,20 +334,20 @@ void SwRedlineItr::Clear_( SwFont* pFnt )
sal_Int32 SwRedlineItr::GetNextRedln_( sal_Int32 nNext )
{
nNext = NextExtend( nNext );
- if( !bShow || COMPLETE_STRING == nFirst )
+ if (!m_bShow || COMPLETE_STRING == m_nFirst)
return nNext;
- if( COMPLETE_STRING == nAct )
+ if (COMPLETE_STRING == m_nAct)
{
- nAct = nFirst;
- rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ]->CalcStartEnd( nNdIdx, nStart, nEnd );
+ m_nAct = m_nFirst;
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ]->CalcStartEnd(m_nNdIdx, m_nStart, m_nEnd);
}
- if( bOn || !nStart )
+ if (m_bOn || !m_nStart)
{
- if( nEnd < nNext )
- nNext = nEnd;
+ if (m_nEnd < nNext)
+ nNext = m_nEnd;
}
- else if( nStart < nNext )
- nNext = nStart;
+ else if (m_nStart < nNext)
+ nNext = m_nStart;
return nNext;
}
@@ -364,30 +368,30 @@ bool SwRedlineItr::ChkSpecialUnderline_() const
bool SwRedlineItr::CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd )
{
- if( nFirst == COMPLETE_STRING )
+ if (m_nFirst == COMPLETE_STRING)
return false;
if( nChkEnd == nChkStart ) // empty lines look one char further
++nChkEnd;
- sal_Int32 nOldStart = nStart;
- sal_Int32 nOldEnd = nEnd;
- sal_Int32 nOldAct = nAct;
+ sal_Int32 nOldStart = m_nStart;
+ sal_Int32 nOldEnd = m_nEnd;
+ sal_Int32 nOldAct = m_nAct;
bool bRet = false;
- for( nAct = nFirst; nAct < static_cast<sal_Int32>(rDoc.getIDocumentRedlineAccess().GetRedlineTable().size()) ; ++nAct )
+ for (m_nAct = m_nFirst; m_nAct < static_cast<sal_Int32>(m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size()) ; ++m_nAct)
{
- rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ nAct ]->CalcStartEnd( nNdIdx, nStart, nEnd );
- if( nChkEnd < nStart )
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[ m_nAct ]->CalcStartEnd( m_nNdIdx, m_nStart, m_nEnd );
+ if (nChkEnd < m_nStart)
break;
- if( nChkStart <= nEnd && ( nChkEnd > nStart || COMPLETE_STRING == nEnd ) )
+ if (nChkStart <= m_nEnd && (nChkEnd > m_nStart || COMPLETE_STRING == m_nEnd))
{
bRet = true;
break;
}
}
- nStart = nOldStart;
- nEnd = nOldEnd;
- nAct = nOldAct;
+ m_nStart = nOldStart;
+ m_nEnd = nOldEnd;
+ m_nAct = nOldAct;
return bRet;
}
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 879a9e952d67..bdb719fb4cc5 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -64,17 +64,17 @@ public:
class SwRedlineItr
{
std::deque<SwTextAttr *> m_Hints;
- const SwDoc& rDoc;
- SwAttrHandler& rAttrHandler;
- std::unique_ptr<SfxItemSet> pSet;
- SwExtend *pExt;
- sal_uLong nNdIdx;
- sal_Int32 nFirst;
- sal_Int32 nAct;
- sal_Int32 nStart;
- sal_Int32 nEnd;
- bool bOn;
- bool bShow;
+ const SwDoc& m_rDoc;
+ SwAttrHandler& m_rAttrHandler;
+ std::unique_ptr<SfxItemSet> m_pSet;
+ SwExtend *m_pExt;
+ sal_uLong m_nNdIdx;
+ sal_Int32 m_nFirst;
+ sal_Int32 m_nAct;
+ sal_Int32 m_nStart;
+ sal_Int32 m_nEnd;
+ bool m_bOn;
+ bool m_bShow;
void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const;
@@ -82,11 +82,11 @@ class SwRedlineItr
short Seek_( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld );
sal_Int32 GetNextRedln_( sal_Int32 nNext );
short EnterExtend( SwFont& rFnt, sal_Int32 nNew ) {
- if( pExt ) return pExt->Enter( rFnt, nNew );
+ if (m_pExt) return m_pExt->Enter( rFnt, nNew );
return 0;
}
sal_Int32 NextExtend( sal_Int32 nNext ) {
- if( pExt ) return pExt->Next( nNext );
+ if (m_pExt) return m_pExt->Next( nNext );
return nNext;
}
public:
@@ -94,31 +94,34 @@ public:
sal_Int32 nRedlPos, bool bShw, const std::vector<ExtTextInputAttr> *pArr = nullptr,
sal_Int32 nExtStart = COMPLETE_STRING );
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
- bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
- void Clear( SwFont* pFnt ) { if( bOn ) Clear_( pFnt ); }
+ bool IsOn() const { return m_bOn || (m_pExt && m_pExt->IsOn()); }
+ void Clear( SwFont* pFnt ) { if (m_bOn) Clear_( pFnt ); }
void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
short Seek( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld ) {
- if( bShow || pExt ) return Seek_( rFnt, nNew, nOld );
+ if (m_bShow || m_pExt) return Seek_( rFnt, nNew, nOld );
return 0;
}
- void Reset() { if( nAct != nFirst ) nAct = COMPLETE_STRING;
- if( pExt ) pExt->Reset(); }
+ void Reset() {
+ if (m_nAct != m_nFirst) m_nAct = COMPLETE_STRING;
+ if (m_pExt) m_pExt->Reset();
+ }
sal_Int32 GetNextRedln( sal_Int32 nNext ) {
- if( bShow || pExt ) return GetNextRedln_( nNext );
+ if (m_bShow || m_pExt) return GetNextRedln_( nNext );
return nNext;
}
bool ChkSpecialUnderline() const
{ return IsOn() && ChkSpecialUnderline_(); }
bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
bool LeaveExtend( SwFont& rFnt, sal_Int32 nNew )
- { return pExt->Leave(rFnt, nNew ); }
+ { return m_pExt->Leave(rFnt, nNew ); }
bool ExtOn() {
- if( pExt ) return pExt->IsOn();
+ if (m_pExt) return m_pExt->IsOn();
return false;
}
void UpdateExtFont( SwFont &rFnt ) {
OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
- pExt->UpdateFont( rFnt ); }
+ m_pExt->UpdateFont( rFnt );
+ }
};
#endif
More information about the Libreoffice-commits
mailing list