[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide' - 103 commits - include/o3tl sw/source
Michael Stahl
Michael.Stahl at cib.de
Tue May 15 16:42:51 UTC 2018
Rebased ref, commits from common ancestor:
commit 73de1963c77a8c376d59cd3ee7e6b6ee2927c554
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 18:04:06 2018 +0200
sw_redlinehide: adapt more functions of SwAttrIter
Change-Id: I17c14f9e66c82cafa2fb5b3e8e45b3bf94fc4a88
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 20f25621273a..eb48340f3656 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -112,12 +112,20 @@ SwAttrIter::~SwAttrIter()
*/
SwTextAttr *SwAttrIter::GetAttr(TextFrameIndex const nPosition) const
{
- return (m_pTextNode) ? m_pTextNode->GetTextAttrForCharAt(nPosition) : nullptr;
+ std::pair<SwTextNode const*, sal_Int32> const pos( m_pMergedPara
+ ? sw::MapViewToModel(*m_pMergedPara, nPosition)
+ : std::make_pair(m_pTextNode, sal_Int32(nPosition)));
+ return pos.first->GetTextAttrForCharAt(pos.second);
}
bool SwAttrIter::SeekAndChgAttrIter(TextFrameIndex const nNewPos, OutputDevice* pOut)
{
- bool bChg = m_nStartIndex && nNewPos == m_nPosition ? m_pFont->IsFntChg() : Seek( nNewPos );
+ std::pair<SwTextNode const*, sal_Int32> const pos( m_pMergedPara
+ ? sw::MapViewToModel(*m_pMergedPara, nNewPos)
+ : std::make_pair(m_pTextNode, sal_Int32(nNewPos)));
+ bool bChg = m_nStartIndex && pos.first == m_pTextNode && pos.second == m_nPosition
+ ? m_pFont->IsFntChg()
+ : Seek( nNewPos );
if ( m_pLastOut.get() != pOut )
{
m_pLastOut = pOut;
@@ -151,6 +159,14 @@ bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFo
if ( m_pRedline && m_pRedline->ExtOn() )
m_pRedline->LeaveExtend(*m_pFont, pFirstTextNode->GetIndex(), 0);
+ if (m_pTextNode != pFirstTextNode)
+ {
+ assert(m_pMergedPara);
+ m_pTextNode = m_pMergedPara->pFirstNode;
+ m_pHints = m_pTextNode->GetpSwpHints();
+ InitFontAndAttrHandler(*m_pTextNode, m_pMergedPara->mergedText, nullptr);
+ }
+
// reset font to its original state
m_aAttrHandler.Reset();
m_aAttrHandler.ResetFont( *m_pFont );
commit 61351b626cc2cc32616dd68735d6578f3719bf37
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 17:30:22 2018 +0200
sw_redlinehide: SwAttrIter::Seek()
Change-Id: Ieb884f678d6521b609714def3f42c8494dc47769
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index c44dc9eaa4d5..20f25621273a 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -65,6 +65,9 @@
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star;
+static sal_Int32 GetNextAttrImpl(SwTextNode const* pTextNode,
+ size_t nStartIndex, size_t nEndIndex, sal_Int32 nPosition);
+
void SwAttrIter::Chg( SwTextAttr const *pHt )
{
assert(pHt && m_pFont && "No attribute of font available for change");
@@ -243,18 +246,59 @@ void SwAttrIter::SeekFwd( const sal_Int32 nNewPos )
bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
{
// note: nNewPos isn't necessarily a index returned from GetNextAttr
- sw::MergedPara * pMerged(nullptr); // FIXME
- std::pair<SwTextNode const*, sal_Int32> const newPos( pMerged
- ? sw::MapViewToModel(*pMerged, nNewPos)
- : std::make_pair(m_pTextNode, nNewPos));
+ std::pair<SwTextNode const*, sal_Int32> const newPos( m_pMergedPara
+ ? sw::MapViewToModel(*m_pMergedPara, nNewPos)
+ : std::make_pair(m_pTextNode, sal_Int32(nNewPos)));
if ( m_pRedline && m_pRedline->ExtOn() )
m_pRedline->LeaveExtend(*m_pFont, newPos.first->GetIndex(), newPos.second);
+ if (m_pTextNode->GetIndex() < newPos.first->GetIndex())
+ {
+ // Skipping to a different node - first seek until the end of this node
+ // to get rid of all hint items
+ sal_Int32 nPos(m_nPosition);
+ do
+ {
+ nPos = GetNextAttrImpl(m_pTextNode, m_nStartIndex, m_nEndIndex, nPos);
+ if (nPos < m_pTextNode->Len())
+ {
+ SeekFwd(nPos);
+ }
+ }
+ while (nPos < m_pTextNode->Len());
+ if (nPos != m_pTextNode->Len())
+ {
+ SeekFwd(m_pTextNode->Len());
+ }
+ assert(m_nChgCnt == 0); // should have reset it all? there cannot be ExtOn() inside of a Delete redline, surely?
+ // Unapply current para items:
+ // the SwAttrHandler doesn't appear to be capable of *unapplying*
+ // items at all; it can only apply a previously effective item.
+ // So do this by recreating the font from scratch.
+ // Apply new para items:
+ InitFontAndAttrHandler(*newPos.first, m_pMergedPara->mergedText, nullptr);
+ // reset to next
+ m_pTextNode = newPos.first;
+ m_pHints = m_pTextNode->GetpSwpHints();
+ m_nStartIndex = 0;
+ m_nEndIndex = 0;
+ m_nPosition = 0;
+ assert(m_pRedline);
+ }
if( m_pHints )
{
- if( !nNewPos || nNewPos < m_nPosition )
+ if (!nNewPos || newPos.second < m_nPosition)
{
+ if (m_pMergedPara)
+ {
+ if (m_pTextNode != m_pMergedPara->pFirstNode)
+ {
+ m_pTextNode = m_pMergedPara->pFirstNode;
+ m_pHints = m_pTextNode->GetpSwpHints();
+ InitFontAndAttrHandler(*m_pTextNode, m_pMergedPara->mergedText, nullptr);
+ }
+ }
if( m_pRedline )
m_pRedline->Clear( nullptr );
@@ -278,14 +322,37 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
++m_nChgCnt;
}
}
- SeekFwd( nNewPos );
+ if (m_pMergedPara)
+ {
+ // iterate hint by hint: SeekFwd does not mix ends and starts,
+ // it always applies all the starts last, so it must be called once
+ // per position where hints start/end!
+ sal_Int32 nPos(m_nPosition);
+ do
+ {
+ nPos = GetNextAttrImpl(m_pTextNode, m_nStartIndex, m_nEndIndex, nPos);
+ if (nPos < newPos.second)
+ {
+ SeekFwd(nPos);
+ }
+ }
+ while (nPos < newPos.second);
+ if (nPos != newPos.second)
+ {
+ SeekFwd(newPos.second);
+ }
+ }
+ else
+ {
+ SeekFwd(newPos.second);
+ }
}
m_pFont->SetActual( SwScriptInfo::WhichFont( nNewPos, nullptr, m_pScriptInfo ) );
if( m_pRedline )
m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, newPos.first->GetIndex(), newPos.second, m_nPosition);
- m_nPosition = nNewPos;
+ m_nPosition = newPos.second;
if( m_nPropFont )
m_pFont->SetProportion( m_nPropFont );
commit a0ff894a73232ec6f5b6626f76f52fdc2fdbedbf
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 16:56:19 2018 +0200
sw_redlinehide: split font/SwAttrHandler init out of CtorInitAttrIter
... so we can call it again later, when the text node changes.
Change-Id: I4cd2ff064b829a70652bf1861bacf365be7277a2
diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx
index 5c59de630c63..e6a08f422d1b 100644
--- a/sw/source/core/text/atrhndl.hxx
+++ b/sw/source/core/text/atrhndl.hxx
@@ -115,6 +115,8 @@ public:
const SwViewShell* pShell, SwFont& rFnt,
bool bVertLayout );
+ bool IsVertLayout() const { return m_bVertLayout; }
+
// remove everything from internal stacks, keep default data
void Reset( );
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index b90d72efdeab..b59ad14a5268 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -66,6 +66,8 @@ private:
void SeekFwd( const sal_Int32 nPos );
void SetFnt( SwFont* pNew ) { m_pFont = pNew; }
+ void InitFontAndAttrHandler(SwTextNode const& rTextNode,
+ OUString const& rText, bool const* pbVertLayout);
protected:
void Chg( SwTextAttr const *pHt );
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 9d96675c8573..8b5267a8aecc 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -111,35 +111,20 @@ std::unique_ptr<sw::MergedPara> CheckParaRedlineMerge(SwTextNode & rTextNode)
} // namespace sw
-void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
- SwScriptInfo & rScriptInfo, SwTextFrame *const pFrame)
+void SwAttrIter::InitFontAndAttrHandler(SwTextNode const& rTextNode,
+ OUString const& rText,
+ bool const*const pbVertLayout)
{
- // during HTML-Import it can happen, that no layout exists
- SwRootFrame* pRootFrame = rTextNode.getIDocumentLayoutAccess().GetCurrentLayout();
- m_pViewShell = pRootFrame ? pRootFrame->GetCurrShell() : nullptr;
-
- m_pScriptInfo = &rScriptInfo;
-
- // attribute array
- m_pHints = rTextNode.GetpSwpHints();
-
// Build a font matching the default paragraph style:
SwFontAccess aFontAccess( &rTextNode.GetAnyFormatColl(), m_pViewShell );
delete m_pFont;
m_pFont = new SwFont( aFontAccess.Get()->GetFont() );
// set font to vertical if frame layout is vertical
- bool bVertLayout = false;
- bool bRTL = false;
- if ( pFrame )
+ // if it's a re-init, the vert flag never changes
+ if (pbVertLayout ? *pbVertLayout : m_aAttrHandler.IsVertLayout())
{
- if ( pFrame->IsVertical() )
- {
- bVertLayout = true;
- m_pFont->SetVertical( m_pFont->GetOrientation(), true );
- }
- bRTL = pFrame->IsRightToLeft();
- m_pMergedPara = pFrame->GetMergedPara();
+ m_pFont->SetVertical( m_pFont->GetOrientation(), true );
}
// Initialize the default attribute of the attribute handler
@@ -148,16 +133,11 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// consider them during construction of the default array, and apply
// them to the font
m_aAttrHandler.Init(aFontAccess.Get()->GetDefault(), rTextNode.GetpSwAttrSet(),
- *rTextNode.getIDocumentSettingAccess(), m_pViewShell, *m_pFont, bVertLayout );
+ *rTextNode.getIDocumentSettingAccess(), m_pViewShell, *m_pFont,
+ pbVertLayout ? *pbVertLayout : m_aAttrHandler.IsVertLayout() );
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
- // TODO must init m_pRedline before this
- // determine script changes if not already done for current paragraph
- assert(m_pScriptInfo);
- if ( m_pScriptInfo->GetInvalidityA() != COMPLETE_STRING )
- m_pScriptInfo->InitScriptInfo( rTextNode, bRTL );
-
assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
m_pFont->SetActual( SwScriptInfo::WhichFont( 0, nullptr, m_pScriptInfo ) );
@@ -186,7 +166,43 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
m_pFont->ChkMagic( m_pViewShell, nTmp );
m_pFont->GetMagic( m_aMagicNo[ nTmp ], m_aFontIdx[ nTmp ], nTmp );
}
- } while (nChg < rTextNode.GetText().getLength());
+ }
+ while (nChg < rText.getLength());
+}
+
+void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
+ SwScriptInfo & rScriptInfo, SwTextFrame *const pFrame)
+{
+ // during HTML-Import it can happen, that no layout exists
+ SwRootFrame* pRootFrame = rTextNode.getIDocumentLayoutAccess().GetCurrentLayout();
+ m_pViewShell = pRootFrame ? pRootFrame->GetCurrShell() : nullptr;
+
+ m_pScriptInfo = &rScriptInfo;
+
+ // attribute array
+ m_pHints = rTextNode.GetpSwpHints();
+
+ // set font to vertical if frame layout is vertical
+ bool bVertLayout = false;
+ bool bRTL = false;
+ if ( pFrame )
+ {
+ if ( pFrame->IsVertical() )
+ {
+ bVertLayout = true;
+ }
+ bRTL = pFrame->IsRightToLeft();
+ m_pMergedPara = pFrame->GetMergedPara();
+ }
+
+ // determine script changes if not already done for current paragraph
+ assert(m_pScriptInfo);
+ if ( m_pScriptInfo->GetInvalidityA() != COMPLETE_STRING )
+ m_pScriptInfo->InitScriptInfo( rTextNode, bRTL );
+
+ InitFontAndAttrHandler(rTextNode,
+ m_pMergedPara ? m_pMergedPara->mergedText : rTextNode.GetText(),
+ & bVertLayout);
m_nStartIndex = m_nEndIndex = m_nPosition = m_nChgCnt = 0;
m_nPropFont = 0;
commit 14b5045fd9f715cd6fd9254f2a6e633fddf94baf
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 14:47:49 2018 +0200
sw_redlinehide: this m_nCurrentIndexOffset is giving me headaches
Just use the mapping functions in GetNextAttr().
Change-Id: I4108e62ffbefbf3b0afe03b31ff97013969ea3a3
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index d16bc458269e..c44dc9eaa4d5 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -593,36 +593,39 @@ TextFrameIndex SwAttrIter::GetNextAttr() const
sal_Int32 nNext = GetNextAttrImpl(pTextNode, nStartIndex, nEndIndex, nPosition);
if( m_pRedline )
{
- // TODO refactor this so it can iterate
- std::pair<sal_Int32, SwRangeRedline const*> const redline(m_pRedline->GetNextRedln(nNext, pTextNode, nActRedline));
+ std::pair<sal_Int32, SwRangeRedline const*> const redline(
+ m_pRedline->GetNextRedln(nNext, pTextNode, nActRedline));
if (redline.second)
{
+ assert(m_pMergedPara);
if (CanSkipOverRedline(*redline.second, nStartIndex, nEndIndex))
{
if (&redline.second->End()->nNode.GetNode() != pTextNode)
{
- // FIXME when to update the offset? now or when seeking?
- const_cast<SwAttrIter*>(this)->m_nCurrentIndexOffset += pTextNode->Len() - redline.first;
- // FIXME this needs to sum up *all* prev. nodes?
- const_cast<SwAttrIter*>(this)->m_nCurrentIndexOffset = redline.second->End()->nContent.GetIndex() - pTextNode->Len();
pTextNode = redline.second->End()->nNode.GetNode().GetTextNode();
nPosition = redline.second->End()->nContent.GetIndex();
- // TODO: reset m_pRedline ... its m_pExt ...
}
else
{
nPosition = redline.second->End()->nContent.GetIndex();
- const_cast<SwAttrIter*>(this)->m_nCurrentIndexOffset += (redline.second->End()->nContent.GetIndex() - redline.first);
}
}
else
- return redline.first - m_nCurrentIndexOffset;
+ {
+ return sw::MapModelToView(*m_pMergedPara, pTextNode, redline.first);
+ }
}
else
- return redline.first - m_nCurrentIndexOffset;
+ {
+ return m_pMergedPara
+ ? sw::MapModelToView(*m_pMergedPara, pTextNode, redline.first)
+ : TextFrameIndex(redline.first);
+ }
}
else
- return nNext - m_nCurrentIndexOffset;
+ {
+ return TextFrameIndex(nNext);
+ }
}
}
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index a5c687764a28..b90d72efdeab 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -63,8 +63,6 @@ private:
/// input: the current text node
const SwTextNode* m_pTextNode;
sw::MergedPara const* m_pMergedPara;
- /// from view (text frame) index to current node index
- sal_Int32 m_nCurrentIndexOffset;
void SeekFwd( const sal_Int32 nPos );
void SetFnt( SwFont* pNew ) { m_pFont = pNew; }
@@ -87,7 +85,6 @@ protected:
, m_nPropFont(0)
, m_pTextNode(pTextNode)
, m_pMergedPara(nullptr)
- , m_nCurrentIndexOffset(0)
{
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
}
@@ -97,7 +94,6 @@ public:
SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
: m_pViewShell(nullptr), m_pFont(nullptr), m_pHints(nullptr), m_pScriptInfo(nullptr), m_pLastOut(nullptr), m_nChgCnt(0), m_pRedline(nullptr),m_nPropFont(0), m_pTextNode(&rTextNode)
, m_pMergedPara(nullptr)
- , m_nCurrentIndexOffset(0)
// TODO the clients here don't have a para-portion?
{ CtorInitAttrIter( rTextNode, rScrInf ); }
commit 7d02274f35a49e7dad2f6e53e1fb52bd418dee56
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 11:37:54 2018 +0200
sw_redlinehide: SwRedlineItr::Seek_() needs to do something
... in Hide mode, such as locate the next Delete that GetNextRedln looks
for.
Change-Id: Ie0ab35c99f34bd3a071798fd54efd12f1f82a118
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 54208ac293da..9d96675c8573 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -298,7 +298,6 @@ SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
// The return value of SwRedlineItr::Seek tells you if the current font
// has been manipulated by leaving (-1) or accessing (+1) of a section
short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew, sal_Int32 const nOld)
- //TODO use nNode to compare
{
short nRet = 0;
if( ExtOn() )
@@ -383,6 +382,36 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const n
m_nEnd = COMPLETE_STRING;
}
}
+ else if (m_eMode == Mode::Hide)
+ { // ... just iterate to update m_nAct for GetNextRedln();
+ // there is no need to care about formatting in this mode
+ if (nOld == COMPLETE_STRING) // backward?
+ {
+ m_nAct = m_nFirst;
+ }
+ for ( ; m_nAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(); ++m_nAct)
+ { // only Start matters in this mode
+ // Seeks until it finds a RL that starts at or behind the seek pos.
+ // - then update m_nStart/m_nEnd to the intersection of it with the
+ // current node (if any).
+ // The only way to skip to a different node is if there is a Delete
+ // RL, so if there is no intersection we'll never skip again.
+ // Note: here, assume that delete can't nest inside delete!
+ SwRangeRedline const*const pRedline(
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[m_nAct]);
+ SwPosition const*const pStart(pRedline->Start());
+ if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE
+ && (nNode < pStart->nNode.GetIndex()
+ || (nNode == pStart->nNode.GetIndex()
+ && nNew <= pStart->nContent.GetIndex())))
+ {
+ pRedline->CalcStartEnd(nNode, m_nStart, m_nEnd);
+ break;
+ }
+ m_nStart = COMPLETE_STRING;
+ m_nEnd = COMPLETE_STRING;
+ }
+ }
return nRet + EnterExtend(rFnt, nNode, nNew);
}
commit 993d9178a381536d45956ac9d76680ee7ee9668f
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Tue May 15 11:37:23 2018 +0200
sw_redlinehide: more work on SwRedlineItr::GetNextRedln()
Change-Id: I9f79a3f6ace1914f516e89c7ddb16835a63ddc00
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index facf24dad3eb..54208ac293da 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -441,7 +441,10 @@ void SwRedlineItr::Clear_( SwFont* pFnt )
m_Hints.clear();
}
-// TODO this must be ITERABLE pass in members as parameter
+/// Ignore mode: does nothing.
+/// Show mode: returns end of redline if currently in one, or start of next
+/// Hide mode: returns start of next redline in current node, plus its
+/// end position if it's a Delete
std::pair<sal_Int32, SwRangeRedline const*>
SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedlineTable::size_type & rAct)
{
@@ -452,35 +455,59 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
return std::make_pair(nNext, nullptr);
if (SwRedlineTable::npos == rAct)
{
- rAct = m_nFirst; // TODO???
- m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct]->CalcStartEnd(pNode->GetIndex(), nStart, nEnd);
+ rAct = m_nFirst;
}
if (rAct != m_nAct)
{
- m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct]->CalcStartEnd(pNode->GetIndex(), nStart, nEnd);
+ do
+ {
+ SwRangeRedline const*const pRedline(
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct]);
+ pRedline->CalcStartEnd(pNode->GetIndex(), nStart, nEnd);
+ if (m_eMode != Mode::Hide
+ || pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
+ {
+ break;
+ }
+ ++rAct; // Hide mode: search a Delete RL
+ if (rAct == m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size())
+ {
+ return std::make_pair(nNext, nullptr); // no Delete here
+ }
+ }
+ while (true);
}
- if (m_bOn || !nStart)
- {
+ if (m_bOn || (m_eMode == Mode::Show && nStart == 0))
+ { // in Ignore mode, the end of redlines isn't relevant, except as returned in the second in the pair!
if (nEnd < nNext)
nNext = nEnd;
}
else if (nStart <= nNext)
{
- nNext = nStart;
- if (m_eMode == Mode::Hide)
+ if (m_eMode == Mode::Show)
+ {
+ nNext = nStart;
+ }
+ else
{
- SwRangeRedline const* pRedline = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
+ assert(m_eMode == Mode::Hide);
+ SwRangeRedline const* pRedline(
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct]);
+ assert(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE); //?
if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
{
- ++rAct;
+ nNext = nStart;
+ ++rAct; // increment because we skip it
while (rAct < m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().size())
{
- SwRangeRedline *const pNext = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
+ SwRangeRedline const*const pNext =
+ m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
if (pRedline->End() < pNext->Start())
{
break; // done for now
}
- else if (pNext->Start() == pRedline->End() && pNext->GetType() == nsRedlineType_t::REDLINE_DELETE)
+ else if (pNext->Start() == pRedline->End() &&
+ pNext->GetType() == nsRedlineType_t::REDLINE_DELETE)
{
// consecutive delete - continue
pRedline = pNext;
commit 78b615836ee3fb4d997be7f62fd093be9e8103a1
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:47:08 2018 +0200
sw_redlinehide: don't need SwAttrIter::m_pFirstNode
Change-Id: Icdadd3d9daa5c0031c044004032723d7108d71ab
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 2cabf13235a2..d16bc458269e 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -144,8 +144,9 @@ bool SwAttrIter::IsSymbol(TextFrameIndex const nNewPos)
bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont )
{
+ SwTextNode const*const pFirstTextNode(m_pMergedPara ? m_pMergedPara->pFirstNode : m_pTextNode);
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend(*m_pFont, m_pFirstTextNode->GetIndex(), 0);
+ m_pRedline->LeaveExtend(*m_pFont, pFirstTextNode->GetIndex(), 0);
// reset font to its original state
m_aAttrHandler.Reset();
@@ -161,7 +162,7 @@ bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFo
{
m_pRedline->Clear( m_pFont );
if( !bParaFont )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, m_pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
else
m_pRedline->Reset();
}
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index 5bb612e79bf8..a5c687764a28 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -63,8 +63,6 @@ private:
/// input: the current text node
const SwTextNode* m_pTextNode;
sw::MergedPara const* m_pMergedPara;
- /// the 1st one, for reset
- const SwTextNode* m_pFirstTextNode;
/// from view (text frame) index to current node index
sal_Int32 m_nCurrentIndexOffset;
@@ -89,7 +87,6 @@ protected:
, m_nPropFont(0)
, m_pTextNode(pTextNode)
, m_pMergedPara(nullptr)
- , m_pFirstTextNode(pTextNode)
, m_nCurrentIndexOffset(0)
{
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
@@ -100,7 +97,6 @@ public:
SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
: m_pViewShell(nullptr), m_pFont(nullptr), m_pHints(nullptr), m_pScriptInfo(nullptr), m_pLastOut(nullptr), m_nChgCnt(0), m_pRedline(nullptr),m_nPropFont(0), m_pTextNode(&rTextNode)
, m_pMergedPara(nullptr)
- , m_pFirstTextNode(&rTextNode)
, m_nCurrentIndexOffset(0)
// TODO the clients here don't have a para-portion?
{ CtorInitAttrIter( rTextNode, rScrInf ); }
commit f0786b52ed747553b5e5793f5f43d7d487147c96
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:42:39 2018 +0200
sw_redlinehide: add MergedPara member to SwAttrIter
Change-Id: I304c333bb6aaca8933606b662743a1642c655de5
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index d30885c56643..5bb612e79bf8 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -24,6 +24,7 @@
#include <swfont.hxx>
#include "porlay.hxx"
+namespace sw { struct MergedPara; }
class OutputDevice;
class SwFont;
class SwpHints;
@@ -61,6 +62,7 @@ private:
o3tl::enumarray<SwFontScript, sal_uInt16> m_aFontIdx;
/// input: the current text node
const SwTextNode* m_pTextNode;
+ sw::MergedPara const* m_pMergedPara;
/// the 1st one, for reset
const SwTextNode* m_pFirstTextNode;
/// from view (text frame) index to current node index
@@ -86,6 +88,7 @@ protected:
, m_nPosition(0)
, m_nPropFont(0)
, m_pTextNode(pTextNode)
+ , m_pMergedPara(nullptr)
, m_pFirstTextNode(pTextNode)
, m_nCurrentIndexOffset(0)
{
@@ -96,6 +99,7 @@ public:
// Constructor, destructor
SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
: m_pViewShell(nullptr), m_pFont(nullptr), m_pHints(nullptr), m_pScriptInfo(nullptr), m_pLastOut(nullptr), m_nChgCnt(0), m_pRedline(nullptr),m_nPropFont(0), m_pTextNode(&rTextNode)
+ , m_pMergedPara(nullptr)
, m_pFirstTextNode(&rTextNode)
, m_nCurrentIndexOffset(0)
// TODO the clients here don't have a para-portion?
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 5f032c572bbc..facf24dad3eb 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -131,7 +131,6 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// set font to vertical if frame layout is vertical
bool bVertLayout = false;
bool bRTL = false;
- sw::MergedPara const* pMerged(nullptr);
if ( pFrame )
{
if ( pFrame->IsVertical() )
@@ -140,7 +139,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
m_pFont->SetVertical( m_pFont->GetOrientation(), true );
}
bRTL = pFrame->IsRightToLeft();
- pMerged = pFrame->GetMergedPara();
+ m_pMergedPara = pFrame->GetMergedPara();
}
// Initialize the default attribute of the attribute handler
@@ -198,10 +197,10 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// the node. It's not clear whether there can be more than 1 PaM in the
// Ring, and this code doesn't handle that case; neither did the old code.
const SwExtTextInput* pExtInp = pDoc->GetExtTextInput( rTextNode );
- if (!pExtInp && pMerged)
+ if (!pExtInp && m_pMergedPara)
{
SwTextNode const* pNode(&rTextNode);
- for (auto const& rExtent : pMerged->extents)
+ for (auto const& rExtent : m_pMergedPara->extents)
{
if (rExtent.pNode != pNode)
{
@@ -213,16 +212,31 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
}
}
const bool bShow = IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() );
- if (pExtInp || pMerged || bShow)
+ if (pExtInp || m_pMergedPara || bShow)
{
- const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
- if (pExtInp || pMerged || SwRedlineTable::npos != nRedlPos)
+ SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
+ if (SwRedlineTable::npos == nRedlPos && m_pMergedPara)
+ {
+ SwTextNode const* pNode(&rTextNode);
+ for (auto const& rExtent : m_pMergedPara->extents)
+ { // note: have to search because extents based only on Delete
+ if (rExtent.pNode != pNode)
+ {
+ pNode = rExtent.pNode;
+ nRedlPos = rIDRA.GetRedlinePos(*pNode, USHRT_MAX);
+ if (SwRedlineTable::npos != nRedlPos)
+ break;
+ }
+ }
+ assert(SwRedlineTable::npos != nRedlPos);
+ }
+ if (pExtInp || m_pMergedPara || SwRedlineTable::npos != nRedlPos)
{
const std::vector<ExtTextInputAttr> *pArr = nullptr;
if( pExtInp )
{
pArr = &pExtInp->GetAttrs();
- Seek( 0 );
+ Seek( TextFrameIndex(0) );
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
commit 27bc6264f7cc475a0f9428ce115b90c6eb96d2fa
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:39:32 2018 +0200
sw_redlinehide: SwRedlineItr::m_nNdIdx can be const
Change-Id: I6231e25dd1cae8360b2561051cc06fb16788398a
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index be4047049603..310fd067ca23 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -74,7 +74,8 @@ class SwRedlineItr
SwAttrHandler& m_rAttrHandler;
std::unique_ptr<SfxItemSet> m_pSet;
SwExtend *m_pExt;
- sal_uLong m_nNdIdx;
+ // note: this isn't actually used in the merged-para (Hide) case
+ sal_uLong const m_nNdIdx;
SwRedlineTable::size_type const m_nFirst;
SwRedlineTable::size_type m_nAct;
sal_Int32 m_nStart;
commit d8f6c9d9803f1b7f85fc6d253c36ff70a04e6e31
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 16:25:19 2018 +0200
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
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index a036e2d1e964..1ba4b8588d91 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -485,7 +485,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
SwAttrHandler aAttrHandler;
aAttrHandler.Init( rTextNode.GetSwAttrSet(),
*rTextNode.getIDocumentSettingAccess() );
- SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler, nRedlPos, true );
+ SwRedlineItr aRedln(rTextNode, *pFnt, aAttrHandler, nRedlPos, SwRedlineItr::Mode::Show);
}
}
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index a162577879f8..5d85adbf3c6d 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -259,7 +259,7 @@ SwTwips SwTextFrame::EmptyHeight() const
aAttrHandler.Init( GetTextNode()->GetSwAttrSet(),
*GetTextNode()->getIDocumentSettingAccess() );
SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler,
- nRedlPos, true );
+ nRedlPos, SwRedlineItr::Mode::Show);
}
}
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index ba17bf9d4241..5f032c572bbc 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -226,7 +226,12 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
- bShow, pArr, pExtInp ? pExtInp->Start() : nullptr);
+ bShow
+ ? SwRedlineItr::Mode::Show
+ : m_pMergedPara
+ ? SwRedlineItr::Mode::Hide
+ : SwRedlineItr::Mode::Ignore,
+ pArr, pExtInp ? pExtInp->Start() : nullptr);
if( m_pRedline->IsOn() )
++m_nChgCnt;
@@ -247,7 +252,8 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// If m_nAct is set to SwRedlineTable::npos (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 bShow,
+ SwAttrHandler& rAH, sal_Int32 nRed,
+ Mode const mode,
const std::vector<ExtTextInputAttr> *pArr,
SwPosition const*const pExtInputStart)
: m_rDoc( *rTextNd.GetDoc() )
@@ -256,7 +262,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
, m_nFirst( nRed )
, m_nAct( SwRedlineTable::npos )
, m_bOn( false )
- , m_bShow( bShow )
+ , m_eMode( mode )
{
if( pArr )
{
@@ -284,7 +290,8 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const n
if( ExtOn() )
return 0; // Abbreviation: if we're within an ExtendTextInputs
// 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)
{
@@ -388,7 +395,7 @@ void SwRedlineItr::ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bCh
{
OSL_ENSURE( IsOn(), "SwRedlineItr::ChangeTextAttr: Off?" );
- if (!m_bShow && !m_pExt)
+ if (m_eMode != Mode::Show && !m_pExt)
return;
if( bChg )
@@ -427,7 +434,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
sal_Int32 nStart(m_nStart);
sal_Int32 nEnd(m_nEnd);
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);
if (SwRedlineTable::npos == rAct)
{
@@ -446,7 +453,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
else if (nStart <= nNext)
{
nNext = nStart;
- if (!m_bShow)
+ if (m_eMode == Mode::Hide)
{
SwRangeRedline const* pRedline = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
@@ -494,7 +501,7 @@ bool SwRedlineItr::CheckLine(
{
// note: previously this would return true in the (!m_bShow && m_pExt)
// 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;
assert(nStartNode == nEndNode);
if( nChkEnd == nChkStart ) // empty lines look one char further
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 9cb6ad3af0d8..be4047049603 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -80,7 +80,10 @@ class SwRedlineItr
sal_Int32 m_nStart;
sal_Int32 m_nEnd;
bool m_bOn;
- bool m_bShow;
+public:
+ enum class Mode { Show, Ignore, Hide };
+private:
+ Mode const m_eMode;
void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const;
@@ -98,7 +101,8 @@ class SwRedlineItr
}
public:
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);
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
SwRedlineTable::size_type GetAct() const { return m_nAct; }
@@ -107,7 +111,7 @@ public:
void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
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;
}
void Reset() {
commit 15f74e63d9bf1ac826424cb8ec9ceb71ecca9b0f
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 14:38:08 2018 +0200
sw_redlinehide: SwRedlineItr::CheckLine()
... should just return early... but keep the changed interface.
Change-Id: I6da6f62ebd66f1017946abac60c5f20d2dbb1fc5
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index e8fb45c23b86..454a5a5116e2 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -566,8 +566,13 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
Width( nLineWidth );
SAL_WARN_IF( nLineWidth < Width(), "sw.core", "SwLineLayout::CalcLine: line is bursting" );
SetDummy( bTmpDummy );
+ std::pair<SwTextNode const*, sal_Int32> const start(
+ rInf.GetTextFrame()->MapViewToModel(rLine.GetStart()));
+ std::pair<SwTextNode const*, sal_Int32> const end(
+ rInf.GetTextFrame()->MapViewToModel(rLine.GetEnd()));
SetRedline( rLine.GetRedln() &&
- rLine.GetRedln()->CheckLine( rLine.GetStart(), rLine.GetEnd() ) );
+ rLine.GetRedln()->CheckLine(start.first->GetIndex(), start.second,
+ end.first->GetIndex(), end.second) );
}
// #i47162# - add optional parameter <_bNoFlyCntPorAndLinePor>
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index f23b19838696..ba17bf9d4241 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -488,10 +488,15 @@ bool SwRedlineItr::ChkSpecialUnderline_() const
return false;
}
-bool SwRedlineItr::CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd )
+bool SwRedlineItr::CheckLine(
+ sal_uLong const nStartNode, sal_Int32 const nChkStart,
+ sal_uLong const nEndNode, sal_Int32 nChkEnd)
{
- if (m_nFirst == SwRedlineTable::npos)
+ // note: previously this would return true in the (!m_bShow && m_pExt)
+ // case, but surely that was a bug?
+ if (m_nFirst == SwRedlineTable::npos || !m_bShow)
return false;
+ assert(nStartNode == nEndNode);
if( nChkEnd == nChkStart ) // empty lines look one char further
++nChkEnd;
sal_Int32 nOldStart = m_nStart;
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 3deeb16bd2ae..9cb6ad3af0d8 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -123,7 +123,7 @@ public:
#endif
bool ChkSpecialUnderline() const
{ return IsOn() && ChkSpecialUnderline_(); }
- bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
+ bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode, sal_Int32 nChkEnd);
bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{ return m_pExt->Leave(rFnt, nNode, nNew); }
bool ExtOn() {
commit 86aee7ae8eadd75e768f7ea75fe7c3e76482e590
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:48:12 2018 +0200
sw_redlinehide: adapt SwExtend to merged paragraph
It needs a new member to know what node it's in, plus all the methods
need a node passed in to compare.
Change-Id: Ibcc5a1fb7031fbdc048cc6716bb5b74cd4b8f0bf
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index afc88a33dfad..2cabf13235a2 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -145,7 +145,7 @@ bool SwAttrIter::IsSymbol(TextFrameIndex const nNewPos)
bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont )
{
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend( *m_pFont, 0 );
+ m_pRedline->LeaveExtend(*m_pFont, m_pFirstTextNode->GetIndex(), 0);
// reset font to its original state
m_aAttrHandler.Reset();
@@ -161,7 +161,7 @@ bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFo
{
m_pRedline->Clear( m_pFont );
if( !bParaFont )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, 0, COMPLETE_STRING);
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, m_pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
else
m_pRedline->Reset();
}
@@ -241,8 +241,14 @@ void SwAttrIter::SeekFwd( const sal_Int32 nNewPos )
bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
{
+ // note: nNewPos isn't necessarily a index returned from GetNextAttr
+ sw::MergedPara * pMerged(nullptr); // FIXME
+ std::pair<SwTextNode const*, sal_Int32> const newPos( pMerged
+ ? sw::MapViewToModel(*pMerged, nNewPos)
+ : std::make_pair(m_pTextNode, nNewPos));
+
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend( *m_pFont, nNewPos );
+ m_pRedline->LeaveExtend(*m_pFont, newPos.first->GetIndex(), newPos.second);
if( m_pHints )
{
@@ -277,7 +283,7 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
m_pFont->SetActual( SwScriptInfo::WhichFont( nNewPos, nullptr, m_pScriptInfo ) );
if( m_pRedline )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek( *m_pFont, nNewPos, m_nPosition );
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, newPos.first->GetIndex(), newPos.second, m_nPosition);
m_nPosition = nNewPos;
if( m_nPropFont )
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index cc98272947d1..2037eed2ec68 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -317,10 +317,17 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
SeekAndChgBefore( GetInfo() );
else if ( pPor->IsQuoVadisPortion() )
{
+ // A remark on QuoVadis/ErgoSum:
+ // We use the Font set for the Paragraph for these portions.
+ // Thus, we initialize:
TextFrameIndex nOffset = GetInfo().GetIdx();
SeekStartAndChg( GetInfo(), true );
if( GetRedln() && m_pCurr->HasRedline() )
- GetRedln()->Seek( *m_pFont, nOffset, 0 );
+ {
+ std::pair<SwTextNode const*, sal_Int32> const pos(
+ GetTextFrame()->MapViewToModel(nOffset));
+ GetRedln()->Seek(*m_pFont, pos.first->GetIndex(), pos.second, 0);
+ }
}
else if( pPor->InTextGrp() || pPor->InFieldGrp() || pPor->InTabGrp() )
SeekAndChg( GetInfo() );
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 4e067384f122..f23b19838696 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -266,7 +266,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
}
else
m_pExt = nullptr;
- Seek (rFnt, 0, COMPLETE_STRING);
+ Seek(rFnt, m_nNdIdx, 0, COMPLETE_STRING);
}
SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
@@ -277,7 +277,8 @@ SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
// The return value of SwRedlineItr::Seek tells you if the current font
// has been manipulated by leaving (-1) or accessing (+1) of a section
-short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
+short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew, sal_Int32 const nOld)
+ //TODO use nNode to compare
{
short nRet = 0;
if( ExtOn() )
@@ -300,10 +301,10 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
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
+ return nRet + EnterExtend(rFnt, nNode, nNew); // There's none prior to us
}
else
- return nRet + EnterExtend( rFnt, nNew ); // We stayed in the same section
+ return nRet + EnterExtend(rFnt, nNode, nNew); // We stayed in the same section
}
if (SwRedlineTable::npos == m_nAct || nOld > nNew)
m_nAct = m_nFirst;
@@ -361,7 +362,7 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
m_nEnd = COMPLETE_STRING;
}
}
- return nRet + EnterExtend( rFnt, nNew );
+ return nRet + EnterExtend(rFnt, nNode, nNew);
}
void SwRedlineItr::FillHints( std::size_t nAuthor, RedlineType_t eType )
@@ -425,7 +426,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
{
sal_Int32 nStart(m_nStart);
sal_Int32 nEnd(m_nEnd);
- nNext = NextExtend( nNext );
+ nNext = NextExtend(pNode->GetIndex(), nNext);
if (!m_bShow || SwRedlineTable::npos == m_nFirst)
return std::make_pair(nNext, nullptr);
if (SwRedlineTable::npos == rAct)
@@ -540,10 +541,12 @@ void SwExtend::ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr )
rFnt.SetGreyWave( true );
}
-short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
+short SwExtend::Enter(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{
- OSL_ENSURE( !Inside(), "SwExtend: Enter without Leave" );
OSL_ENSURE( !m_pFont, "SwExtend: Enter with Font" );
+ if (nNode != m_nNode)
+ return 0;
+ OSL_ENSURE( !Inside(), "SwExtend: Enter without Leave" );
m_nPos = nNew;
if( Inside() )
{
@@ -554,9 +557,11 @@ short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
return 0;
}
-bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
+bool SwExtend::Leave_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{
- OSL_ENSURE( Inside(), "SwExtend: Leave without Enter" );
+ OSL_ENSURE(nNode == m_nNode && Inside(), "SwExtend: Leave without Enter");
+ if (nNode != m_nNode)
+ return true;
const ExtTextInputAttr nOldAttr = m_rArr[m_nPos - m_nStart];
m_nPos = nNew;
if( Inside() )
@@ -577,9 +582,10 @@ bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
return false;
}
-sal_Int32 SwExtend::Next( sal_Int32 nNext )
+sal_Int32 SwExtend::Next(sal_uLong const nNode, sal_Int32 nNext)
{
- (void) m_nNode; // TODO use it here
+ if (nNode != m_nNode)
+ return nNext;
if (m_nPos < m_nStart)
{
if (nNext > m_nStart)
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 65f22be44f2b..3deeb16bd2ae 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -38,11 +38,14 @@ class SwExtend
{
std::unique_ptr<SwFont> m_pFont;
const std::vector<ExtTextInputAttr> &m_rArr;
- sal_uLong m_nNode;
- sal_Int32 m_nStart;
+ /// position of start of SwExtTextInput
+ sal_uLong const m_nNode;
+ sal_Int32 const m_nStart;
+ /// current position (inside)
sal_Int32 m_nPos;
- sal_Int32 m_nEnd;
- bool Leave_( SwFont& rFnt, sal_Int32 nNew );
+ /// position of end of SwExtTextInput (in same node as start)
+ sal_Int32 const m_nEnd;
+ bool Leave_(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
bool Inside() const { return (m_nPos >= m_nStart && m_nPos < m_nEnd); }
static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
public:
@@ -56,10 +59,10 @@ public:
{}
bool IsOn() const { return m_pFont != nullptr; }
void Reset() { m_pFont.reset(); m_nPos = COMPLETE_STRING; }
- bool Leave( SwFont& rFnt, sal_Int32 nNew )
- { return m_pFont && Leave_( rFnt, nNew ); }
- short Enter( SwFont& rFnt, sal_Int32 nNew );
- sal_Int32 Next( sal_Int32 nNext );
+ bool Leave(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ { return m_pFont && Leave_(rFnt, nNode, nNew); }
+ short Enter(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
+ sal_Int32 Next(sal_uLong nNode, sal_Int32 nNext);
SwFont* GetFont() { return m_pFont.get(); }
void UpdateFont(SwFont &rFont) { ActualizeFont(rFont, m_rArr[m_nPos - m_nStart]); }
};
@@ -82,14 +85,15 @@ class SwRedlineItr
void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const;
void FillHints( std::size_t nAuthor, RedlineType_t eType );
- short Seek_( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld );
+ short Seek_(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld);
// sal_Int32 GetNextRedln_( sal_Int32 nNext );
- short EnterExtend( SwFont& rFnt, sal_Int32 nNew ) {
- if (m_pExt) return m_pExt->Enter( rFnt, nNew );
+ short EnterExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ {
+ if (m_pExt) return m_pExt->Enter(rFnt, nNode, nNew);
return 0;
}
- sal_Int32 NextExtend( sal_Int32 nNext ) {
- if (m_pExt) return m_pExt->Next( nNext );
+ sal_Int32 NextExtend(sal_uLong const nNode, sal_Int32 const nNext) {
+ if (m_pExt) return m_pExt->Next(nNode, nNext);
return nNext;
}
public:
@@ -101,8 +105,9 @@ public:
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 (m_bShow || m_pExt) return Seek_( rFnt, nNew, 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);
return 0;
}
void Reset() {
@@ -119,8 +124,8 @@ public:
bool ChkSpecialUnderline() const
{ return IsOn() && ChkSpecialUnderline_(); }
bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
- bool LeaveExtend( SwFont& rFnt, sal_Int32 nNew )
- { return m_pExt->Leave(rFnt, nNew ); }
+ bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ { return m_pExt->Leave(rFnt, nNode, nNew); }
bool ExtOn() {
if (m_pExt) return m_pExt->IsOn();
return false;
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 34b353b10f80..1ccfd5fbecc0 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -1032,7 +1032,11 @@ TextFrameIndex SwTextFormatter::FormatQuoVadis(TextFrameIndex const nOffset)
FeedInf( rInf );
SeekStartAndChg( rInf, true );
if( GetRedln() && m_pCurr->HasRedline() )
- GetRedln()->Seek( *m_pFont, nOffset, 0 );
+ {
+ std::pair<SwTextNode const*, sal_Int32> const pos(
+ GetTextFrame()->MapViewToModel(nOffset));
+ GetRedln()->Seek(*m_pFont, pos.first->GetIndex(), pos.second, 0);
+ }
// A tricky special case: Flyfrms extend into the Line and are at the
// position we want to insert the Quovadis text
commit 4db6e129a0dd83a2abd0adbe78b681583f82ca7e
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:42:44 2018 +0200
itratr header
Change-Id: Ib8a0e8bd01ef6dfa4c0e9f9c00c83ba935fca2fb
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 66e44cafbf74..afc88a33dfad 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -239,7 +239,7 @@ void SwAttrIter::SeekFwd( const sal_Int32 nNewPos )
}
-bool SwAttrIter::Seek( const sal_Int32 nNewPos )
+bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
{
if ( m_pRedline && m_pRedline->ExtOn() )
m_pRedline->LeaveExtend( *m_pFont, nNewPos );
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index e244d8b8e09b..d30885c56643 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -106,7 +106,7 @@ public:
SwRedlineItr *GetRedln() { return m_pRedline; }
// The parameter returns the position of the next change before or at the
// char position.
- sal_Int32 GetNextAttr( ) const;
+ TextFrameIndex GetNextAttr() const;
/// Enables the attributes used at char pos nPos in the logical font
bool Seek(TextFrameIndex nPos);
// Creates the font at the specified position via Seek() and checks
commit 8c0f457ba7440d6279b574e5e2fd083f3fe07338
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:35:48 2018 +0200
sw_redlinehide: SwExtend needs a node index for merged para
Change-Id: I0742eea80e881f1a5f3714e283f4b913260c46ee
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 31102e1efe62..4e067384f122 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -131,6 +131,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// set font to vertical if frame layout is vertical
bool bVertLayout = false;
bool bRTL = false;
+ sw::MergedPara const* pMerged(nullptr);
if ( pFrame )
{
if ( pFrame->IsVertical() )
@@ -139,6 +140,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
m_pFont->SetVertical( m_pFont->GetOrientation(), true );
}
bRTL = pFrame->IsRightToLeft();
+ pMerged = pFrame->GetMergedPara();
}
// Initialize the default attribute of the attribute handler
@@ -192,24 +194,39 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
SwDoc* pDoc = rTextNode.GetDoc();
const IDocumentRedlineAccess& rIDRA = rTextNode.getIDocumentRedlineAccess();
+ // sw_redlinehide: this is a Ring - pExtInp is the first PaM that's inside
+ // the node. It's not clear whether there can be more than 1 PaM in the
+ // Ring, and this code doesn't handle that case; neither did the old code.
const SwExtTextInput* pExtInp = pDoc->GetExtTextInput( rTextNode );
+ if (!pExtInp && pMerged)
+ {
+ SwTextNode const* pNode(&rTextNode);
+ for (auto const& rExtent : pMerged->extents)
+ {
+ if (rExtent.pNode != pNode)
+ {
+ pNode = rExtent.pNode;
+ pExtInp = pDoc->GetExtTextInput(*pNode);
+ if (pExtInp)
+ break;
+ }
+ }
+ }
const bool bShow = IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() );
- if( pExtInp || bShow )
+ if (pExtInp || pMerged || bShow)
{
const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
- if( pExtInp || SwRedlineTable::npos != nRedlPos )
+ if (pExtInp || pMerged || SwRedlineTable::npos != nRedlPos)
{
const std::vector<ExtTextInputAttr> *pArr = nullptr;
- sal_Int32 nInputStt = 0;
if( pExtInp )
{
pArr = &pExtInp->GetAttrs();
- nInputStt = pExtInp->Start()->nContent.GetIndex();
Seek( 0 );
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
- bShow, pArr, nInputStt );
+ bShow, pArr, pExtInp ? pExtInp->Start() : nullptr);
if( m_pRedline->IsOn() )
++m_nChgCnt;
@@ -232,7 +249,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
SwAttrHandler& rAH, sal_Int32 nRed, bool bShow,
const std::vector<ExtTextInputAttr> *pArr,
- sal_Int32 nExtStart )
+ SwPosition const*const pExtInputStart)
: m_rDoc( *rTextNd.GetDoc() )
, m_rAttrHandler( rAH )
, m_nNdIdx( rTextNd.GetIndex() )
@@ -242,7 +259,11 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
, m_bShow( bShow )
{
if( pArr )
- m_pExt = new SwExtend( *pArr, nExtStart );
+ {
+ assert(pExtInputStart);
+ m_pExt = new SwExtend(*pArr, pExtInputStart->nNode.GetIndex(),
+ pExtInputStart->nContent.GetIndex());
+ }
else
m_pExt = nullptr;
Seek (rFnt, 0, COMPLETE_STRING);
@@ -558,6 +579,7 @@ bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
sal_Int32 SwExtend::Next( sal_Int32 nNext )
{
+ (void) m_nNode; // TODO use it here
if (m_nPos < m_nStart)
{
if (nNext > m_nStart)
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 2cf419046b4d..65f22be44f2b 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -38,6 +38,7 @@ class SwExtend
{
std::unique_ptr<SwFont> m_pFont;
const std::vector<ExtTextInputAttr> &m_rArr;
+ sal_uLong m_nNode;
sal_Int32 m_nStart;
sal_Int32 m_nPos;
sal_Int32 m_nEnd;
@@ -45,8 +46,10 @@ class SwExtend
bool Inside() const { return (m_nPos >= m_nStart && m_nPos < m_nEnd); }
static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
public:
- SwExtend(const std::vector<ExtTextInputAttr> &rArr, sal_Int32 const nStart)
+ SwExtend(const std::vector<ExtTextInputAttr> &rArr,
+ sal_uLong const nNode, sal_Int32 const nStart)
: m_rArr(rArr)
+ , m_nNode(nNode)
, m_nStart(nStart)
, m_nPos(COMPLETE_STRING)
, m_nEnd(m_nStart + rArr.size())
@@ -92,7 +95,7 @@ class SwRedlineItr
public:
SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH,
sal_Int32 nRedlPos, bool bShw, const std::vector<ExtTextInputAttr> *pArr = nullptr,
- sal_Int32 nExtStart = COMPLETE_STRING );
+ SwPosition const* pExtInputStart = nullptr);
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
SwRedlineTable::size_type GetAct() const { return m_nAct; }
bool IsOn() const { return m_bOn || (m_pExt && m_pExt->IsOn()); }
commit c03854754d8f6572e343e4cb7fdee425b2c21a89
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 17:35:28 2018 +0200
sw_redlinehide: SwAttrIter::GetHints only used to check if there are
hints, so replace it with something less dangerous.
Change-Id: If35cf8157e6b88ee6873789847ed9c5ceea6e37e
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index e8d80a0dd7bc..e244d8b8e09b 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -125,7 +125,7 @@ public:
// Returns the attribute for a position
SwTextAttr *GetAttr(TextFrameIndex nPos) const;
- const SwpHints *GetHints() const { return m_pHints; }
+ bool HaveHints() const { return m_pHints != nullptr; }
SwFont *GetFnt() { return m_pFont; }
const SwFont *GetFnt() const { return m_pFont; }
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 002eaf932fb4..63305a185566 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -322,7 +322,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
if( pDel )
{
m_pCurr->SetNext( nullptr );
- if( GetHints() && bNoteFollow )
+ if (HaveHints() && bNoteFollow)
{
GetInfo().GetParaPortion()->SetFollowField( pDel->IsRest() ||
lcl_NeedsFieldRest( m_pCurr ) );
@@ -367,7 +367,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
{
m_pCurr->SetRealHeight( 1 );
}
- if( GetHints() )
+ if (HaveHints())
m_pFrame->RemoveFootnote( nEnd );
}
commit 05ce7078c9f8da62049de0b15a6acc9000226c1e
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 12:47:16 2018 +0200
itratr: GetNextAttr return TextFrameIndex
Change-Id: I2b519f5379815abc943e05a79db609b3e93f82fc
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index c1d86c33797f..66e44cafbf74 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -573,7 +573,7 @@ static sal_Int32 GetNextAttrImpl(SwTextNode const*const pTextNode,
return nNext;
}
-sal_Int32 SwAttrIter::GetNextAttr() const
+TextFrameIndex SwAttrIter::GetNextAttr() const
{
size_t nStartIndex(m_nStartIndex);
size_t nEndIndex(m_nEndIndex);
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index bdc677198675..e8d80a0dd7bc 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -108,7 +108,7 @@ public:
// char position.
sal_Int32 GetNextAttr( ) const;
/// Enables the attributes used at char pos nPos in the logical font
- bool Seek( const sal_Int32 nPos );
+ bool Seek(TextFrameIndex nPos);
// Creates the font at the specified position via Seek() and checks
// if it's a symbol font.
bool IsSymbol(TextFrameIndex nPos);
commit bd7794c78602b49f1086950edfd5e0b47d9d9182
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:40:21 2018 +0200
sw_redlinehide: trivial conversions in objectpositioning/
Change-Id: Ice9c49596d478bd02728827dbd0dc2c77d7a13db
diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
index 4144f8241154..43070b3547f1 100644
--- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
@@ -223,7 +223,7 @@ void SwToContentAnchoredObjectPosition::CalcPosition()
// #i22341# - get top of line, in which the anchor character is.
mnToCharTopOfLine = GetAnchoredObj().GetLastTopOfLine();
pOrientFrame = &(const_cast<SwTextFrame&>(rAnchorTextFrame).GetFrameAtOfst(
- rAnch.GetContentAnchor()->nContent.GetIndex() ) );
+ rAnchorTextFrame.MapModelToViewPos(*rAnch.GetContentAnchor())));
mpToCharOrientFrame = pOrientFrame;
}
}
commit 935b62f081911e1730d0705bdc3af11e8fc46802
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:39:59 2018 +0200
sw_redlinehide: trivial conversions in trvlfrm.cxx
Change-Id: I812ba7a03b9bd25134dab2e85fcead1c7bed617a
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 1586d7e5753d..d4c1e5c002c9 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1013,10 +1013,9 @@ sal_uInt16 SwRootFrame::SetCurrPage( SwCursor* pToSet, sal_uInt16 nPageNum )
pContent = pContent->GetNextContentFrame();
if ( pContent )
{
- SwContentNode* pCNd = const_cast<SwContentNode*>(pContent->GetNode());
- pToSet->GetPoint()->nNode = *pCNd;
- pCNd->MakeStartIndex( &pToSet->GetPoint()->nContent );
- pToSet->GetPoint()->nContent = static_cast<const SwTextFrame*>(pContent)->GetOfst();
+ assert(pContent->IsTextFrame());
+ SwTextFrame const*const pFrame(static_cast<const SwTextFrame*>(pContent));
+ *pToSet->GetPoint() = pFrame->MapViewToModelPos(pFrame->GetOfst());
SwShellCursor* pSCursor = dynamic_cast<SwShellCursor*>(pToSet);
if( pSCursor )
@@ -1110,15 +1109,14 @@ bool GetFrameInPage( const SwContentFrame *pCnt, SwWhichPage fnWhichPage,
}
}
- SwContentNode *pCNd = const_cast<SwContentNode*>(pCnt->GetNode());
- pPam->GetPoint()->nNode = *pCNd;
- sal_Int32 nIdx;
- if( fnPosPage == GetFirstSub )
- nIdx = static_cast<const SwTextFrame*>(pCnt)->GetOfst();
- else
- nIdx = pCnt->GetFollow() ?
- static_cast<const SwTextFrame*>(pCnt)->GetFollow()->GetOfst()-1 : pCNd->Len();
- pPam->GetPoint()->nContent.Assign( pCNd, nIdx );
+ assert(pCnt->IsTextFrame());
+ SwTextFrame const*const pFrame(static_cast<const SwTextFrame*>(pCnt));
+ TextFrameIndex const nIdx((fnPosPage == GetFirstSub)
+ ? pFrame->GetOfst()
+ : (pFrame->GetFollow())
+ ? pFrame->GetFollow()->GetOfst() - TextFrameIndex(1)
+ : TextFrameIndex(pFrame->GetText().getLength()));
+ *pPam->GetPoint() = pFrame->MapViewToModelPos(nIdx);
return true;
}
}
commit 8d767d8b96da650776768fc3b0baa837a10b6dae
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:39:09 2018 +0200
sw_redlinehide: trivial conversions in softpagebreak.cxx
Still a bit TODO here wrt. finding the frame from every node...
Change-Id: Icff33d2fae3afee77c4329db0938b444f0e47537
diff --git a/sw/source/core/layout/softpagebreak.cxx b/sw/source/core/layout/softpagebreak.cxx
index 051364d935e4..109730e8cfa0 100644
--- a/sw/source/core/layout/softpagebreak.cxx
+++ b/sw/source/core/layout/softpagebreak.cxx
@@ -79,7 +79,11 @@ void SwTextNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
if( pFirst2 == pFrame )
{ // Here we are: a first content inside a cell
// inside the splitted row => soft page break
- rBreak.insert( pFrame->GetOfst() );
+ auto const pos(pFrame->MapViewToModel(pFrame->GetOfst()));
+ if (pos.first == this)
+ {
+ rBreak.insert(pos.second);
+ }
break;
}
pCell = pCell->GetNext();
@@ -88,7 +92,14 @@ void SwTextNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
}
else // No soft page break if there's a "hard" page break attribute
if( pFirst2 == pFrame && !pFrame->IsPageBreak( true ) )
- rBreak.insert( pFrame->GetOfst() );
+ {
+ auto const pos(pFrame->MapViewToModel(pFrame->GetOfst()));
+ if (pos.first == this)
+ { // in the !Show case, we have to iterate over the merged
+ // SwTextFrame for every node
+ rBreak.insert(pos.second);
+ }
+ }
}
}
}
commit 3012f16fb7977a6afa4a0f4343ca68ad9cb7c579
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:38:03 2018 +0200
sw_redlinehide: trivial conversions in layout/
Change-Id: I5ce4590af52b3bfc08f89915999e86f4973fa9e3
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index aaf96027e7aa..0a4292638342 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -572,7 +572,7 @@ void SwAnchoredDrawObject::InvalidateObjPos()
(GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) )
{
SwTextFrame* pAnchorTextFrame( static_cast<SwTextFrame*>(AnchorFrame()) );
- if (pAnchorTextFrame->CalcFlyPos(&GetFrameFormat()) != COMPLETE_STRING)
+ if (pAnchorTextFrame->CalcFlyPos(&GetFrameFormat()) != TextFrameIndex(COMPLETE_STRING))
{
AnchorFrame()->Prepare( PREP_FLY_ATTR_CHG, &GetFrameFormat() );
}
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index 0145389eab9e..5958f29085bc 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -545,7 +545,7 @@ bool SwAnchoredObject::HasClearedEnvironment() const
const SwTextFrame* pTmpTextFrame = static_cast<const SwTextFrame*>(pTmpFrame);
if ( pTmpTextFrame->IsUndersized() ||
( pTmpTextFrame->GetFollow() &&
- pTmpTextFrame->GetFollow()->GetOfst() == 0 ) )
+ pTmpTextFrame->GetFollow()->GetOfst() == TextFrameIndex(0)))
{
bHasClearedEnvironment = true;
}
@@ -716,8 +716,9 @@ SwTextFrame* SwAnchoredObject::FindAnchorCharFrame()
if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) ||
(rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR))
{
- pAnchorCharFrame = &(static_cast<SwTextFrame*>(AnchorFrame())->
- GetFrameAtOfst( rAnch.GetContentAnchor()->nContent.GetIndex() ));
+ SwTextFrame *const pFrame(static_cast<SwTextFrame*>(AnchorFrame()));
+ TextFrameIndex const nOffset(pFrame->MapModelToViewPos(*rAnch.GetContentAnchor()));
+ pAnchorCharFrame = &pFrame->GetFrameAtOfst(nOffset);
}
}
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 41f4e2a72f82..5a3e5b73b837 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -1403,7 +1403,8 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
const SwTwips nHDiff = nOldH - aRectFnSet.GetHeight(getFrameArea());
const bool bNoPrepAdjustFrame =
nHDiff > 0 && IsInTab() && GetFollow() &&
- ( 1 == static_cast<SwTextFrame*>(GetFollow())->GetLineCount( COMPLETE_STRING ) || aRectFnSet.GetWidth(static_cast<SwTextFrame*>(GetFollow())->getFrameArea()) < 0 ) &&
+ (1 == static_cast<SwTextFrame*>(GetFollow())->GetLineCount(TextFrameIndex(COMPLETE_STRING))
+ || aRectFnSet.GetWidth(static_cast<SwTextFrame*>(GetFollow())->getFrameArea()) < 0) &&
GetFollow()->CalcAddLowerSpaceAsLastInTableCell() == nHDiff;
if ( !bNoPrepAdjustFrame )
{
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 1c5ebadcdca1..8fdbcf9c0efc 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1088,10 +1088,10 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
if( LONG_MAX != nNewY )
{
aVert.SetVertOrient( text::VertOrientation::NONE );
- sal_Int32 nOfs =
- pFormat->GetAnchor().GetContentAnchor()->nContent.GetIndex();
- OSL_ENSURE( GetAnchorFrame()->IsTextFrame(), "TextFrame expected" );
+ assert(GetAnchorFrame()->IsTextFrame());
pAutoFrame = static_cast<const SwTextFrame*>(GetAnchorFrame());
+ TextFrameIndex const nOfs(pAutoFrame->MapModelToViewPos(
+ *pFormat->GetAnchor().GetContentAnchor()));
while( pAutoFrame->GetFollow() &&
pAutoFrame->GetFollow()->GetOfst() <= nOfs )
{
@@ -1144,10 +1144,10 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
{
if( !pAutoFrame )
{
- sal_Int32 nOfs = pFormat->GetAnchor().GetContentAnchor()
- ->nContent.GetIndex();
- OSL_ENSURE( GetAnchorFrame()->IsTextFrame(), "TextFrame expected");
+ assert(GetAnchorFrame()->IsTextFrame());
pAutoFrame = static_cast<const SwTextFrame*>(GetAnchorFrame());
+ TextFrameIndex const nOfs(pAutoFrame->MapModelToViewPos(
+ *pFormat->GetAnchor().GetContentAnchor()));
while( pAutoFrame->GetFollow() &&
pAutoFrame->GetFollow()->GetOfst() <= nOfs )
pAutoFrame = pAutoFrame->GetFollow();
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index 954b77913b67..1af4476d4946 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -272,7 +272,7 @@ bool SwObjectFormatterTextFrame::DoFormatObj( SwAnchoredObject& _rAnchoredObj,
// objects under the condition, that its follow contains all its text.
else if ( !mrAnchorTextFrame.IsFollow() &&
mrAnchorTextFrame.GetFollow() &&
- mrAnchorTextFrame.GetFollow()->GetOfst() == 0 )
+ mrAnchorTextFrame.GetFollow()->GetOfst() == TextFrameIndex(0))
{
SwLayouter::RemoveMovedFwdFrame(
*(mrAnchorTextFrame.FindPageFrame()->GetFormat()->GetDoc()),
@@ -440,7 +440,7 @@ bool SwObjectFormatterTextFrame::DoFormatObjs()
// objects under the condition, that its follow contains all its text.
else if ( !mrAnchorTextFrame.IsFollow() &&
mrAnchorTextFrame.GetFollow() &&
- mrAnchorTextFrame.GetFollow()->GetOfst() == 0 )
+ mrAnchorTextFrame.GetFollow()->GetOfst() == TextFrameIndex(0))
{
SwLayouter::RemoveMovedFwdFrame(
*(mrAnchorTextFrame.FindPageFrame()->GetFormat()->GetDoc()),
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 96612798d990..90cc289b2b21 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -5461,7 +5461,7 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const SwRowFrame& rSourceLine )
// would have no follow and thus would add this space.
if ( pTmp->IsTextFrame() &&
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pTmp))
- ->GetLineCount( COMPLETE_STRING ) == 1 )
+ ->GetLineCount(TextFrameIndex(COMPLETE_STRING)) == 1)
{
nTmpHeight += SwFlowFrame::CastFlowFrame(pTmp)
->CalcAddLowerSpaceAsLastInTableCell();
commit ef6fd700a9440b69373f94b1bd40e150519c6c68
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:36:39 2018 +0200
sw_redlinehide: convert SwTextIter::TruncLines() to MergedAttrIter
Change-Id: I84d405df29139361dc521b490a50c16c95d10efa
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index d90186c05c1d..002eaf932fb4 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -342,16 +342,16 @@ void SwTextIter::TruncLines( bool bNoteFollow )
pLine = pLine->GetNext();
}
- SwpHints* pTmpHints = GetTextFrame()->GetTextNode()->GetpSwpHints();
-
// examine hints in range nEnd - (nEnd + nRangeChar)
- for( size_t i = 0; i < pTmpHints->Count(); ++i )
+ SwTextNode const* pNode(nullptr);
+ sw::MergedAttrIter iter(*GetTextFrame());
+ for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
{
- const SwTextAttr* pHt = pTmpHints->Get( i );
if( RES_TXTATR_FLYCNT == pHt->Which() )
{
- // check, if hint is in our range
- const sal_Int32 nTmpPos = pHt->GetStart();
+ // check if hint is in our range
+ TextFrameIndex const nTmpPos(
+ GetTextFrame()->MapModelToView(pNode, pHt->GetStart()));
if ( nEnd <= nTmpPos && nTmpPos < nRangeEnd )
pFollow->InvalidateRange_(
SwCharRange( nTmpPos, nTmpPos ) );
commit 09aaf642ae9fa0f4b4e7a9b66d4dbd937744c836
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:30:32 2018 +0200
sw_redlinehide: trivial conversions in itrtxt.cxx
Change-Id: Ia61fbdff0aa87669e643fa7d3d3fe08e23becd74
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index c842251e73ee..d90186c05c1d 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -206,7 +206,7 @@ const SwLineLayout *SwTextCursor::CharCursorToLine(TextFrameIndex const nPositio
bRightMargin = false;
bool bPrevious = bRightMargin && m_pCurr->GetLen() && GetPrev() &&
GetPrev()->GetLen();
- if( bPrevious && nPosition && CH_BREAK == GetInfo().GetChar( nPosition-1 ) )
+ if (bPrevious && nPosition && CH_BREAK == GetInfo().GetChar(nPosition - TextFrameIndex(1)))
bPrevious = false;
return bPrevious ? PrevLine() : m_pCurr;
}
@@ -317,7 +317,7 @@ static bool lcl_NeedsFieldRest( const SwLineLayout* pCurr )
void SwTextIter::TruncLines( bool bNoteFollow )
{
SwLineLayout *pDel = m_pCurr->GetNext();
- const sal_Int32 nEnd = m_nStart + m_pCurr->GetLen();
+ TextFrameIndex const nEnd = m_nStart + m_pCurr->GetLen();
if( pDel )
{
@@ -332,7 +332,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
if ( pFollow && ! pFollow->IsLocked() &&
nEnd == pFollow->GetOfst() )
{
- sal_Int32 nRangeEnd = nEnd;
+ TextFrameIndex nRangeEnd = nEnd;
SwLineLayout* pLine = pDel;
// determine range to be searched for flys anchored as characters
@@ -363,8 +363,10 @@ void SwTextIter::TruncLines( bool bNoteFollow )
}
if( m_pCurr->IsDummy() &&
!m_pCurr->GetLen() &&
- m_nStart < GetTextFrame()->GetText().getLength() )
+ m_nStart < TextFrameIndex(GetTextFrame()->GetText().getLength()))
+ {
m_pCurr->SetRealHeight( 1 );
+ }
if( GetHints() )
m_pFrame->RemoveFootnote( nEnd );
}
commit cde20643a8196118fadab015e9191b482b98bef9
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:24:01 2018 +0200
sw_redlinehide: trivial conversions in xmldump.cxx
Change-Id: I37015a42cc1efdc324ccf7ac92423d9dbfb50be1
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 484f52405dd3..0f951cd6f033 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -31,7 +31,7 @@ class XmlPortionDumper:public SwPortionHandler
{
private:
xmlTextWriterPtr writer;
- sal_Int32 ofs;
+ TextFrameIndex ofs;
static const char* getTypeName( sal_uInt16 nType )
{
@@ -115,7 +115,7 @@ class XmlPortionDumper:public SwPortionHandler
@param rText
text which is painted on-screen
*/
- virtual void Text( sal_Int32 nLength,
+ virtual void Text( TextFrameIndex nLength,
sal_uInt16 nType,
sal_Int32 nHeight,
sal_Int32 nWidth) override
@@ -146,7 +146,7 @@ class XmlPortionDumper:public SwPortionHandler
@param nHeight
font size of the painted text
*/
- virtual void Special( sal_Int32 nLength,
+ virtual void Special( TextFrameIndex nLength,
const OUString & rText,
sal_uInt16 nType,
sal_Int32 nHeight,
@@ -191,7 +191,7 @@ class XmlPortionDumper:public SwPortionHandler
* @param nLength
* number of 'model string' characters to be skipped
*/
- virtual void Skip( sal_Int32 nLength ) override
+ virtual void Skip( TextFrameIndex nLength ) override
{
xmlTextWriterStartElement( writer, BAD_CAST( "Skip" ) );
xmlTextWriterWriteFormatAttribute( writer,
commit a5ee43881dc0a6dbc28fa2fcd49725dfe87d3fd5
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:17:57 2018 +0200
sw_redlinehide: trivial conversions in itrpaint.cxx
Change-Id: I12cdc805c3e07840b5b914397026a48a589785ea
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 47769b372ef8..cc98272947d1 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -317,7 +317,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
SeekAndChgBefore( GetInfo() );
else if ( pPor->IsQuoVadisPortion() )
{
- sal_Int32 nOffset = GetInfo().GetIdx();
+ TextFrameIndex nOffset = GetInfo().GetIdx();
SeekStartAndChg( GetInfo(), true );
if( GetRedln() && m_pCurr->HasRedline() )
GetRedln()->Seek( *m_pFont, nOffset, 0 );
@@ -428,7 +428,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
if( !GetNextLine() &&
GetInfo().GetVsh() && !GetInfo().GetVsh()->IsPreview() &&
GetInfo().GetOpt().IsParagraph() && !GetTextFrame()->GetFollow() &&
- GetInfo().GetIdx() >= GetInfo().GetText().getLength() )
+ GetInfo().GetIdx() >= TextFrameIndex(GetInfo().GetText().getLength()))
{
const SwTmpEndPortion aEnd( *pEndTempl );
GetFnt()->ChgPhysFnt( GetInfo().GetVsh(), *pOut );
@@ -460,7 +460,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
// GetInfo().Y() must be current baseline
SwTwips nDiff = GetInfo().Y() + nTmpHeight - nTmpAscent - GetTextFrame()->getFrameArea().Bottom();
if( ( nDiff > 0 &&
- ( GetEnd() < GetInfo().GetText().getLength() ||
+ (GetEnd() < TextFrameIndex(GetInfo().GetText().getLength()) ||
( nDiff > nTmpHeight/2 && GetPrevLine() ) ) ) ||
(nDiff >= 0 && bNextUndersized) )
@@ -490,7 +490,8 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
return;
}
// Reuse calculated underline font as much as possible.
- if ( GetInfo().GetUnderFnt() && GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + 1 )
+ if (GetInfo().GetUnderFnt() &&
+ GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + TextFrameIndex(1))
{
SwFont &rFont = GetInfo().GetUnderFnt()->GetFont();
const Color aColor = GetUnderColor( GetInfo().GetFont() );
@@ -536,47 +537,47 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
}
}
- const sal_Int32 nIndx = GetInfo().GetIdx();
- long nUnderEnd = 0;
+ const TextFrameIndex nIndx = GetInfo().GetIdx();
+ TextFrameIndex nUnderEnd(0);
const size_t nCnt = aUnderMulti.GetRangeCount();
// find the underline range the current portion is contained in
for( size_t i = 0; i < nCnt; ++i )
{
const Range& rRange = aUnderMulti.GetRange( i );
- if( nUnderEnd == rRange.Min() )
- nUnderEnd = rRange.Max();
- else if( nIndx >= rRange.Min() )
+ if (nUnderEnd == TextFrameIndex(rRange.Min()))
+ nUnderEnd = TextFrameIndex(rRange.Max());
+ else if (nIndx >= TextFrameIndex(rRange.Min()))
{
- nUnderEnd = rRange.Max();
+ nUnderEnd = TextFrameIndex(rRange.Max());
}
else
break;
}
if ( GetEnd() && GetEnd() <= nUnderEnd )
- nUnderEnd = GetEnd() - 1;
+ nUnderEnd = GetEnd() - TextFrameIndex(1);
// calculate the new common underline font
SwFont* pUnderlineFnt = nullptr;
Point aCommonBaseLine;
// check, if underlining is not isolated
- if ( nIndx + GetInfo().GetLen() < nUnderEnd + 1 )
+ if (nIndx + GetInfo().GetLen() < nUnderEnd + TextFrameIndex(1))
{
// here starts the algorithm for calculating the underline font
SwScriptInfo& rScriptInfo = GetInfo().GetParaPortion()->GetScriptInfo();
SwAttrIter aIter( *GetInfo().GetTextFrame()->GetTextNode(),
rScriptInfo );
- sal_Int32 nTmpIdx = nIndx;
+ TextFrameIndex nTmpIdx = nIndx;
sal_uLong nSumWidth = 0;
sal_uLong nSumHeight = 0;
sal_uLong nBold = 0;
sal_uInt16 nMaxBaseLineOfst = 0;
int nNumberOfPortions = 0;
- while( sal::static_int_cast<long>(nTmpIdx) <= nUnderEnd && pPor )
+ while (nTmpIdx <= nUnderEnd && pPor)
{
if ( pPor->IsFlyPortion() || pPor->IsFlyCntPortion() ||
pPor->IsBreakPortion() || pPor->IsMarginPortion() ||
commit c69cdf4fc3ae1d1062603c5a8761dd73475f881c
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 16:46:46 2018 +0200
sw_redlinehide: trivial conversions in itrform2.cxx
Change-Id: I83c0dd85f2f6c68edb7a48928db68fb4e84e5387
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index c776d63ef553..260cf6705154 100755
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -68,10 +68,10 @@ namespace {
//! Calculates and sets optimal repaint offset for the current line
long lcl_CalcOptRepaint( SwTextFormatter &rThis,
SwLineLayout const &rCurr,
- const sal_Int32 nOldLineEnd,
+ TextFrameIndex nOldLineEnd,
const std::vector<long> &rFlyStarts );
//! Determine if we need to build hidden portions
- bool lcl_BuildHiddenPortion( const SwTextSizeInfo& rInf, sal_Int32 &rPos );
+ bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex &rPos);
// Check whether the two font has the same border
bool lcl_HasSameBorder(const SwFont& rFirst, const SwFont& rSecond);
@@ -95,15 +95,15 @@ void SwTextFormatter::CtorInitTextFormatter( SwTextFrame *pNewFrame, SwTextForma
bTruncLines = false;
nCntEndHyph = 0;
nCntMidHyph = 0;
- nLeftScanIdx = COMPLETE_STRING;
- nRightScanIdx = 0;
+ nLeftScanIdx = TextFrameIndex(COMPLETE_STRING);
+ nRightScanIdx = TextFrameIndex(0);
m_nHintEndIndex = 0;
m_pFirstOfBorderMerge = nullptr;
- if( m_nStart > GetInfo().GetText().getLength() )
+ if (m_nStart > TextFrameIndex(GetInfo().GetText().getLength()))
{
OSL_ENSURE( false, "+SwTextFormatter::CTOR: bad offset" );
- m_nStart = GetInfo().GetText().getLength();
+ m_nStart = TextFrameIndex(GetInfo().GetText().getLength());
}
}
@@ -159,8 +159,8 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo &rInf )
// line again.
// Can be seen in 8081.sdw, if you enter text in the first line
- const sal_Int32 nSoftHyphPos = rInf.GetSoftHyphPos();
- const sal_Int32 nUnderScorePos = rInf.GetUnderScorePos();
+ TextFrameIndex const nSoftHyphPos = rInf.GetSoftHyphPos();
+ TextFrameIndex const nUnderScorePos = rInf.GetUnderScorePos();
// Save flys and set to 0, or else segmentation fault
// Not ClearFly(rInf) !
@@ -398,8 +398,8 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
while( pPor && !rInf.IsStop() )
{
- OSL_ENSURE( rInf.GetLen() < COMPLETE_STRING &&
- rInf.GetIdx() <= rInf.GetText().getLength(),
+ OSL_ENSURE(rInf.GetLen() < TextFrameIndex(COMPLETE_STRING) &&
+ rInf.GetIdx() <= TextFrameIndex(rInf.GetText().getLength()),
"SwTextFormatter::BuildPortions: bad length in info" );
// We have to check the script for fields in order to set the
@@ -435,7 +435,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
else
{
const OUString& rText = rInf.GetText();
- sal_Int32 nIdx = rInf.GetIdx();
+ sal_Int32 nIdx = sal_Int32(rInf.GetIdx());
bAllowBehind = nIdx < rText.getLength() && rCC.isLetterNumeric(rText, nIdx);
}
@@ -462,10 +462,10 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
}
else if ( rInf.GetIdx() )
{
- bAllowBefore = rCC.isLetterNumeric( rInf.GetText(), rInf.GetIdx() - 1 );
+ bAllowBefore = rCC.isLetterNumeric(rInf.GetText(), sal_Int32(rInf.GetIdx()) - 1);
// Note: ScriptType returns values in [1,4]
if ( bAllowBefore )
- nLstActual = SwFontScript(m_pScriptInfo->ScriptType( rInf.GetIdx() - 1 ) - 1);
+ nLstActual = SwFontScript(m_pScriptInfo->ScriptType(rInf.GetIdx() - TextFrameIndex(1)) - 1);
}
nLstHeight /= 5;
@@ -758,7 +758,7 @@ void SwTextFormatter::CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor )
// i#89179
// tab portion representing the list tab of a list label gets the
// same height and ascent as the corresponding number portion
- else if ( pPor->InTabGrp() && pPor->GetLen() == 0 &&
+ else if ( pPor->InTabGrp() && pPor->GetLen() == TextFrameIndex(0) &&
rInf.GetLast() && rInf.GetLast()->InNumberGrp() &&
static_cast<const SwNumberPortion*>(rInf.GetLast())->HasFont() )
{
@@ -886,17 +886,16 @@ SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo &rInf ) const
// Only at the End!
// If pCurr does not have a width, it can however already have content.
// E.g. for non-displayable characters
- if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FIELDSTART)
+ auto const ch(rInf.GetText()[sal_Int32(rInf.GetIdx())]);
+ if (ch == CH_TXT_ATR_FIELDSTART)
pPor = new SwFieldMarkPortion();
- else if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND)
+ else if (ch == CH_TXT_ATR_FIELDEND)
pPor = new SwFieldMarkPortion();
- else if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT)
+ else if (ch == CH_TXT_ATR_FORMELEMENT)
{
- SwTextNode *pNd = rInf.GetTextFrame()->GetTextNode();
- const SwDoc *doc = pNd->GetDoc();
- SwIndex aIndex(pNd, rInf.GetIdx());
- SwPosition aPosition(*pNd, aIndex);
- sw::mark::IFieldmark *pBM = doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
+ SwTextFrame const*const pFrame(rInf.GetTextFrame());
+ SwPosition aPosition(pFrame->MapViewToModelPos(rInf.GetIdx()));
+ sw::mark::IFieldmark *pBM = pFrame->GetDoc().getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
OSL_ENSURE(pBM != nullptr, "Where is my form field bookmark???");
if (pBM != nullptr)
{
@@ -947,8 +946,8 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
SwTextPortion *pPor = WhichTextPor( rInf );
// until next attribute change:
- const sal_Int32 nNextAttr = GetNextAttr();
- sal_Int32 nNextChg = std::min( nNextAttr, rInf.GetText().getLength() );
+ const TextFrameIndex nNextAttr = GetNextAttr();
+ TextFrameIndex nNextChg = std::min(nNextAttr, TextFrameIndex(rInf.GetText().getLength()));
// end of script type:
const sal_Int32 nNextScript = m_pScriptInfo->NextScriptChg( rInf.GetIdx() );
@@ -971,7 +970,7 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
// It follows that a line with a lot of blanks is processed incorrectly.
// Therefore we increase from factor 2 to 8 (due to negative kerning).
- pPor->SetLen(1);
+ pPor->SetLen(TextFrameIndex(1));
CalcAscent( rInf, pPor );
const SwFont* pTmpFnt = rInf.GetFont();
@@ -979,9 +978,9 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
sal_Int32( pPor->GetAscent() ) ) / 8;
if ( !nExpect )
nExpect = 1;
- nExpect = rInf.GetIdx() + (rInf.GetLineWidth() / nExpect);
- if( nExpect > rInf.GetIdx() && nNextChg > nExpect )
- nNextChg = std::min( nExpect, rInf.GetText().getLength() );
+ nExpect = sal_Int32(rInf.GetIdx()) + (rInf.GetLineWidth() / nExpect);
+ if (TextFrameIndex(nExpect) > rInf.GetIdx() && nNextChg > TextFrameIndex(nExpect))
+ nNextChg = TextFrameIndex(std::min(nExpect, rInf.GetText().getLength()));
// we keep an invariant during method calls:
// there are no portion ending characters like hard spaces
@@ -1231,7 +1230,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
// Check for Hidden Portion:
if ( !pPor )
{
- sal_Int32 nEnd = rInf.GetIdx();
+ TextFrameIndex nEnd = rInf.GetIdx();
if ( ::lcl_BuildHiddenPortion( rInf, nEnd ) )
pPor = new SwHiddenTextPortion( nEnd - rInf.GetIdx() );
}
@@ -1245,7 +1244,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
{
// We open a multiportion part, if we enter a multi-line part
// of the paragraph.
- sal_Int32 nEnd = rInf.GetIdx();
+ TextFrameIndex nEnd = rInf.GetIdx();
SwMultiCreator* pCreate = rInf.GetMultiCreator( nEnd, pMulti );
if( pCreate )
{
@@ -1257,7 +1256,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
{
pTmp = new SwRubyPortion( *pCreate, *rInf.GetFont(),
*GetTextFrame()->GetTextNode()->getIDocumentSettingAccess(),
- nEnd, 0, rInf );
+ nEnd, TextFrameIndex(0), rInf );
}
else if( SwMultiCreatorId::Rotate == pCreate->nId )
pTmp = new SwRotatedPortion( *pCreate, nEnd,
@@ -1287,7 +1286,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
}
else
{
- if( rInf.GetIdx() >= rInf.GetText().getLength() )
+ if (rInf.GetIdx() >= TextFrameIndex(rInf.GetText().getLength()))
{
rInf.SetFull(true);
CalcFlyWidth( rInf );
@@ -1370,7 +1369,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
// if a portion is created despite there being a pending RestPortion,
// then it is a field which has been split (e.g. because it contains a Tab)
if( pPor && rInf.GetRest() )
- pPor->SetLen( 0 );
+ pPor->SetLen(TextFrameIndex(0));
// robust:
if( !pPor || rInf.IsStop() )
@@ -1409,9 +1408,10 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
if ( 0 != nDir )
{
delete pPor;
- pPor = new SwRotatedPortion( rInf.GetIdx() + 1, 900 == nDir ?
- DIR_BOTTOM2TOP :
- DIR_TOP2BOTTOM );
+ pPor = new SwRotatedPortion(rInf.GetIdx() + TextFrameIndex(1),
+ 900 == nDir
+ ? DIR_BOTTOM2TOP
+ : DIR_TOP2BOTTOM );
}
}
}
@@ -1425,9 +1425,9 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
if ( 0 != nDir )
{
delete pPor;
- pPor = new SwRotatedPortion( 0, 900 == nDir ?
- DIR_BOTTOM2TOP :
- DIR_TOP2BOTTOM );
+ pPor = new SwRotatedPortion(TextFrameIndex(0), 900 == nDir
+ ? DIR_BOTTOM2TOP
+ : DIR_TOP2BOTTOM );
rInf.SetNumDone( false );
rInf.SetFootnoteDone( false );
@@ -1470,8 +1470,8 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
// For the formatting routines, we set pOut to the reference device.
SwHookOut aHook( GetInfo() );
- if( GetInfo().GetLen() < GetInfo().GetText().getLength() )
- GetInfo().SetLen( GetInfo().GetText().getLength() );
+ if (GetInfo().GetLen() < TextFrameIndex(GetInfo().GetText().getLength()))
+ GetInfo().SetLen(TextFrameIndex(GetInfo().GetText().getLength()));
bool bBuild = true;
SetFlyInCntBase( false );
@@ -1497,7 +1497,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
// for an optimal repaint rectangle, we want to compare fly portions
// before and after the BuildPortions call
const bool bOptimizeRepaint = AllowRepaintOpt();
- const sal_Int32 nOldLineEnd = nStartPos + m_pCurr->GetLen();
+ TextFrameIndex const nOldLineEnd = nStartPos + m_pCurr->GetLen();
std::vector<long> flyStarts;
// these are the conditions for a fly position comparison
@@ -1539,7 +1539,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
if( GetInfo().IsStop() )
{
- m_pCurr->SetLen( 0 );
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list