Kaydet (Commit) f8a3250c authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide: add 3rd mode to SwRedlineItr

So it can work both in the old ignore-redlines mode and in the new
hide-redlines mode.

Change-Id: I29b23c6749a0f314aff5e9b2342fb389b53bd107
üst 30559172
...@@ -485,7 +485,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const ...@@ -485,7 +485,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
SwAttrHandler aAttrHandler; SwAttrHandler aAttrHandler;
aAttrHandler.Init( rTextNode.GetSwAttrSet(), aAttrHandler.Init( rTextNode.GetSwAttrSet(),
*rTextNode.getIDocumentSettingAccess() ); *rTextNode.getIDocumentSettingAccess() );
SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler, nRedlPos, true ); SwRedlineItr aRedln(rTextNode, *pFnt, aAttrHandler, nRedlPos, SwRedlineItr::Mode::Show);
} }
} }
......
...@@ -259,7 +259,7 @@ SwTwips SwTextFrame::EmptyHeight() const ...@@ -259,7 +259,7 @@ SwTwips SwTextFrame::EmptyHeight() const
aAttrHandler.Init( GetTextNode()->GetSwAttrSet(), aAttrHandler.Init( GetTextNode()->GetSwAttrSet(),
*GetTextNode()->getIDocumentSettingAccess() ); *GetTextNode()->getIDocumentSettingAccess() );
SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler, SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler,
nRedlPos, true ); nRedlPos, SwRedlineItr::Mode::Show);
} }
} }
......
...@@ -243,7 +243,12 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode, ...@@ -243,7 +243,12 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
} }
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos, m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
bShow, pArr, pExtInp ? pExtInp->Start() : nullptr); m_pMergedPara
? SwRedlineItr::Mode::Hide
: bShow
? SwRedlineItr::Mode::Show
: SwRedlineItr::Mode::Ignore,
pArr, pExtInp ? pExtInp->Start() : nullptr);
if( m_pRedline->IsOn() ) if( m_pRedline->IsOn() )
++m_nChgCnt; ++m_nChgCnt;
...@@ -264,7 +269,8 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode, ...@@ -264,7 +269,8 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// If m_nAct is set to SwRedlineTable::npos (via Reset()), then currently no // If m_nAct is set to SwRedlineTable::npos (via Reset()), then currently no
// Redline is active, m_nStart and m_nEnd are invalid. // Redline is active, m_nStart and m_nEnd are invalid.
SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
SwAttrHandler& rAH, sal_Int32 nRed, bool bShow, SwAttrHandler& rAH, sal_Int32 nRed,
Mode const mode,
const std::vector<ExtTextInputAttr> *pArr, const std::vector<ExtTextInputAttr> *pArr,
SwPosition const*const pExtInputStart) SwPosition const*const pExtInputStart)
: m_rDoc( *rTextNd.GetDoc() ) : m_rDoc( *rTextNd.GetDoc() )
...@@ -273,7 +279,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, ...@@ -273,7 +279,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
, m_nFirst( nRed ) , m_nFirst( nRed )
, m_nAct( SwRedlineTable::npos ) , m_nAct( SwRedlineTable::npos )
, m_bOn( false ) , m_bOn( false )
, m_bShow( bShow ) , m_eMode( mode )
{ {
if( pArr ) if( pArr )
{ {
...@@ -301,7 +307,8 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const n ...@@ -301,7 +307,8 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const n
if( ExtOn() ) if( ExtOn() )
return 0; // Abbreviation: if we're within an ExtendTextInputs return 0; // Abbreviation: if we're within an ExtendTextInputs
// there can't be other changes of attributes (not even by redlining) // there can't be other changes of attributes (not even by redlining)
if (m_bShow) assert(m_eMode == Mode::Hide || m_nNdIdx == nNode);
if (m_eMode == Mode::Show)
{ {
if (m_bOn) if (m_bOn)
{ {
...@@ -405,7 +412,7 @@ void SwRedlineItr::ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bCh ...@@ -405,7 +412,7 @@ void SwRedlineItr::ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bCh
{ {
OSL_ENSURE( IsOn(), "SwRedlineItr::ChangeTextAttr: Off?" ); OSL_ENSURE( IsOn(), "SwRedlineItr::ChangeTextAttr: Off?" );
if (!m_bShow && !m_pExt) if (m_eMode != Mode::Show && !m_pExt)
return; return;
if( bChg ) if( bChg )
...@@ -444,7 +451,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl ...@@ -444,7 +451,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
sal_Int32 nStart(m_nStart); sal_Int32 nStart(m_nStart);
sal_Int32 nEnd(m_nEnd); sal_Int32 nEnd(m_nEnd);
nNext = NextExtend(pNode->GetIndex(), nNext); nNext = NextExtend(pNode->GetIndex(), nNext);
if (!m_bShow || SwRedlineTable::npos == m_nFirst) if (m_eMode == Mode::Ignore || SwRedlineTable::npos == m_nFirst)
return std::make_pair(nNext, nullptr); return std::make_pair(nNext, nullptr);
if (SwRedlineTable::npos == rAct) if (SwRedlineTable::npos == rAct)
{ {
...@@ -463,7 +470,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl ...@@ -463,7 +470,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
else if (nStart <= nNext) else if (nStart <= nNext)
{ {
nNext = nStart; nNext = nStart;
if (!m_bShow) if (m_eMode == Mode::Hide)
{ {
SwRangeRedline const* pRedline = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct]; SwRangeRedline const* pRedline = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE) if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
...@@ -511,7 +518,7 @@ bool SwRedlineItr::CheckLine( ...@@ -511,7 +518,7 @@ bool SwRedlineItr::CheckLine(
{ {
// note: previously this would return true in the (!m_bShow && m_pExt) // note: previously this would return true in the (!m_bShow && m_pExt)
// case, but surely that was a bug? // case, but surely that was a bug?
if (m_nFirst == SwRedlineTable::npos || !m_bShow) if (m_nFirst == SwRedlineTable::npos || m_eMode != Mode::Show)
return false; return false;
assert(nStartNode == nEndNode); (void) nStartNode; (void) nEndNode; assert(nStartNode == nEndNode); (void) nStartNode; (void) nEndNode;
if( nChkEnd == nChkStart ) // empty lines look one char further if( nChkEnd == nChkStart ) // empty lines look one char further
......
...@@ -81,7 +81,10 @@ class SwRedlineItr ...@@ -81,7 +81,10 @@ class SwRedlineItr
sal_Int32 m_nStart; sal_Int32 m_nStart;
sal_Int32 m_nEnd; sal_Int32 m_nEnd;
bool m_bOn; bool m_bOn;
bool m_bShow; public:
enum class Mode { Show, Ignore, Hide };
private:
Mode const m_eMode;
void Clear_( SwFont* pFnt ); void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const; bool ChkSpecialUnderline_() const;
...@@ -98,7 +101,8 @@ class SwRedlineItr ...@@ -98,7 +101,8 @@ class SwRedlineItr
} }
public: public:
SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH, SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH,
sal_Int32 nRedlPos, bool bShw, const std::vector<ExtTextInputAttr> *pArr = nullptr, sal_Int32 nRedlPos, Mode mode,
const std::vector<ExtTextInputAttr> *pArr = nullptr,
SwPosition const* pExtInputStart = nullptr); SwPosition const* pExtInputStart = nullptr);
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE; ~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
SwRedlineTable::size_type GetAct() const { return m_nAct; } SwRedlineTable::size_type GetAct() const { return m_nAct; }
...@@ -107,7 +111,7 @@ public: ...@@ -107,7 +111,7 @@ public:
void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg ); void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
short Seek(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld) short Seek(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld)
{ {
if (m_bShow || m_pExt) return Seek_(rFnt, nNode, nNew, nOld); if (m_eMode != Mode::Hide || m_pExt) return Seek_(rFnt, nNode, nNew, nOld);
return 0; return 0;
} }
void Reset() { void Reset() {
......
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