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

sw_redlinehide_4b: adapt FindText()

Generally speaking, the find functions should find the strings that are
visible in the document view.  However, they may also be called from
SwXTextDocument functions, where they ought to find the strings that are
actually in the document model.

So concoct some funny helper types and adapt this so it can handle both
cases; it's not pretty but maybe it even works.

Change-Id: I1917398ff928e922673353e75e8fb724dc042031
üst 92560b2d
......@@ -117,7 +117,8 @@ public:
SwDocPositions nStart, SwDocPositions nEnde,
bool& bCancel,
FindRanges,
bool bReplace = false );
bool bReplace = false,
SwRootFrame const*const pLayout = nullptr);
sal_uLong FindFormat( const SwTextFormatColl& rFormatColl,
SwDocPositions nStart, SwDocPositions nEnde,
bool& bCancel,
......
......@@ -3330,7 +3330,7 @@ sal_uLong SwCursorShell::Find_Text( const i18nutil::SearchOptions2& rSearchOpt,
m_pTableCursor = nullptr;
SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
sal_uLong nRet = m_pCurrentCursor->Find_Text(rSearchOpt, bSearchInNotes, eStart, eEnd,
bCancel, eRng, bReplace );
bCancel, eRng, bReplace, GetLayout());
if( nRet || bCancel )
UpdateCursor();
return nRet;
......
......@@ -1136,7 +1136,7 @@ int SwFindParaAttr::DoFind(SwPaM & rCursor, SwMoveFnCollection const & fnMove,
// TODO: searching for attributes in Outliner text?!
// continue search in correct section (pTextRegion)
if (sw::FindTextImpl(aSrchPam, *pSearchOpt, false/*bSearchInNotes*/, *pSText, fnMove, *pTextRegion, bInReadOnly) &&
if (sw::FindTextImpl(aSrchPam, *pSearchOpt, false/*bSearchInNotes*/, *pSText, fnMove, *pTextRegion, bInReadOnly, nullptr/*FIXME*/) &&
*aSrchPam.GetMark() != *aSrchPam.GetPoint() )
break; // found
else if( !pSet->Count() )
......
This diff is collapsed.
......@@ -735,24 +735,26 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
/// @param rbFirst If <true> then first time request. If so than the position of
/// the PaM must not be changed!
SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const & fnMove,
bool bInReadOnly )
bool const bInReadOnly, SwRootFrame const*const i_pLayout)
{
SwRootFrame const*const pLayout(i_pLayout ? i_pLayout :
rPam.GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout());
SwContentNode * pNd = nullptr;
if( ((*rPam.GetPoint()).*fnMove.fnCmpOp)( *rPam.GetMark() ) ||
( *rPam.GetPoint() == *rPam.GetMark() && rbFirst ) )
{
SwContentFrame* pFrame;
if( rbFirst )
{
rbFirst = false;
pNd = rPam.GetContentNode();
if( pNd )
{
SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
if(
(
nullptr == ( pFrame = pNd->getLayoutFrame( pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() ) ) ||
nullptr == pFrame ||
( !bInReadOnly && pFrame->IsProtected() ) ||
(pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsHiddenNow())
(pFrame->IsTextFrame() && static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow())
) ||
( !bInReadOnly && pNd->FindSectionNode() &&
pNd->FindSectionNode()->GetSection().IsProtect()
......@@ -773,6 +775,12 @@ SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const &
// go to next/previous ContentNode
while( true )
{
if (i_pLayout && aPos.nNode.GetNode().IsTextNode())
{
auto const fal(sw::GetFirstAndLastNode(*pLayout, aPos.nNode));
aPos.nNode = bSrchForward ? *fal.second : *fal.first;
}
pNd = bSrchForward
? rNodes.GoNextSection( &aPos.nNode, true, !bInReadOnly )
: SwNodes::GoPrevSection( &aPos.nNode, true, !bInReadOnly );
......@@ -783,10 +791,11 @@ SwContentNode* GetNode( SwPaM & rPam, bool& rbFirst, SwMoveFnCollection const &
if( (aPos.*fnMove.fnCmpOp)( *rPam.GetMark() ) )
{
// only in AutoTextSection can be nodes that are hidden
if( nullptr == ( pFrame = pNd->getLayoutFrame( pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() ) ) ||
SwContentFrame const*const pFrame(pNd->getLayoutFrame(pLayout));
if (nullptr == pFrame ||
( !bInReadOnly && pFrame->IsProtected() ) ||
( pFrame->IsTextFrame() &&
static_cast<SwTextFrame*>(pFrame)->IsHiddenNow() ) )
static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow()))
{
pNd = nullptr;
continue;
......
......@@ -29,6 +29,7 @@ class SwPaM;
class SwTextAttr;
class SwFormat;
class SfxPoolItem;
class SwRootFrame;
namespace i18nutil {
struct SearchOptions2;
......@@ -75,7 +76,8 @@ struct SwMoveFnCollection
};
// function prototype for searching
SwContentNode* GetNode( SwPaM&, bool&, SwMoveFnCollection const &, bool bInReadOnly = false );
SwContentNode* GetNode(SwPaM&, bool&, SwMoveFnCollection const &,
bool bInReadOnly = false, SwRootFrame const* pLayout = nullptr);
namespace sw {
......@@ -88,7 +90,8 @@ namespace sw {
bool bSearchInNotes,
utl::TextSearch& rSText,
SwMoveFnCollection const & fnMove,
const SwPaM & rRegion, bool bInReadOnly = false);
const SwPaM & rRegion, bool bInReadOnly,
SwRootFrame const* pLayout);
bool FindFormatImpl(SwPaM & rSearchPam,
const SwFormat& rFormat,
SwMoveFnCollection const & fnMove,
......
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