summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/IDocumentRedlineAccess.hxx5
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx9
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx29
-rw-r--r--sw/source/core/edit/acorrect.cxx45
-rw-r--r--sw/source/core/inc/DocumentRedlineManager.hxx5
5 files changed, 53 insertions, 40 deletions
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index 395fae8d47e2..0e4c9e33fb52 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -170,6 +170,11 @@ public:
/*[in]*/const SwNode& rNode,
/*[in]*/RedlineType nType) const = 0;
+ virtual bool HasRedline(
+ /*[in]*/const SwPaM& rPam,
+ /*[in]*/RedlineType nType,
+ /*[in]*/bool bStartOrEndInRange) const = 0;
+
virtual void CompressRedlines() = 0;
virtual const SwRangeRedline* GetRedline(
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2acfc17b7082..f1bb78af34cb 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -7652,11 +7652,18 @@ void SwUiWriterTest::testRedlineAutoCorrect()
nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // Including capitalization
+ pWrtShell->Insert("end. word");
+ pWrtShell->AutoCorrect(corr, ' ');
+ sReplaced = "tset test end. Word ";
+ nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+
// tracked deletions after the correction point doesn't affect autocorrect
dispatchCommand(mxComponent, ".uno:GoToStartOfDoc", {});
pWrtShell->Insert("a");
pWrtShell->AutoCorrect(corr, ' ');
- sReplaced = "A tset test ";
+ sReplaced = "A tset test end. Word ";
nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 22893963b5b1..17419eda39ba 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2523,6 +2523,35 @@ SwRedlineTable::size_type DocumentRedlineManager::GetRedlinePos( const SwNode& r
// #TODO - add 'SwExtraRedlineTable' also ?
}
+bool DocumentRedlineManager::HasRedline( const SwPaM& rPam, RedlineType nType, bool bStartOrEndInRange ) const // xxx
+{
+ SwPosition currentStart(*rPam.Start());
+ SwPosition currentEnd(*rPam.End());
+ SwNodeIndex pEndNodeIndex(currentEnd.nNode.GetNode());
+
+ for( SwRedlineTable::size_type n = GetRedlinePos( rPam.Start()->nNode.GetNode(), nType );
+ n < mpRedlineTable->size(); ++n )
+ {
+ const SwRangeRedline* pTmp = (*mpRedlineTable)[ n ];
+
+ if ( pTmp->Start()->nNode > pEndNodeIndex )
+ break;
+
+ if( RedlineType::Any != nType && nType != pTmp->GetType() )
+ continue;
+
+ // redline over the range
+ if ( currentStart < *pTmp->End() && *pTmp->Start() <= currentEnd &&
+ // starting or ending within the range
+ ( !bStartOrEndInRange ||
+ ( currentStart <= *pTmp->Start() || *pTmp->End() <= currentEnd ) ) )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
const SwRangeRedline* DocumentRedlineManager::GetRedline( const SwPosition& rPos,
SwRedlineTable::size_type* pFndPos ) const
{
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index d7003ccfbaed..a1c06e0442d1 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -42,6 +42,7 @@
#include <editeng/acorrcfg.hxx>
#include <redline.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <rootfrm.hxx>
using namespace ::com::sun::star;
@@ -231,31 +232,10 @@ bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const
// tdf#83419 avoid bad autocorrect with visible redlines
// e.g. replacing the first letter of the tracked deletion
// with its capitalized (and not deleted) version.
- if ( bDoReplace )
+ if ( bDoReplace && !pFrame->getRootFrame()->IsHideRedlines() &&
+ m_rEditSh.GetDoc()->getIDocumentRedlineAccess().HasRedline( *pPam, RedlineType::Delete, /*bStartOrEndInRange=*/false ) )
{
- const OUString& rOrigText = pos.first->GetText();
- // GetRedlineText() doesn't contain dummy characters, so handle them
- sal_Int32 nLengthCorrection = 0;
- for (sal_Int32 n = 0; n < rOrigText.getLength(); ++n)
- {
- sal_Unicode const Char = rOrigText[n];
- if ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char )
- ++nLengthCorrection;
- }
- sal_Int32 nDelChars = rOrigText.getLength() - nLengthCorrection -
- pos.first->GetRedlineText().getLength();
- // Are there tracked deletions before the correction point?
- if ( nDelChars > 0 && pos.first->GetRedlineText().compareTo( nLengthCorrection == 0
- ? rOrigText
- : rOrigText.replaceAll(OUString(CH_TXTATR_INWORD), "")
- .replaceAll(OUString(CH_TXTATR_BREAKWORD), ""),
- pos.second + nSourceLength + nDelChars ) != 0 &&
- // and are they visible?
- pFrame->GetText().compareTo(
- rOrigText, pos.second + nSourceLength + nDelChars + nLengthCorrection) == 0 )
- {
- bDoReplace = false;
- }
+ bDoReplace = false;
}
if ( bDoReplace )
@@ -434,22 +414,9 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
SwPaM aPam(aStartPos, aEndPos);
// don't replace, if a redline starts or ends within the original text
- for ( SwRedlineTable::size_type nAct =
- pDoc->getIDocumentRedlineAccess().GetRedlinePos( m_rCursor.GetNode(), RedlineType::Any );
- nAct < pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); ++nAct )
+ if ( pDoc->getIDocumentRedlineAccess().HasRedline( aPam, RedlineType::Any, /*bStartOrEndInRange=*/true ) )
{
- const SwRangeRedline* pRed = pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nAct ];
-
- if ( pRed->Start()->nNode > pTextNd->GetIndex() )
- break;
-
- // redline over the original text
- if ( aStartPos < *pRed->End() && *pRed->Start() < aEndPos &&
- // starting or ending within the original text
- ( aStartPos < *pRed->Start() || *pRed->End() < aEndPos ) )
- {
- return bRet;
- }
+ return bRet;
}
if( pFnd->IsTextOnly() )
diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx
index a9811827e262..8f79088dec0f 100644
--- a/sw/source/core/inc/DocumentRedlineManager.hxx
+++ b/sw/source/core/inc/DocumentRedlineManager.hxx
@@ -76,6 +76,11 @@ public:
/*[in]*/const SwNode& rNode,
/*[in]*/RedlineType nType) const override;
+ virtual bool HasRedline(
+ /*[in]*/const SwPaM& rPam,
+ /*[in]*/RedlineType nType,
+ /*[in]*/bool bStartOrEndInRange) const override;
+
virtual void CompressRedlines() override;
virtual const SwRangeRedline* GetRedline(