Don't take the previous paragraph style when deleting paragraph marker
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1176,7 +1176,8 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
|
||||
wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph);
|
||||
wxASSERT(firstPara != NULL);
|
||||
|
||||
para->SetAttributes(firstPara->GetAttributes());
|
||||
if (!(fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE))
|
||||
para->SetAttributes(firstPara->GetAttributes());
|
||||
|
||||
// Save empty paragraph attributes for appending later
|
||||
// These are character attributes deliberately set for a new paragraph. Without this,
|
||||
@@ -1253,7 +1254,9 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
|
||||
}
|
||||
}
|
||||
|
||||
if (finalPara && finalPara != para)
|
||||
if ((fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE) && firstPara)
|
||||
finalPara->SetAttributes(firstPara->GetAttributes());
|
||||
else if (finalPara && finalPara != para)
|
||||
finalPara->SetAttributes(originalAttr);
|
||||
|
||||
return true;
|
||||
@@ -1455,6 +1458,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
|
||||
obj->DeleteRange(range);
|
||||
|
||||
wxRichTextRange thisRange = obj->GetRange();
|
||||
wxTextAttrEx thisAttr = obj->GetAttributes();
|
||||
|
||||
// If the whole paragraph is within the range to delete,
|
||||
// delete the whole thing.
|
||||
@@ -1488,7 +1492,14 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
|
||||
|
||||
wxTextAttrEx nextParaAttr;
|
||||
if (applyFinalParagraphStyle)
|
||||
nextParaAttr = nextParagraph->GetAttributes();
|
||||
{
|
||||
// Special case when deleting the end of a paragraph - use _this_ paragraph's style,
|
||||
// not the next one.
|
||||
if (range.GetStart() == range.GetEnd() && range.GetStart() == thisRange.GetEnd())
|
||||
nextParaAttr = thisAttr;
|
||||
else
|
||||
nextParaAttr = nextParagraph->GetAttributes();
|
||||
}
|
||||
|
||||
if (firstPara && nextParagraph && firstPara != nextParagraph)
|
||||
{
|
||||
@@ -4934,17 +4945,19 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
|
||||
wxRichTextParagraph* para = GetParagraphAtPosition(pos, false);
|
||||
long pos1 = pos;
|
||||
|
||||
if (p)
|
||||
newPara->SetAttributes(*p);
|
||||
|
||||
if (flags & wxRICHTEXT_INSERT_INTERACTIVE)
|
||||
{
|
||||
if (para && para->GetRange().GetEnd() == pos)
|
||||
pos1 ++;
|
||||
if (newPara->GetAttributes().HasBulletNumber())
|
||||
newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1);
|
||||
}
|
||||
|
||||
action->SetPosition(pos);
|
||||
|
||||
if (p)
|
||||
newPara->SetAttributes(*p);
|
||||
|
||||
// Use the default character style
|
||||
// Use the default character style
|
||||
if (!GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst())
|
||||
@@ -5088,22 +5101,18 @@ bool wxRichTextBuffer::DeleteRangeWithUndo(const wxRichTextRange& range, wxRichT
|
||||
// Copy the fragment that we'll need to restore in Undo
|
||||
CopyFragment(range, action->GetOldParagraphs());
|
||||
|
||||
// Special case: if there is only one (non-partial) paragraph,
|
||||
// we must save the *next* paragraph's style, because that
|
||||
// is the style we must apply when inserting the content back
|
||||
// when undoing the delete. (This is because we're merging the
|
||||
// paragraph with the previous paragraph and throwing away
|
||||
// the style, and we need to restore it.)
|
||||
if (!action->GetOldParagraphs().GetPartialParagraph() && action->GetOldParagraphs().GetChildCount() == 1)
|
||||
// See if we're deleting a paragraph marker, in which case we need to
|
||||
// make a note not to copy the attributes from the 2nd paragraph to the 1st.
|
||||
if (range.GetStart() == range.GetEnd())
|
||||
{
|
||||
wxRichTextParagraph* lastPara = GetParagraphAtPosition(range.GetStart());
|
||||
if (lastPara)
|
||||
wxRichTextParagraph* para = GetParagraphAtPosition(range.GetStart());
|
||||
if (para && para->GetRange().GetEnd() == range.GetEnd())
|
||||
{
|
||||
wxRichTextParagraph* nextPara = GetParagraphAtPosition(range.GetEnd()+1);
|
||||
if (nextPara)
|
||||
wxRichTextParagraph* nextPara = GetParagraphAtPosition(range.GetStart()+1);
|
||||
if (nextPara && nextPara != para)
|
||||
{
|
||||
wxRichTextParagraph* para = (wxRichTextParagraph*) action->GetOldParagraphs().GetChild(0);
|
||||
para->SetAttributes(nextPara->GetAttributes());
|
||||
action->GetOldParagraphs().GetChildren().GetFirst()->GetData()->SetAttributes(nextPara->GetAttributes());
|
||||
action->GetOldParagraphs().GetAttributes().SetFlags(action->GetOldParagraphs().GetAttributes().GetFlags() | wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user