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

sw_redlinehide_4b: visibility checks for bookmarks too

SwCursorShell::GotoMark(), GoNextBookmark(), GoPrevBookmark() check
visibility of mark in layout.

SwWrtShell::GotoMark() returns whether it was successful.

EnhancedPDFExport skips marks that are not visible when creating links.

Change-Id: I36c0706c18a5f861b15eaf451a97daec04104056
üst 7d481f7a
......@@ -19,6 +19,8 @@
#include <crsrsh.hxx>
#include <ndtxt.hxx>
#include <rootfrm.hxx>
#include <txtfrm.hxx>
#include <docary.hxx>
#include <IMark.hxx>
#include "callnk.hxx"
......@@ -121,10 +123,53 @@ namespace
EndAction();
return pMark;
}
// set CurrentCursor.SPoint
namespace sw {
bool IsMarkHidden(SwRootFrame const& rLayout, ::sw::mark::IMark const& rMark)
{
if (!rLayout.IsHideRedlines())
{
return false;
}
SwTextNode const& rNode(*rMark.GetMarkPos().nNode.GetNode().GetTextNode());
SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
rNode.getLayoutFrame(&rLayout)));
if (!pFrame)
{
return true;
}
if (rMark.IsExpanded())
{
SwTextFrame const*const pOtherFrame(static_cast<SwTextFrame const*>(
rMark.GetOtherMarkPos().nNode.GetNode().GetTextNode()->getLayoutFrame(&rLayout)));
return pFrame == pOtherFrame
&& pFrame->MapModelToViewPos(rMark.GetMarkPos())
== pFrame->MapModelToViewPos(rMark.GetOtherMarkPos());
}
else
{
if (rMark.GetMarkPos().nContent.GetIndex() == rNode.Len())
{ // at end of node: never deleted (except if node deleted)
return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
}
else
{ // check character following mark pos
return pFrame->MapModelToViewPos(rMark.GetMarkPos())
== pFrame->MapModelToView(&rNode, rMark.GetMarkPos().nContent.GetIndex() + 1);
}
}
}
} // namespace sw
// set CurrentCursor.SPoint
bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark, bool bAtStart)
{
if (sw::IsMarkHidden(*GetLayout(), *pMark))
{
return false;
}
// watch Cursor-Moves
CursorStateHelper aCursorSt(*this);
if ( bAtStart )
......@@ -140,6 +185,10 @@ bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark, bool bAtStart
bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark)
{
if (sw::IsMarkHidden(*GetLayout(), *pMark))
{
return false;
}
// watch Cursor-Moves
CursorStateHelper aCursorSt(*this);
aCursorSt.SetCursorToMark(pMark);
......@@ -169,6 +218,10 @@ bool SwCursorShell::GoNextBookmark()
IDocumentMarkAccess::const_iterator_t ppMark = vCandidates.begin();
for(; ppMark!=vCandidates.end(); ++ppMark)
{
if (sw::IsMarkHidden(*GetLayout(), **ppMark))
{
continue;
}
aCursorSt.SetCursorToMark(ppMark->get());
if(!aCursorSt.RollbackIfIllegal())
break; // found legal move
......@@ -214,6 +267,10 @@ bool SwCursorShell::GoPrevBookmark()
// above)
if(!(**ppMark).EndsBefore(*GetCursor()->GetPoint()))
continue;
if (sw::IsMarkHidden(*GetLayout(), **ppMark))
{
continue;
}
aCursorSt.SetCursorToMark(ppMark->get());
if(!aCursorSt.RollbackIfIllegal())
break; // found legal move
......
......@@ -26,6 +26,7 @@
namespace com { namespace sun { namespace star { namespace linguistic2 { class XHyphenatedWord; } } } }
namespace sw { namespace mark { class IMark; } }
class SwCharRange;
class SwTextNode;
class SwTextFormatter;
......@@ -135,6 +136,8 @@ OUString GetExpandTextMerged(SwRootFrame const* pLayout,
SwTextNode const& rNode, bool bWithNumber,
bool bWithSpacesForLevel, ExpandMode i_mode);
bool IsMarkHidden(SwRootFrame const& rLayout, ::sw::mark::IMark const& rMark);
} // namespace sw
/// Represents the visualization of a paragraph. Typical upper is an
......
......@@ -2101,7 +2101,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
const OUString& sBkName = pBkmk->GetName();
//jump to it
JumpToSwMark( &mrSh, sBkName );
if (! JumpToSwMark( &mrSh, sBkName ))
{
continue;
}
// Destination Rectangle
const SwRect& rDestRect = mrSh.GetCharRect();
......
......@@ -404,7 +404,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
// jump to bookmark and set the "selections-flags" correctly again
void GotoMark( const ::sw::mark::IMark* const pMark );
void GotoMark( const ::sw::mark::IMark* const pMark, bool bSelect );
bool GotoMark( const ::sw::mark::IMark* const pMark, bool bSelect );
void GotoMark( const OUString& rName );
bool GoNextBookmark(); // true when there still was one
bool GoPrevBookmark();
......
......@@ -2002,8 +2002,7 @@ bool SwView::JumpToSwMark( const OUString& rMark )
}
else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
{
m_pWrtShell->GotoMark( ppMark->get(), false );
bRet = true;
bRet = m_pWrtShell->GotoMark( ppMark->get(), false );
}
else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
m_pWrtShell->addCurrentPosition();
......@@ -2029,8 +2028,7 @@ bool SwView::JumpToSwMark( const OUString& rMark )
}
else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
{
m_pWrtShell->GotoMark( ppMark->get(), false );
bRet = true;
bRet = m_pWrtShell->GotoMark( ppMark->get(), false );
}
else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
......
......@@ -576,13 +576,14 @@ bool SwWrtShell::GotoPage(sal_uInt16 nPage, bool bRecord)
return false;
}
void SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, bool bSelect )
bool SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, bool bSelect )
{
ShellMoveCursor aTmp( this, bSelect );
SwPosition aPos = *GetCursor()->GetPoint();
bool bRet = SwCursorShell::GotoMark( pMark, true/*bStart*/ );
if (bRet)
m_aNavigationMgr.addEntry(aPos);
return bRet;
}
bool SwWrtShell::GotoFly( const OUString& rName, FlyCntType eType, bool bSelFrame )
......
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