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

sw_redlinehide_4a: SwAutoFormat iterates frames, not nodes

In order to not require moving the delete redlines out of the document
body, rely on the DeleteSel() implementation skipping over the redlines,
and also pass the shell's layout to the various SwDoc functions that
are called.

Previously, the redlines were not deleted by DeleteSel() due to
SwAutoFormat setting RedlineFlags::Ignore.

Change-Id: Ib05ecb534993368d81f66e70124617968b4c8e9a
üst b9a5d497
...@@ -1806,6 +1806,9 @@ void SwDoc::SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nP ...@@ -1806,6 +1806,9 @@ void SwDoc::SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nP
{ {
aPam.SetMark(); aPam.SetMark();
aPam.GetMark()->nContent.Assign(pTNd, pTNd->GetText().getLength()); aPam.GetMark()->nContent.Assign(pTNd, pTNd->GetText().getLength());
// sw_redlinehide: don't need layout currently because the only caller
// passes in the properties node
assert(static_cast<SwTextFrame const*>(pTNd->getLayoutFrame(nullptr))->GetTextNodeForParaProps() == pTNd);
getIDocumentContentOperations().InsertItemSet( aPam, *pSet ); getIDocumentContentOperations().InsertItemSet( aPam, *pSet );
} }
} }
......
This diff is collapsed.
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
#define INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX #define INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX
#include <swtypes.hxx> #include <swtypes.hxx>
#include "TextFrameIndex.hxx" #include "TextFrameIndex.hxx"
#include <vector>
class SwTextFrame; class SwTextFrame;
class SwPaM; class SwPaM;
class SwTextCursor; class SwTextCursor;
...@@ -50,7 +53,8 @@ public: ...@@ -50,7 +53,8 @@ public:
SwTwips GetCharPos(TextFrameIndex nChar, bool bCenter = true) const; SwTwips GetCharPos(TextFrameIndex nChar, bool bCenter = true) const;
// collect all whitespaces at the beginning and end of a line in Pam // collect all whitespaces at the beginning and end of a line in Pam
void GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const; void GetSpaces(std::vector<std::pair<TextFrameIndex, TextFrameIndex>> &,
bool bWithLineBreak) const;
// Is a bullet point/symbol/etc. at the first text position? // Is a bullet point/symbol/etc. at the first text position?
bool IsBullet(TextFrameIndex nTextPos) const; bool IsBullet(TextFrameIndex nTextPos) const;
......
...@@ -131,39 +131,31 @@ SwTwips SwTextFrameInfo::GetCharPos(TextFrameIndex const nChar, bool bCenter) co ...@@ -131,39 +131,31 @@ SwTwips SwTextFrameInfo::GetCharPos(TextFrameIndex const nChar, bool bCenter) co
return (( nNext + nStt ) / 2 ) - aRectFnSet.GetLeft(pFrame->getFrameArea()); return (( nNext + nStt ) / 2 ) - aRectFnSet.GetLeft(pFrame->getFrameArea());
} }
static SwPaM *AddPam( SwPaM *pPam, const SwTextFrame* pTextFrame, static void
AddRange(std::vector<std::pair<TextFrameIndex, TextFrameIndex>> & rRanges,
TextFrameIndex const nPos, TextFrameIndex const nLen) TextFrameIndex const nPos, TextFrameIndex const nLen)
{ {
assert(rRanges.empty() || rRanges.back().second <= nPos);
if( nLen ) if( nLen )
{ {
SwPosition const start(pTextFrame->MapViewToModelPos(nPos)); if (!rRanges.empty() && nPos == rRanges.back().second)
SwPosition const end(pTextFrame->MapViewToModelPos(nPos + nLen));
// It could be the first
if( pPam->HasMark() )
{ {
// If the new position is right after the current one, then rRanges.back().second += nLen;
// simply extend the Pam }
if (start == *pPam->GetPoint()) else
{ {
*pPam->GetPoint() = end; rRanges.emplace_back(nPos, nPos + nLen);
return pPam;
}
pPam = new SwPaM(*pPam, pPam);
} }
*pPam->GetPoint() = start;
pPam->SetMark();
*pPam->GetPoint() = end;
} }
return pPam;
} }
// Accumulates the whitespace at line start and end in the Pam // Accumulates the whitespace at line start and end in the vector
void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const void SwTextFrameInfo::GetSpaces(
std::vector<std::pair<TextFrameIndex, TextFrameIndex>> & rRanges,
bool const bWithLineBreak) const
{ {
SwTextSizeInfo aInf( const_cast<SwTextFrame*>(pFrame) ); SwTextSizeInfo aInf( const_cast<SwTextFrame*>(pFrame) );
SwTextMargin aLine( const_cast<SwTextFrame*>(pFrame), &aInf ); SwTextMargin aLine( const_cast<SwTextFrame*>(pFrame), &aInf );
SwPaM *pPam = &rPam;
bool bFirstLine = true; bool bFirstLine = true;
do { do {
...@@ -173,8 +165,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const ...@@ -173,8 +165,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
// Do NOT include the blanks/tabs from the first line // Do NOT include the blanks/tabs from the first line
// in the selection // in the selection
if( !bFirstLine && nPos > aLine.GetStart() ) if( !bFirstLine && nPos > aLine.GetStart() )
pPam = AddPam( pPam, pFrame, aLine.GetStart(), AddRange( rRanges, aLine.GetStart(), nPos - aLine.GetStart() );
nPos - aLine.GetStart() );
// Do NOT include the blanks/tabs from the last line // Do NOT include the blanks/tabs from the last line
// in the selection // in the selection
...@@ -187,7 +178,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const ...@@ -187,7 +178,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK == TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK ==
aLine.GetInfo().GetChar(aLine.GetEnd() - TextFrameIndex(1)) aLine.GetInfo().GetChar(aLine.GetEnd() - TextFrameIndex(1))
? 1 : 0 ); ? 1 : 0 );
pPam = AddPam( pPam, pFrame, nPos, aLine.GetEnd() - nPos - nOff ); AddRange( rRanges, nPos, aLine.GetEnd() - nPos - nOff );
} }
} }
} }
......
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