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

sw_redlinehide: TextFrameIndex conversion in SwTextFrame::SwClientNotify

... etc.

Change-Id: I34336fa923b5c40a040490dd618633035efd5d94
üst 3811947b
...@@ -1213,7 +1213,9 @@ bool SwTextFrame::IsIdxInside(TextFrameIndex const nPos, TextFrameIndex const nL ...@@ -1213,7 +1213,9 @@ bool SwTextFrame::IsIdxInside(TextFrameIndex const nPos, TextFrameIndex const nL
TextFrameIndex const nMax = GetFollow()->GetOfst(); TextFrameIndex const nMax = GetFollow()->GetOfst();
// either the range overlap or our text has been deleted // either the range overlap or our text has been deleted
if( nMax > nPos || nMax > GetText().getLength() ) // sw_redlinehide: GetText() should be okay here because it has already
// been updated in the INS/DEL hint case
if (nMax > nPos || nMax > TextFrameIndex(GetText().getLength()))
return true; return true;
// changes made in the first line of a follow can modify the master // changes made in the first line of a follow can modify the master
...@@ -1332,11 +1334,12 @@ void SwTextFrame::CalcLineSpace() ...@@ -1332,11 +1334,12 @@ void SwTextFrame::CalcLineSpace()
} }
} }
static void lcl_SetWrong( SwTextFrame& rFrame, sal_Int32 nPos, sal_Int32 nCnt, bool bMove ) static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode const& rNode,
sal_Int32 const nPos, sal_Int32 const nCnt, bool const bMove)
{ {
if ( !rFrame.IsFollow() ) if ( !rFrame.IsFollow() )
{ {
SwTextNode* pTextNode = rFrame.GetTextNode(); SwTextNode* pTextNode = const_cast<SwTextNode*>(&rNode);
IGrammarContact* pGrammarContact = getGrammarContact( *pTextNode ); IGrammarContact* pGrammarContact = getGrammarContact( *pTextNode );
SwGrammarMarkUp* pWrongGrammar = pGrammarContact ? SwGrammarMarkUp* pWrongGrammar = pGrammarContact ?
pGrammarContact->getGrammarCheck( *pTextNode, false ) : pGrammarContact->getGrammarCheck( *pTextNode, false ) :
...@@ -1396,7 +1399,7 @@ static void lcl_SetWrong( SwTextFrame& rFrame, sal_Int32 nPos, sal_Int32 nCnt, b ...@@ -1396,7 +1399,7 @@ static void lcl_SetWrong( SwTextFrame& rFrame, sal_Int32 nPos, sal_Int32 nCnt, b
} }
} }
static void lcl_SetScriptInval( SwTextFrame& rFrame, sal_Int32 nPos ) static void lcl_SetScriptInval(SwTextFrame& rFrame, TextFrameIndex const nPos)
{ {
if( rFrame.GetPara() ) if( rFrame.GetPara() )
rFrame.GetPara()->GetScriptInfo().SetInvalidityA( nPos ); rFrame.GetPara()->GetScriptInfo().SetInvalidityA( nPos );
...@@ -1467,7 +1470,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1467,7 +1470,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
// collection has changed // collection has changed
Prepare(); Prepare();
InvalidatePrt_(); InvalidatePrt_();
lcl_SetWrong( *this, 0, COMPLETE_STRING, false ); lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
SetDerivedR2L( false ); SetDerivedR2L( false );
CheckDirChange(); CheckDirChange();
// Force complete paint due to existing indents. // Force complete paint due to existing indents.
...@@ -1491,8 +1494,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1491,8 +1494,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
// save stack // save stack
// warning: one has to ensure that all variables are set // warning: one has to ensure that all variables are set
sal_Int32 nPos; TextFrameIndex nPos;
sal_Int32 nLen; TextFrameIndex nLen;
bool bSetFieldsDirty = false; bool bSetFieldsDirty = false;
bool bRecalcFootnoteFlag = false; bool bRecalcFootnoteFlag = false;
...@@ -1506,11 +1509,13 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1506,11 +1509,13 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
break; break;
case RES_INS_TXT: case RES_INS_TXT:
{ {
nPos = static_cast<const SwInsText*>(pNew)->nPos; sal_Int32 const nNPos = static_cast<const SwInsText*>(pNew)->nPos;
nLen = static_cast<const SwInsText*>(pNew)->nLen; sal_Int32 const nNLen = static_cast<const SwInsText*>(pNew)->nLen;
nPos = MapModelToView(&rNode, nNPos);
nLen = TextFrameIndex(nNLen);
if (m_pMergedPara) if (m_pMergedPara)
{ {
UpdateMergedParaForInsert(*m_pMergedPara, rNode, nPos, nLen); UpdateMergedParaForInsert(*m_pMergedPara, rNode, nNPos, nNLen);
} }
if( IsIdxInside( nPos, nLen ) ) if( IsIdxInside( nPos, nLen ) )
{ {
...@@ -1523,9 +1528,9 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1523,9 +1528,9 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
Prepare(); Prepare();
} }
else else
InvalidateRange_( SwCharRange( nPos, nLen ), nLen ); InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
} }
lcl_SetWrong( *this, nPos, nLen, true ); lcl_SetWrong( *this, rNode, nNPos, nNLen, true );
lcl_SetScriptInval( *this, nPos ); lcl_SetScriptInval( *this, nPos );
bSetFieldsDirty = true; bSetFieldsDirty = true;
if( HasFollow() ) if( HasFollow() )
...@@ -1534,35 +1539,41 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1534,35 +1539,41 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
break; break;
case RES_DEL_CHR: case RES_DEL_CHR:
{ {
nPos = static_cast<const SwDelChr*>(pNew)->nPos; sal_Int32 const nNPos = static_cast<const SwDelChr*>(pNew)->nPos;
nPos = MapModelToView(&rNode, nNPos);
if (m_pMergedPara) if (m_pMergedPara)
{ {
nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nPos, 1); nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nNPos, 1);
} }
else else
{ {
nLen = TextFrameIndex(1); nLen = TextFrameIndex(1);
} }
lcl_SetWrong( *this, nPos, -1, true ); lcl_SetWrong( *this, rNode, nNPos, -1, true );
if (nLen) if (nLen)
{ {
InvalidateRange( SwCharRange(nPos, nLen), -1 ); InvalidateRange( SwCharRange(nPos, nLen), -1 );
lcl_SetScriptInval( *this, nPos ); lcl_SetScriptInval( *this, nPos );
bSetFieldsDirty = bRecalcFootnoteFlag = true; bSetFieldsDirty = bRecalcFootnoteFlag = true;
if (HasFollow()) if (HasFollow())
lcl_ModifyOfst( this, nPos, COMPLETE_STRING ); lcl_ModifyOfst(this, nPos, TextFrameIndex(COMPLETE_STRING));
} }
} }
break; break;
case RES_DEL_TXT: case RES_DEL_TXT:
{ {
nPos = static_cast<const SwDelText*>(pNew)->nStart; sal_Int32 const nNPos = static_cast<const SwDelText*>(pNew)->nStart;
nLen = static_cast<const SwDelText*>(pNew)->nLen; sal_Int32 const nNLen = static_cast<const SwDelText*>(pNew)->nLen;
nPos = MapModelToView(&rNode, nNPos);
if (m_pMergedPara) if (m_pMergedPara)
{ // update merged before doing anything else { // update merged before doing anything else
nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nPos, nLen); nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nNPos, nNLen);
} }
const sal_Int32 m = -nLen; else
{
nLen = TextFrameIndex(nNLen);
}
const sal_Int32 m = -nNLen;
if ((!m_pMergedPara || nLen) && IsIdxInside(nPos, nLen)) if ((!m_pMergedPara || nLen) && IsIdxInside(nPos, nLen))
{ {
if( !nLen ) if( !nLen )
...@@ -1570,7 +1581,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1570,7 +1581,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
else else
InvalidateRange( SwCharRange(nPos, TextFrameIndex(1)), m ); InvalidateRange( SwCharRange(nPos, TextFrameIndex(1)), m );
} }
lcl_SetWrong( *this, nPos, m, true ); lcl_SetWrong( *this, rNode, nNPos, m, true );
if (nLen) if (nLen)
{ {
lcl_SetScriptInval( *this, nPos ); lcl_SetScriptInval( *this, nPos );
...@@ -1582,8 +1593,10 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1582,8 +1593,10 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
break; break;
case RES_UPDATE_ATTR: case RES_UPDATE_ATTR:
{ {
nPos = static_cast<const SwUpdateAttr*>(pNew)->getStart(); sal_Int32 const nNPos = static_cast<const SwUpdateAttr*>(pNew)->getStart();
nLen = static_cast<const SwUpdateAttr*>(pNew)->getEnd() - nPos; sal_Int32 const nNLen = static_cast<const SwUpdateAttr*>(pNew)->getEnd() - nNPos;
nPos = MapModelToView(&rNode, nNPos);
nLen = MapModelToView(&rNode, nNPos + nNLen) - nPos;
if( IsIdxInside( nPos, nLen ) ) if( IsIdxInside( nPos, nLen ) )
{ {
// We need to reformat anyways, even if the invalidated // We need to reformat anyways, even if the invalidated
...@@ -1593,7 +1606,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1593,7 +1606,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
// FootnoteNumbers need to be formatted // FootnoteNumbers need to be formatted
if( !nLen ) if( !nLen )
nLen = 1; nLen = TextFrameIndex(1);
InvalidateRange_( SwCharRange( nPos, nLen) ); InvalidateRange_( SwCharRange( nPos, nLen) );
const sal_uInt16 nTmp = static_cast<const SwUpdateAttr*>(pNew)->getWhichAttr(); const sal_uInt16 nTmp = static_cast<const SwUpdateAttr*>(pNew)->getWhichAttr();
...@@ -1601,7 +1614,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1601,7 +1614,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_INETFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp || if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_INETFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp ||
RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp ) RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp )
{ {
lcl_SetWrong( *this, nPos, nPos + nLen, false ); lcl_SetWrong( *this, rNode, nNPos, nNPos + nNLen, false );
lcl_SetScriptInval( *this, nPos ); lcl_SetScriptInval( *this, nPos );
} }
} }
...@@ -1635,7 +1648,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1635,7 +1648,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
case RES_TXTATR_FIELD: case RES_TXTATR_FIELD:
case RES_TXTATR_ANNOTATION: case RES_TXTATR_ANNOTATION:
{ {
nPos = static_cast<const SwFormatField*>(pNew)->GetTextField()->GetStart(); sal_Int32 const nNPos = static_cast<const SwFormatField*>(pNew)->GetTextField()->GetStart();
nPos = MapModelToView(&rNode, nNPos);
if (IsIdxInside(nPos, TextFrameIndex(1))) if (IsIdxInside(nPos, TextFrameIndex(1)))
{ {
if( pNew == pOld ) if( pNew == pOld )
...@@ -1651,13 +1665,14 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1651,13 +1665,14 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
bSetFieldsDirty = true; bSetFieldsDirty = true;
// ST2 // ST2
if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() ) if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() )
lcl_SetWrong( *this, nPos, nPos + 1, false ); lcl_SetWrong( *this, rNode, nNPos, nNPos + 1, false );
} }
break; break;
case RES_TXTATR_FTN : case RES_TXTATR_FTN :
{ {
nPos = static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetStart(); nPos = MapModelToView(&rNode,
static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetStart());
if (IsInFootnote() || IsIdxInside(nPos, TextFrameIndex(1))) if (IsInFootnote() || IsIdxInside(nPos, TextFrameIndex(1)))
Prepare( PREP_FTN, static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote() ); Prepare( PREP_FTN, static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote() );
break; break;
...@@ -1674,7 +1689,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1674,7 +1689,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FTN, false, &pItem )) if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FTN, false, &pItem ))
{ {
nPos = static_cast<const SwFormatFootnote*>(pItem)->GetTextFootnote()->GetStart(); nPos = MapModelToView(&rNode,
static_cast<const SwFormatFootnote*>(pItem)->GetTextFootnote()->GetStart());
if (IsIdxInside(nPos, TextFrameIndex(1))) if (IsIdxInside(nPos, TextFrameIndex(1)))
Prepare( PREP_FTN, pNew ); Prepare( PREP_FTN, pNew );
nClear = 0x01; nClear = 0x01;
...@@ -1683,7 +1699,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1683,7 +1699,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FIELD, false, &pItem )) if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FIELD, false, &pItem ))
{ {
nPos = static_cast<const SwFormatField*>(pItem)->GetTextField()->GetStart(); nPos = MapModelToView(&rNode,
static_cast<const SwFormatField*>(pItem)->GetTextField()->GetStart());
if (IsIdxInside(nPos, TextFrameIndex(1))) if (IsIdxInside(nPos, TextFrameIndex(1)))
{ {
const SfxPoolItem* pOldItem = pOld ? const SfxPoolItem* pOldItem = pOld ?
...@@ -1786,8 +1803,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1786,8 +1803,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
if ( SfxItemState::SET == if ( SfxItemState::SET ==
rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) ) rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) )
{ {
lcl_SetWrong( *this, 0, COMPLETE_STRING, false ); lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
lcl_SetScriptInval( *this, 0 ); lcl_SetScriptInval( *this, TextFrameIndex(0) );
} }
else if ( SfxItemState::SET == else if ( SfxItemState::SET ==
rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) || rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) ||
...@@ -1795,14 +1812,14 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1795,14 +1812,14 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) || rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) ||
SfxItemState::SET == SfxItemState::SET ==
rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) ) rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) )
lcl_SetWrong( *this, 0, COMPLETE_STRING, false ); lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
else if ( SfxItemState::SET == else if ( SfxItemState::SET ==
rNewSet.GetItemState( RES_CHRATR_FONT, false ) || rNewSet.GetItemState( RES_CHRATR_FONT, false ) ||
SfxItemState::SET == SfxItemState::SET ==
rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) || rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) ||
SfxItemState::SET == SfxItemState::SET ==
rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) ) rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) )
lcl_SetScriptInval( *this, 0 ); lcl_SetScriptInval( *this, TextFrameIndex(0) );
else if ( SfxItemState::SET == else if ( SfxItemState::SET ==
rNewSet.GetItemState( RES_FRAMEDIR, false ) rNewSet.GetItemState( RES_FRAMEDIR, false )
&& (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)) && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify))
...@@ -1901,8 +1918,9 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1901,8 +1918,9 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
if( pDocPos->nDocPos <= getFrameArea().Top() ) if( pDocPos->nDocPos <= getFrameArea().Top() )
{ {
const SwFormatField *pField = static_cast<const SwFormatField *>(pNew); const SwFormatField *pField = static_cast<const SwFormatField *>(pNew);
InvalidateRange( TextFrameIndex const nIndex(MapModelToView(&rNode,
SwCharRange(pField->GetTextField()->GetStart(), TextFrameIndex(1))); pField->GetTextField()->GetStart()));
InvalidateRange(SwCharRange(nIndex, TextFrameIndex(1)));
} }
} }
break; break;
...@@ -2183,7 +2201,8 @@ bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid, ...@@ -2183,7 +2201,8 @@ bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid,
else else
{ {
// We are the TextFrame _with_ the footnote // We are the TextFrame _with_ the footnote
const sal_Int32 nPos = pFootnote->GetStart(); TextFrameIndex const nPos = MapModelToView(
&pFootnote->GetTextNode(), pFootnote->GetStart());
InvalidateRange(SwCharRange(nPos, TextFrameIndex(1)), 1); InvalidateRange(SwCharRange(nPos, TextFrameIndex(1)), 1);
} }
break; break;
......
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