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

sw: rename misleading DeleteCurrentParagraph()

Rename also DelPrevPara() and DeleteCurNxtPara().

Also document the state transitions.

Change-Id: I0b874852a4c1aab8d5d3a55b9dfef360e313089c
üst 7058c016
...@@ -171,15 +171,15 @@ class SwAutoFormat ...@@ -171,15 +171,15 @@ 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 );
bool DeleteCurNxtPara( 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 DeleteCurrentParagraph( bool bStart = true, bool bEnd = true ); void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
void DelEmptyLine( bool bTstNextPara = true ); void DelEmptyLine( bool bTstNextPara = true );
/// when using multiline paragraphs delete the "left" and/or /// when using multiline paragraphs delete the "left" and/or
/// "right" margins /// "right" margins
void DelMoreLinesBlanks( bool bWithLineBreaks = false ); void DelMoreLinesBlanks( bool bWithLineBreaks = false );
/// delete the previous paragraph /// join with the previous paragraph
void DelPrevPara(); void JoinPrevPara();
/// execute AutoCorrect on current TextNode /// execute AutoCorrect on current TextNode
void AutoCorrect( sal_Int32 nSttPos = 0 ); void AutoCorrect( sal_Int32 nSttPos = 0 );
...@@ -332,7 +332,7 @@ OUString SwAutoFormat::GoNextPara() ...@@ -332,7 +332,7 @@ OUString SwAutoFormat::GoNextPara()
bool SwAutoFormat::HasObjects( const SwNode& rNd ) bool SwAutoFormat::HasObjects( const SwNode& rNd )
{ {
// Is there something bound to the paragraph in the paragraph // Is there something bound to the paragraph in the paragraph
// like borders, DrawObjects, ... // like Frames, DrawObjects, ...
bool bRet = false; bool bRet = false;
const SwFrameFormats& rFormats = *m_pDoc->GetSpzFrameFormats(); const SwFrameFormats& rFormats = *m_pDoc->GetSpzFrameFormats();
for( auto pFrameFormat : rFormats ) for( auto pFrameFormat : rFormats )
...@@ -429,6 +429,13 @@ sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl ...@@ -429,6 +429,13 @@ sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl
{ {
if( m_aFlags.bAFormatByInput ) 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(); nLvl = rNd.GetAutoFormatLvl();
const_cast<SwTextNode&>(rNd).SetAutoFormatLvl( 0 ); const_cast<SwTextNode&>(rNd).SetAutoFormatLvl( 0 );
if( nLvl ) if( nLvl )
...@@ -1054,7 +1061,7 @@ bool SwAutoFormat::IsSentenceAtEnd( const SwTextNode& rTextNd ) ...@@ -1054,7 +1061,7 @@ bool SwAutoFormat::IsSentenceAtEnd( const SwTextNode& rTextNd )
} }
/// Delete beginning and/or end in a node /// 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 if( m_aFlags.bAFormatByInput
? m_aFlags.bAFormatByInpDelSpacesAtSttEnd ? m_aFlags.bAFormatByInpDelSpacesAtSttEnd
...@@ -1114,7 +1121,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam ) ...@@ -1114,7 +1121,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
m_pEditShell->DeleteSel( 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 // delete blanks at the end of the current and at the beginning of the next one
m_aDelPam.DeleteMark(); m_aDelPam.DeleteMark();
...@@ -1220,8 +1227,7 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks ) ...@@ -1220,8 +1227,7 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
} }
} }
// delete the previous paragraph void SwAutoFormat::JoinPrevPara()
void SwAutoFormat::DelPrevPara()
{ {
m_aDelPam.DeleteMark(); m_aDelPam.DeleteMark();
m_aDelPam.GetPoint()->nNode = m_aNdIdx; m_aDelPam.GetPoint()->nNode = m_aNdIdx;
...@@ -1262,7 +1268,7 @@ void SwAutoFormat::BuildIndent() ...@@ -1262,7 +1268,7 @@ void SwAutoFormat::BuildIndent()
bBreak = !IsFastFullLine( *pNxtNd ) || bBreak = !IsFastFullLine( *pNxtNd ) ||
IsBlanksInString( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd ); IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() )) if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{ {
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') ); m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
} }
...@@ -1273,7 +1279,7 @@ void SwAutoFormat::BuildIndent() ...@@ -1273,7 +1279,7 @@ void SwAutoFormat::BuildIndent()
!CalcLevel( *pNxtNd ) ); !CalcLevel( *pNxtNd ) );
} }
} }
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
AutoCorrect(); AutoCorrect();
} }
...@@ -1302,7 +1308,7 @@ void SwAutoFormat::BuildTextIndent() ...@@ -1302,7 +1308,7 @@ void SwAutoFormat::BuildTextIndent()
{ {
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd ); IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) ) if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{ {
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') ); m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
} }
...@@ -1311,7 +1317,7 @@ void SwAutoFormat::BuildTextIndent() ...@@ -1311,7 +1317,7 @@ void SwAutoFormat::BuildTextIndent()
pNxtNd = GetNextNode(); pNxtNd = GetNextNode();
} }
} }
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
AutoCorrect(); AutoCorrect();
} }
...@@ -1336,7 +1342,7 @@ void SwAutoFormat::BuildText() ...@@ -1336,7 +1342,7 @@ void SwAutoFormat::BuildText()
{ {
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd ); IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) ) if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{ {
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') ); m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
} }
...@@ -1348,7 +1354,7 @@ void SwAutoFormat::BuildText() ...@@ -1348,7 +1354,7 @@ void SwAutoFormat::BuildText()
break; break;
} }
} }
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
AutoCorrect(); AutoCorrect();
} }
...@@ -1381,7 +1387,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) ...@@ -1381,7 +1387,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
IsBlanksInString( *m_pCurTextNd ) || IsBlanksInString( *m_pCurTextNd ) ||
IsSentenceAtEnd( *m_pCurTextNd ); IsSentenceAtEnd( *m_pCurTextNd );
bool bRTL = m_pEditShell->IsInRightToLeftText(); bool bRTL = m_pEditShell->IsInRightToLeftText();
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
bool bChgBullet = false, bChgEnum = false; bool bChgBullet = false, bChgEnum = false;
sal_Int32 nAutoCorrPos = 0; sal_Int32 nAutoCorrPos = 0;
...@@ -1648,7 +1654,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) ...@@ -1648,7 +1654,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES ); SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd ); IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) ) if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{ {
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') ); m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
} }
...@@ -1659,7 +1665,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) ...@@ -1659,7 +1665,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
if(!pNxtNd || pCurrNode == pNxtNd) if(!pNxtNd || pCurrNode == pNxtNd)
break; break;
} }
DeleteCurrentParagraph( false ); DeleteLeadingTrailingBlanks( false );
AutoCorrect( nAutoCorrPos ); AutoCorrect( nAutoCorrPos );
} }
...@@ -1735,7 +1741,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) ...@@ -1735,7 +1741,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
bBreak = !IsFastFullLine( *pNxtNd ) || bBreak = !IsFastFullLine( *pNxtNd ) ||
IsBlanksInString( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
IsSentenceAtEnd( *pNxtNd ); IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetText() ) ) if (DeleteJoinCurNextPara(pNxtNd->GetText()))
{ {
m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') ); m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
} }
...@@ -1744,7 +1750,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) ...@@ -1744,7 +1750,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
pNxtNd = GetNextNode(); pNxtNd = GetNextNode();
} }
} }
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
AutoCorrect(); AutoCorrect();
} }
...@@ -1763,10 +1769,10 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) ...@@ -1763,10 +1769,10 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
{ {
SwTextFormatColl& rNxtColl = m_pCurTextNd->GetTextColl()->GetNextTextFormatColl(); SwTextFormatColl& rNxtColl = m_pCurTextNd->GetTextColl()->GetNextTextFormatColl();
DelPrevPara(); JoinPrevPara();
DeleteCurrentParagraph( true, false ); DeleteLeadingTrailingBlanks( true, false );
(void)DeleteCurNxtPara( OUString() ); (void)DeleteJoinCurNextPara( OUString() );
m_aDelPam.DeleteMark(); m_aDelPam.DeleteMark();
m_aDelPam.GetPoint()->nNode = m_aNdIdx.GetIndex() + 1; m_aDelPam.GetPoint()->nNode = m_aNdIdx.GetIndex() + 1;
...@@ -1775,7 +1781,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) ...@@ -1775,7 +1781,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
} }
else else
{ {
DeleteCurrentParagraph(); DeleteLeadingTrailingBlanks();
AutoCorrect(); AutoCorrect();
} }
} }
...@@ -2157,16 +2163,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const & ...@@ -2157,16 +2163,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
enum Format_Status enum Format_Status
{ {
READ_NEXT_PARA, READ_NEXT_PARA, // -> ISEND, TST_EMPTY_LINE
TST_EMPTY_LINE, TST_EMPTY_LINE, // -> READ_NEXT_PARA, TST_ALPHA_LINE
TST_ALPHA_LINE, TST_ALPHA_LINE, // -> READ_NEXT_PARA, GET_ALL_INFO, IS_END
GET_ALL_INFO, GET_ALL_INFO, // -> READ_NEXT_PARA, IS_ONE_LINE, TST_ENUMERIC, HAS_FMTCOLL
IS_ONE_LINE, IS_ONE_LINE, // -> READ_NEXT_PARA, TST_ENUMERIC
TST_ENUMERIC, TST_ENUMERIC, // -> READ_NEXT_PARA, TST_IDENT, TST_NEG_IDENT
TST_IDENT, TST_IDENT, // -> READ_NEXT_PARA, TST_TXT_BODY
TST_NEG_IDENT, TST_NEG_IDENT, // -> READ_NEXT_PARA, TST_TXT_BODY
TST_TXT_BODY, TST_TXT_BODY, // -> READ_NEXT_PARA
HAS_FMTCOLL, HAS_FMTCOLL, // -> READ_NEXT_PARA
IS_END IS_END
} eStat; } eStat;
......
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