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

sw_redlinehide_3: adapt GotoOutline for SwCursrShell

Adapt SwDoc::GotoOutline(), SwCursorShell::GotoNextOutline(),
SwCursorShell::GotoPrevOutline() to skip over outline nodes that are
merged away in the layout.

Change-Id: Id6f6bb93177753ed21a438c89dc6d90098e11455
üst 71c03c2a
......@@ -1007,7 +1007,7 @@ public:
/// Outline - move up / move down.
bool MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset);
bool GotoOutline( SwPosition& rPos, const OUString& rName ) const;
bool GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const* = nullptr) const;
/** Accept changes of outline styles for OutlineRule.
@param bResetIndentAttrs Optional parameter - default value false:
......
......@@ -1001,7 +1001,8 @@ bool SwCursorShell::GotoOutline( const OUString& rName )
SwCursorSaveState aSaveState( *pCursor );
bool bRet = false;
if( mxDoc->GotoOutline( *pCursor->GetPoint(), rName ) && !pCursor->IsSelOvr() )
if (mxDoc->GotoOutline(*pCursor->GetPoint(), rName, GetLayout())
&& !pCursor->IsSelOvr())
{
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
bRet = true;
......@@ -1023,18 +1024,45 @@ bool SwCursorShell::GotoNextOutline()
SwCursor* pCursor = getShellCursor( true );
SwNode* pNd = &(pCursor->GetNode());
SwOutlineNodes::size_type nPos;
if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ))
++nPos;
bool bUseFirst = !rNds.GetOutLineNds().Seek_Entry( pNd, &nPos );
SwOutlineNodes::size_type const nStartPos(nPos);
do
{
if (nPos == rNds.GetOutLineNds().size())
{
nPos = 0;
}
else if (!bUseFirst)
{
++nPos;
}
if (bUseFirst)
{
bUseFirst = false;
}
else
{
if (nPos == nStartPos)
{
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
return false;
}
}
if( nPos == rNds.GetOutLineNds().size() )
pNd = rNds.GetOutLineNds()[ nPos ];
}
while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
if (nPos < nStartPos)
{
nPos = 0;
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
}
else
{
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
pNd = rNds.GetOutLineNds()[ nPos ];
}
SET_CURR_SHELL( this );
SwCallLink aLk( *this ); // watch Cursor-Moves
......@@ -1064,20 +1092,38 @@ bool SwCursorShell::GotoPrevOutline()
SwOutlineNodes::size_type nPos;
bool bRet = false;
(void)rNds.GetOutLineNds().Seek_Entry(pNd, &nPos);
if ( nPos == 0 )
{
nPos = rNds.GetOutLineNds().size();
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
}
else
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
SwOutlineNodes::size_type const nStartPos(nPos);
if (nPos)
do
{
--nPos; // before
if (nPos == 0)
{
nPos = rNds.GetOutLineNds().size() - 1;
}
else
{
--nPos; // before
}
if (nPos == nStartPos)
{
pNd = nullptr;
break;
}
pNd = rNds.GetOutLineNds()[ nPos ];
}
while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode()));
if (pNd)
{
if (nStartPos < nPos)
{
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
}
else
{
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
}
SET_CURR_SHELL( this );
SwCallLink aLk( *this ); // watch Cursor-Moves
SwCursorSaveState aSaveState( *pCursor );
......@@ -1088,6 +1134,10 @@ bool SwCursorShell::GotoPrevOutline()
if( bRet )
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
}
else
{
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
}
return bRet;
}
......
......@@ -502,7 +502,7 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
else if( sCmp == "outline" )
{
SwPosition aPos( SwNodeIndex( m_rDoc.GetNodes() ));
if( m_rDoc.GotoOutline( aPos, sName ))
if (m_rDoc.GotoOutline(aPos, sName, nullptr))
{
SwNode* pNd = &aPos.nNode.GetNode();
const int nLvl = pNd->GetTextNode()->GetAttrOutlineLevel()-1;
......
......@@ -584,7 +584,8 @@ static SwTextNode* lcl_FindOutlineName( const SwOutlineNodes& rOutlNds, const OU
return pSavedNode;
}
static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& rName )
static SwTextNode* lcl_FindOutlineNum(const SwOutlineNodes& rOutlNds,
OUString& rName, SwRootFrame const*const pLayout)
{
// Valid numbers are (always just offsets!):
// ([Number]+\.)+ (as a regular expression!)
......@@ -645,9 +646,9 @@ static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
// #i51089#, #i68289#
// Assure, that text node has the correct numbering level. Otherwise,
// its number vector will not fit to the searched level.
if ( pNd->GetNum() && pNd->GetActualListLevel() == nLevel - 1 )
if (pNd->GetNum(pLayout) && pNd->GetActualListLevel() == nLevel - 1)
{
const SwNodeNum & rNdNum = *(pNd->GetNum());
const SwNodeNum & rNdNum = *(pNd->GetNum(pLayout));
SwNumberTree::tNumberVector aLevelVal = rNdNum.GetNumberVector();
// now compare with the one searched for
bool bEqual = true;
......@@ -678,17 +679,14 @@ static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
return nullptr;
}
// Add this bullet point:
// A Name can contain a Number and/or the Text.
// rName can contain a Number and/or the Text.
// First, we try to find the correct Entry via the Number.
// If it exists, we compare the Text, to see if it's the right one.
// If it exists, we compare the Text to see if it's the right one.
// If that's not the case, we search again via the Text. If it is
// found, we got the right entry. Or else we use the one found by
// searching for the Number.
// If we don't have a Number, we search via the Text only.
bool SwDoc::GotoOutline( SwPosition& rPos, const OUString& rName ) const
bool SwDoc::GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const*const pLayout) const
{
if( !rName.isEmpty() )
{
......@@ -696,7 +694,7 @@ bool SwDoc::GotoOutline( SwPosition& rPos, const OUString& rName ) const
// 1. step: via the Number:
OUString sName( rName );
SwTextNode* pNd = ::lcl_FindOutlineNum( rOutlNds, sName );
SwTextNode* pNd = ::lcl_FindOutlineNum(rOutlNds, sName, pLayout);
if ( pNd )
{
OUString sExpandedText = pNd->GetExpandText();
......
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