summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-12-17 14:10:26 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-18 17:55:29 +0100
commit87514172c1924492c33a8aa261b082f0ae7f9b48 (patch)
treedfe6d7c10207f53bb5c2b86969c8656439cbc4b8 /sw
parent1199902fc9cbf2cf51733f7bc4205d6c32d781d1 (diff)
sw_redlinehide_4b: adapt FindFormat()
Change-Id: I78cfca1cd629bf518f8294450a34ee228a360ef9
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/swcrsr.hxx3
-rw-r--r--sw/source/core/crsr/findcoll.cxx19
-rw-r--r--sw/source/core/crsr/findfmt.cxx34
-rw-r--r--sw/source/core/inc/pamtyp.hxx3
4 files changed, 44 insertions, 15 deletions
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index 0ccba70839b9..d3d23155ff5e 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -123,7 +123,8 @@ public:
SwDocPositions nStart, SwDocPositions nEnde,
bool& bCancel,
FindRanges,
- const SwTextFormatColl* pReplFormat );
+ const SwTextFormatColl* pReplFormat,
+ SwRootFrame const*const pLayout = nullptr);
sal_uLong FindAttrs( const SfxItemSet& rSet, bool bNoCollections,
SwDocPositions nStart, SwDocPositions nEnde,
bool& bCancel,
diff --git a/sw/source/core/crsr/findcoll.cxx b/sw/source/core/crsr/findcoll.cxx
index b05fe2c5f742..ec033d6bb207 100644
--- a/sw/source/core/crsr/findcoll.cxx
+++ b/sw/source/core/crsr/findcoll.cxx
@@ -30,8 +30,13 @@
struct SwFindParaFormatColl : public SwFindParas
{
const SwTextFormatColl *pFormatColl, *pReplColl;
- SwFindParaFormatColl(const SwTextFormatColl& rFormatColl, const SwTextFormatColl* pRpColl)
- : pFormatColl( &rFormatColl ), pReplColl( pRpColl )
+ SwRootFrame const* m_pLayout;
+ SwFindParaFormatColl(const SwTextFormatColl& rFormatColl,
+ const SwTextFormatColl *const pRpColl,
+ SwRootFrame const*const pLayout)
+ : pFormatColl( &rFormatColl )
+ , pReplColl( pRpColl )
+ , m_pLayout(pLayout)
{}
virtual ~SwFindParaFormatColl() {}
virtual int DoFind(SwPaM &, SwMoveFnCollection const &, const SwPaM &, bool bInReadOnly) override;
@@ -45,11 +50,12 @@ int SwFindParaFormatColl::DoFind(SwPaM & rCursor, SwMoveFnCollection const & fnM
if( bInReadOnly && pReplColl )
bInReadOnly = false;
- if (!sw::FindFormatImpl(rCursor, *pFormatColl, fnMove, rRegion, bInReadOnly))
+ if (!sw::FindFormatImpl(rCursor, *pFormatColl, fnMove, rRegion, bInReadOnly, m_pLayout))
nRet = FIND_NOT_FOUND;
else if( pReplColl )
{
- rCursor.GetDoc()->SetTextFormatColl(rCursor, const_cast<SwTextFormatColl*>(pReplColl));
+ rCursor.GetDoc()->SetTextFormatColl(rCursor,
+ const_cast<SwTextFormatColl*>(pReplColl), true, false, m_pLayout);
nRet = FIND_NO_RING;
}
return nRet;
@@ -63,7 +69,8 @@ bool SwFindParaFormatColl::IsReplaceMode() const
/// search for Format-Collections
sal_uLong SwCursor::FindFormat( const SwTextFormatColl& rFormatColl, SwDocPositions nStart,
SwDocPositions nEnd, bool& bCancel,
- FindRanges eFndRngs, const SwTextFormatColl* pReplFormatColl )
+ FindRanges eFndRngs, const SwTextFormatColl* pReplFormatColl,
+ SwRootFrame const*const pLayout)
{
// switch off OLE-notifications
SwDoc* pDoc = GetDoc();
@@ -83,7 +90,7 @@ sal_uLong SwCursor::FindFormat( const SwTextFormatColl& rFormatColl, SwDocPositi
&aRewriter );
}
- SwFindParaFormatColl aSwFindParaFormatColl(rFormatColl, pReplFormatColl);
+ SwFindParaFormatColl aSwFindParaFormatColl(rFormatColl, pReplFormatColl, pLayout);
sal_uLong nRet = FindAll( aSwFindParaFormatColl, nStart, nEnd, eFndRngs, bCancel );
pDoc->SetOle2Link( aLnk );
diff --git a/sw/source/core/crsr/findfmt.cxx b/sw/source/core/crsr/findfmt.cxx
index f45759e5a0d6..1193cf856ef8 100644
--- a/sw/source/core/crsr/findfmt.cxx
+++ b/sw/source/core/crsr/findfmt.cxx
@@ -20,13 +20,15 @@
#include <doc.hxx>
#include <pamtyp.hxx>
#include <pam.hxx>
+#include <txtfrm.hxx>
#include <memory>
namespace sw {
bool FindFormatImpl(SwPaM & rSearchPam,
const SwFormat& rFormat, SwMoveFnCollection const & fnMove,
- const SwPaM &rRegion, bool bInReadOnly)
+ const SwPaM &rRegion, bool bInReadOnly,
+ SwRootFrame const*const pLayout)
{
bool bFound = false;
const bool bSrchForward = &fnMove == &fnMoveForward;
@@ -47,19 +49,37 @@ bool FindFormatImpl(SwPaM & rSearchPam,
bool bFirst = true;
SwContentNode* pNode;
- while( nullptr != ( pNode = ::GetNode( *pPam, bFirst, fnMove, bInReadOnly )))
+ while (nullptr != (pNode = ::GetNode(*pPam, bFirst, fnMove, bInReadOnly, pLayout)))
{
- if ( pNode->GetFormatColl() == &rFormat )
+ SwTextFrame const*const pFrame(pLayout && pNode->IsTextNode()
+ ? static_cast<SwTextFrame const*>(pNode->getLayoutFrame(pLayout))
+ : nullptr);
+ assert(!pLayout || !pNode->IsTextNode() || pFrame);
+ SwContentNode const& rPropsNode(*(pFrame
+ ? pFrame->GetTextNodeForParaProps()
+ : pNode));
+
+ if (rPropsNode.GetFormatColl() == &rFormat)
{
// if a FormatCollection is found then it is definitely a SwContentNode
// FORWARD: SPoint at the end, GetMark at the beginning of the node
// BACKWARD: SPoint at the beginning, GetMark at the end of the node
// always: incl. start and incl. end
- *rSearchPam.GetPoint() = *pPam->GetPoint();
- rSearchPam.SetMark();
- pNode->MakeEndIndex( &rSearchPam.GetPoint()->nContent );
- rSearchPam.GetMark()->nContent = 0;
+ if (pFrame)
+ {
+ *rSearchPam.GetPoint() = *pPam->GetPoint();
+ rSearchPam.SetMark();
+ *rSearchPam.GetMark() = pFrame->MapViewToModelPos(
+ TextFrameIndex(bSrchForward ? pFrame->GetText().getLength() : 0));
+ }
+ else
+ {
+ *rSearchPam.GetPoint() = *pPam->GetPoint();
+ rSearchPam.SetMark();
+ pNode->MakeEndIndex( &rSearchPam.GetPoint()->nContent );
+ rSearchPam.GetMark()->nContent = 0;
+ }
// if backward search, switch point and mark
if( !bSrchForward )
diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx
index b51212b23633..c9fc8124b876 100644
--- a/sw/source/core/inc/pamtyp.hxx
+++ b/sw/source/core/inc/pamtyp.hxx
@@ -95,7 +95,8 @@ namespace sw {
bool FindFormatImpl(SwPaM & rSearchPam,
const SwFormat& rFormat,
SwMoveFnCollection const & fnMove,
- const SwPaM & rRegion, bool bInReadOnly = false);
+ const SwPaM & rRegion, bool bInReadOnly,
+ SwRootFrame const* pLayout);
bool FindAttrImpl(SwPaM & rSearchPam,
const SfxPoolItem& rAttr,
SwMoveFnCollection const & fnMove,