Kaydet (Commit) fd6e9279 authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Thorsten Behrens

sw_redlinehide_4a: SwAutoFormat: manually skip redlines when deleting

Change-Id: I001e61305ee8416f851f834d3068bd91de8281f8
(cherry picked from commit b9a5d497)
üst 2d8454e0
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <IDocumentUndoRedo.hxx> #include <IDocumentUndoRedo.hxx>
#include <DocumentRedlineManager.hxx> #include <DocumentRedlineManager.hxx>
#include <IDocumentStylePoolAccess.hxx> #include <IDocumentStylePoolAccess.hxx>
#include <redline.hxx>
#include <unocrsr.hxx>
#include <docary.hxx> #include <docary.hxx>
#include <editsh.hxx> #include <editsh.hxx>
#include <index.hxx> #include <index.hxx>
...@@ -172,6 +174,7 @@ class SwAutoFormat ...@@ -172,6 +174,7 @@ class SwAutoFormat
static bool HasSelBlanks( SwPaM& rPam ); static bool HasSelBlanks( SwPaM& rPam );
static bool HasBreakAttr( const SwTextNode& ); static bool HasBreakAttr( const SwTextNode& );
void DeleteSel( SwPaM& rPam ); void DeleteSel( SwPaM& rPam );
void DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect);
bool DeleteJoinCurNextPara( const OUString& rNxtPara ); bool DeleteJoinCurNextPara( const OUString& rNxtPara );
/// delete in the node start and/or end /// delete in the node start and/or end
void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true ); void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
...@@ -1093,26 +1096,87 @@ void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd) ...@@ -1093,26 +1096,87 @@ void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
} }
} }
void SwAutoFormat::DeleteSel( SwPaM& rDelPam ) bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & rRanges,
SwDoc & rDoc, SwPaM const& rDelPam)
{ {
if( m_aFlags.bWithRedlining ) bool isNoRedline(true);
SwRedlineTable::size_type tmp;
IDocumentRedlineAccess const& rIDRA(rDoc.getIDocumentRedlineAccess());
if (!(rIDRA.GetRedlineFlags() & RedlineFlags::ShowDelete))
{
return isNoRedline;
}
rIDRA.GetRedline(*rDelPam.Start(), &tmp);
SwPosition const* pCurrent(rDelPam.Start());
for ( ; tmp < rIDRA.GetRedlineTable().size(); ++tmp)
{
SwRangeRedline const*const pRedline(rIDRA.GetRedlineTable()[tmp]);
if (*rDelPam.End() <= *pRedline->Start())
{
break;
}
if (*pRedline->End() <= *rDelPam.Start())
{
continue;
}
if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
{
assert(*pRedline->Start() != *pRedline->End());
isNoRedline = false;
if (*pCurrent < *pRedline->Start())
{
rRanges.push_back(rDoc.CreateUnoCursor(*pCurrent));
rRanges.back()->SetMark();
*rRanges.back()->GetPoint() = *pRedline->Start();
}
pCurrent = pRedline->End();
}
}
if (!isNoRedline && *pCurrent < *rDelPam.End())
{
rRanges.push_back(rDoc.CreateUnoCursor(*pCurrent));
rRanges.back()->SetMark();
*rRanges.back()->GetPoint() = *rDelPam.End();
}
return isNoRedline;
}
void SwAutoFormat::DeleteSel(SwPaM & rDelPam)
{
std::vector<std::shared_ptr<SwUnoCursor>> ranges; // need correcting cursor
if (GetRanges(ranges, *m_pDoc, rDelPam))
{
DeleteSelImpl(rDelPam, rDelPam);
}
else
{
for (auto const& pCursor : ranges)
{
DeleteSelImpl(*pCursor, rDelPam);
}
}
}
void SwAutoFormat::DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect)
{
if (m_aFlags.bWithRedlining || &rDelPam != &rPamToCorrect)
{ {
// Add to Shell-Cursor-Ring so that DelPam will be moved as well! // Add to Shell-Cursor-Ring so that DelPam will be moved as well!
SwPaM* pShCursor = m_pEditShell->GetCursor_(); SwPaM* pShCursor = m_pEditShell->GetCursor_();
SwPaM aTmp( *m_pCurTextNd, 0, pShCursor ); SwPaM aTmp( *m_pCurTextNd, 0, pShCursor );
SwPaM* pPrev = rDelPam.GetPrev(); SwPaM* pPrev = rPamToCorrect.GetPrev();
rDelPam.GetRingContainer().merge( pShCursor->GetRingContainer() ); rPamToCorrect.GetRingContainer().merge( pShCursor->GetRingContainer() );
m_pEditShell->DeleteSel( rDelPam ); m_pEditShell->DeleteSel( rDelPam );
// and remove Pam again: // and remove Pam again:
SwPaM* p; SwPaM* p;
SwPaM* pNext = &rDelPam; SwPaM* pNext = &rPamToCorrect;
do { do {
p = pNext; p = pNext;
pNext = p->GetNext(); pNext = p->GetNext();
p->MoveTo( &rDelPam ); p->MoveTo( &rPamToCorrect );
} while( p != pPrev ); } while( p != pPrev );
m_aNdIdx = aTmp.GetPoint()->nNode; m_aNdIdx = aTmp.GetPoint()->nNode;
......
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