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