Skip to content

Commit

Permalink
sw: rename misleading DeleteCurrentParagraph()
Browse files Browse the repository at this point in the history
Rename also DelPrevPara() and DeleteCurNxtPara().

Also document the state transitions.

Change-Id: I0b874852a4c1aab8d5d3a55b9dfef360e313089c
  • Loading branch information
Michael Stahl authored and Michael Stahl committed Dec 1, 2018
1 parent 7058c01 commit c1f1cad
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions sw/source/core/edit/autofmt.cxx
Expand Up @@ -171,15 +171,15 @@ class SwAutoFormat
static bool HasSelBlanks( SwPaM& rPam );
static bool HasBreakAttr( const SwTextNode& );
void DeleteSel( SwPaM& rPam );
bool DeleteCurNxtPara( const OUString& rNxtPara );
bool DeleteJoinCurNextPara( const OUString& rNxtPara );
/// delete in the node start and/or end
void DeleteCurrentParagraph( bool bStart = true, bool bEnd = true );
void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
void DelEmptyLine( bool bTstNextPara = true );
/// when using multiline paragraphs delete the "left" and/or
/// "right" margins
void DelMoreLinesBlanks( bool bWithLineBreaks = false );
/// delete the previous paragraph
void DelPrevPara();
/// join with the previous paragraph
void JoinPrevPara();
/// execute AutoCorrect on current TextNode
void AutoCorrect( sal_Int32 nSttPos = 0 );

Expand Down Expand Up @@ -332,7 +332,7 @@ OUString SwAutoFormat::GoNextPara()
bool SwAutoFormat::HasObjects( const SwNode& rNd )
{
// Is there something bound to the paragraph in the paragraph
// like borders, DrawObjects, ...
// like Frames, DrawObjects, ...
bool bRet = false;
const SwFrameFormats& rFormats = *m_pDoc->GetSpzFrameFormats();
for( auto pFrameFormat : rFormats )
Expand Down Expand Up @@ -429,6 +429,13 @@ sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl
{
if( m_aFlags.bAFormatByInput )
{
// this is very non-obvious: on the *first* invocation of
// AutoFormat, the node will have the tabs (any number) converted
// to a fixed indent in BuildTextIndent(), and the number of tabs
// is stored in the node;
// on the *second* invocation of AutoFormat, CalcLevel() will
// retrieve the stored number, and it will be used by
// BuildHeadLine() to select the corresponding heading style.
nLvl = rNd.GetAutoFormatLvl();
const_cast<SwTextNode&>(rNd).SetAutoFormatLvl( 0 );
if( nLvl )
Expand Down Expand Up @@ -1054,7 +1061,7 @@ bool SwAutoFormat::IsSentenceAtEnd( const SwTextNode& rTextNd )
}

/// Delete beginning and/or end in a node
void SwAutoFormat::DeleteCurrentParagraph( bool bStart, bool bEnd )
void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
{
if( m_aFlags.bAFormatByInput
? m_aFlags.bAFormatByInpDelSpacesAtSttEnd
Expand Down Expand Up @@ -1114,7 +1121,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
m_pEditShell->DeleteSel( rDelPam );
}

bool SwAutoFormat::DeleteCurNxtPara( const OUString& rNxtPara )
bool SwAutoFormat::DeleteJoinCurNextPara( const OUString& rNxtPara )
{
// delete blanks at the end of the current and at the beginning of the next one
m_aDelPam.DeleteMark();
Expand Down Expand Up @@ -1220,8 +1227,7 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
}
}

// delete the previous paragraph
void SwAutoFormat::DelPrevPara()
void SwAutoFormat::JoinPrevPara()
{
m_aDelPam.DeleteMark();
m_aDelPam.GetPoint()->nNode = m_aNdIdx;
Expand Down Expand Up @@ -1262,7 +1268,7 @@ void SwAutoFormat::BuildIndent()
bBreak = !IsFastFullLine( *pNxtNd ) ||
IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ))
if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
Expand All @@ -1273,7 +1279,7 @@ void SwAutoFormat::BuildIndent()
!CalcLevel( *pNxtNd ) );
}
}
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();
AutoCorrect();
}

