summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-11-22 17:47:08 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-01 08:44:45 +0100
commitc1f1cad3e63afcf6b9bbf6e42f28efa74ec49189 (patch)
tree75262585725e6606161d02b722ee8c9ca8852930 /sw
parent7058c016c5f1e4ac867db0852ca75d7e9fda2dc5 (diff)
sw: rename misleading DeleteCurrentParagraph()
Rename also DelPrevPara() and DeleteCurNxtPara(). Also document the state transitions. Change-Id: I0b874852a4c1aab8d5d3a55b9dfef360e313089c
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/edit/autofmt.cxx74
1 files changed, 40 insertions, 34 deletions
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index a466d3448ab7..f52f2b7aeddf 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -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 );
@@ -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 )
@@ -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 )
@@ -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
@@ -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();
@@ -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;
@@ -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(' ') );
}
@@ -1273,7 +1279,7 @@ void SwAutoFormat::BuildIndent()
!CalcLevel( *pNxtNd ) );
}
}
- DeleteCurrentParagraph();
+ DeleteLeadingTrailingBlanks();
AutoCorrect();
}
@@ -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(' ') );
}
@@ -1311,7 +1317,7 @@ void SwAutoFormat::BuildTextIndent()
pNxtNd = GetNextNode();
}
}
- DeleteCurrentParagraph();
+ DeleteLeadingTrailingBlanks();
AutoCorrect();
}
@@ -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(' ') );
}
@@ -1348,7 +1354,7 @@ void SwAutoFormat::BuildText()
break;
}
}
- DeleteCurrentParagraph();
+ DeleteLeadingTrailingBlanks();
AutoCorrect();
}
@@ -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;
@@ -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(' ') );
}
@@ -1659,7 +1665,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
if(!pNxtNd || pCurrNode == pNxtNd)
break;
}
- DeleteCurrentParagraph( false );
+ DeleteLeadingTrailingBlanks( false );
AutoCorrect( nAutoCorrPos );
}
@@ -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(' ') );
}
@@ -1744,7 +1750,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
pNxtNd = GetNextNode();
}
}
- DeleteCurrentParagraph();
+ DeleteLeadingTrailingBlanks();
AutoCorrect();
}
@@ -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;
@@ -1775,7 +1781,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
}
else
{
- DeleteCurrentParagraph();
+ DeleteLeadingTrailingBlanks();
AutoCorrect();
}
}
@@ -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;