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
{
aPam.SetMark();
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 );
}
}
......
This diff is collapsed.
......@@ -21,8 +21,11 @@
#define INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX
#include <swtypes.hxx>
#include "TextFrameIndex.hxx"
#include <vector>
class SwTextFrame;
class SwPaM;
class SwTextCursor;
......@@ -50,7 +53,8 @@ public:
SwTwips GetCharPos(TextFrameIndex nChar, bool bCenter = true) const;
// 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?
bool IsBullet(TextFrameIndex nTextPos) const;
......
......@@ -131,39 +131,31 @@ SwTwips SwTextFrameInfo::GetCharPos(TextFrameIndex const nChar, bool bCenter) co
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)
{
assert(rRanges.empty() || rRanges.back().second <= nPos);
if( nLen )
{
SwPosition const start(pTextFrame->MapViewToModelPos(nPos));
SwPosition const end(pTextFrame->MapViewToModelPos(nPos + nLen));
// It could be the first
if( pPam->HasMark() )
if (!rRanges.empty() && nPos == rRanges.back().second)
{
// If the new position is right after the current one, then
// simply extend the Pam
if (start == *pPam->GetPoint())
{
*pPam->GetPoint() = end;
return pPam;
}
pPam = new SwPaM(*pPam, pPam);
rRanges.back().second += nLen;
}
else
{
rRanges.emplace_back(nPos, nPos + nLen);
}
*pPam->GetPoint() = start;
pPam->SetMark();
*pPam->GetPoint() = end;
}
return pPam;
}
// Accumulates the whitespace at line start and end in the Pam
void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
// Accumulates the whitespace at line start and end in the vector
void SwTextFrameInfo::GetSpaces(
std::vector<std::pair<TextFrameIndex, TextFrameIndex>> & rRanges,
bool const bWithLineBreak) const
{
SwTextSizeInfo aInf( const_cast<SwTextFrame*>(pFrame) );
SwTextMargin aLine( const_cast<SwTextFrame*>(pFrame), &aInf );
SwPaM *pPam = &rPam;
bool bFirstLine = true;
do {
......@@ -173,8 +165,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
// Do NOT include the blanks/tabs from the first line
// in the selection
if( !bFirstLine && nPos > aLine.GetStart() )
pPam = AddPam( pPam, pFrame, aLine.GetStart(),
nPos - aLine.GetStart() );
AddRange( rRanges, aLine.GetStart(), nPos - aLine.GetStart() );
// Do NOT include the blanks/tabs from the last line
// in the selection
......@@ -187,7 +178,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK ==
aLine.GetInfo().GetChar(aLine.GetEnd() - TextFrameIndex(1))
? 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