Expand Down Expand Up @@ -1302,7 +1308,7 @@ void SwAutoFormat::BuildTextIndent()
{
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) )
if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
Expand All @@ -1311,7 +1317,7 @@ void SwAutoFormat::BuildTextIndent()
pNxtNd = GetNextNode();
}
}
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();
AutoCorrect();
}

Expand All @@ -1336,7 +1342,7 @@ void SwAutoFormat::BuildText()
{
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) )
if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
Expand All @@ -1348,7 +1354,7 @@ void SwAutoFormat::BuildText()
break;
}
}
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();
AutoCorrect();
}

Expand Down Expand Up @@ -1381,7 +1387,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
IsBlanksInString( *m_pCurTextNd ) ||
IsSentenceAtEnd( *m_pCurTextNd );
bool bRTL = m_pEditShell->IsInRightToLeftText();
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();

bool bChgBullet = false, bChgEnum = false;
sal_Int32 nAutoCorrPos = 0;
Expand Down Expand Up @@ -1648,7 +1654,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) )
if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
Expand All @@ -1659,7 +1665,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
if(!pNxtNd || pCurrNode == pNxtNd)
break;
}
DeleteCurrentParagraph( false );
DeleteLeadingTrailingBlanks( false );
AutoCorrect( nAutoCorrPos );
}

Expand Down Expand Up @@ -1735,7 +1741,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
bBreak = !IsFastFullLine( *pNxtNd ) ||
IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) )
if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
Expand All @@ -1744,7 +1750,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
pNxtNd = GetNextNode();
}
}
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();
AutoCorrect();
}

Expand All @@ -1763,10 +1769,10 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
{
SwTextFormatColl& rNxtColl = m_pCurTextNd->GetTextColl()->GetNextTextFormatColl();

DelPrevPara();
JoinPrevPara();

DeleteCurrentParagraph( true, false );
(void)DeleteCurNxtPara( OUString() );
DeleteLeadingTrailingBlanks( true, false );
(void)DeleteJoinCurNextPara( OUString() );

m_aDelPam.DeleteMark();
m_aDelPam.GetPoint()->nNode = m_aNdIdx.GetIndex() + 1;
Expand All @@ -1775,7 +1781,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
}
else
{
DeleteCurrentParagraph();
DeleteLeadingTrailingBlanks();
AutoCorrect();
}
}
Expand Down Expand Up @@ -2157,16 +2163,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &

enum Format_Status
{
READ_NEXT_PARA,
TST_EMPTY_LINE,
TST_ALPHA_LINE,
GET_ALL_INFO,
IS_ONE_LINE,
TST_ENUMERIC,
TST_IDENT,
TST_NEG_IDENT,
TST_TXT_BODY,
HAS_FMTCOLL,
READ_NEXT_PARA, // -> ISEND, TST_EMPTY_LINE
TST_EMPTY_LINE, // -> READ_NEXT_PARA, TST_ALPHA_LINE
TST_ALPHA_LINE, // -> READ_NEXT_PARA, GET_ALL_INFO, IS_END
GET_ALL_INFO, // -> READ_NEXT_PARA, IS_ONE_LINE, TST_ENUMERIC, HAS_FMTCOLL
IS_ONE_LINE, // -> READ_NEXT_PARA, TST_ENUMERIC
TST_ENUMERIC, // -> READ_NEXT_PARA, TST_IDENT, TST_NEG_IDENT
TST_IDENT, // -> READ_NEXT_PARA, TST_TXT_BODY
TST_NEG_IDENT, // -> READ_NEXT_PARA, TST_TXT_BODY
TST_TXT_BODY, // -> READ_NEXT_PARA
HAS_FMTCOLL, // -> READ_NEXT_PARA
IS_END
} eStat;

Expand Down

0 comments on commit c1f1cad

Please sign in to comment.