diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-22 17:47:08 +0100 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-12-07 10:32:31 +0100 |
commit | 5450e84cd2a960745d6de4d1c0ba81e81e0f29fd (patch) | |
tree | f944b6ac95fa9ada9f4d0fb4ebadbb9828362dde | |
parent | 2c7e1591b997179952628965b3979230c0b6fd64 (diff) |
sw: rename misleading DeleteCurrentParagraph()
Rename also DelPrevPara() and DeleteCurNxtPara().
Also document the state transitions.
Change-Id: I0b874852a4c1aab8d5d3a55b9dfef360e313089c
(cherry picked from commit c1f1cad3e63afcf6b9bbf6e42f28efa74ec49189)
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 0b435c3a5f02..3c097ba576af 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -172,15 +172,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 ); @@ -333,7 +333,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 ) @@ -430,6 +430,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 ) @@ -1055,7 +1062,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 @@ -1115,7 +1122,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(); @@ -1221,8 +1228,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; @@ -1263,7 +1269,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(' ') ); } @@ -1274,7 +1280,7 @@ void SwAutoFormat::BuildIndent() !CalcLevel( *pNxtNd ) ); } } - DeleteCurrentParagraph(); + DeleteLeadingTrailingBlanks(); AutoCorrect(); } @@ -1303,7 +1309,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(' ') ); } @@ -1312,7 +1318,7 @@ void SwAutoFormat::BuildTextIndent() pNxtNd = GetNextNode(); } } - DeleteCurrentParagraph(); + DeleteLeadingTrailingBlanks(); AutoCorrect(); } @@ -1337,7 +1343,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(' ') ); } @@ -1349,7 +1355,7 @@ void SwAutoFormat::BuildText() break; } } - DeleteCurrentParagraph(); + DeleteLeadingTrailingBlanks(); AutoCorrect(); } @@ -1382,7 +1388,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; @@ -1649,7 +1655,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(' ') ); } @@ -1660,7 +1666,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) if(!pNxtNd || pCurrNode == pNxtNd) break; } - DeleteCurrentParagraph( false ); + DeleteLeadingTrailingBlanks( false ); AutoCorrect( nAutoCorrPos ); } @@ -1736,7 +1742,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(' ') ); } @@ -1745,7 +1751,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) pNxtNd = GetNextNode(); } } - DeleteCurrentParagraph(); + DeleteLeadingTrailingBlanks(); AutoCorrect(); } @@ -1764,10 +1770,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; @@ -1776,7 +1782,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) } else { - DeleteCurrentParagraph(); + DeleteLeadingTrailingBlanks(); AutoCorrect(); } } @@ -2158,16 +2164,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; |