Don't take the previous paragraph style when deleting paragraph marker
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -213,6 +213,11 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
|
|||||||
#define wxTEXT_ATTR_EFFECTS 0x00800000
|
#define wxTEXT_ATTR_EFFECTS 0x00800000
|
||||||
#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000
|
#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000
|
||||||
|
|
||||||
|
// A special flag telling the buffer to keep the first paragraph style
|
||||||
|
// as-is, when deleting a paragraph marker. In future we might pass a
|
||||||
|
// flag to InsertFragment and DeleteRange to indicate the appropriate mode.
|
||||||
|
#define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Styles for wxTextAttrEx::SetBulletStyle
|
* Styles for wxTextAttrEx::SetBulletStyle
|
||||||
*/
|
*/
|
||||||
|
@@ -1175,7 +1175,8 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
|
|||||||
wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph);
|
wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph);
|
||||||
wxASSERT(firstPara != NULL);
|
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
|
// Save empty paragraph attributes for appending later
|
||||||
// These are character attributes deliberately set for a new paragraph. Without this,
|
// These are character attributes deliberately set for a new paragraph. Without this,
|
||||||
@@ -1251,7 +1252,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);
|
finalPara->SetAttributes(originalAttr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1450,6 +1453,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
|
|||||||
if (!obj->GetRange().IsOutside(range))
|
if (!obj->GetRange().IsOutside(range))
|
||||||
{
|
{
|
||||||
wxRichTextRange thisRange = obj->GetRange();
|
wxRichTextRange thisRange = obj->GetRange();
|
||||||
|
wxTextAttrEx thisAttr = obj->GetAttributes();
|
||||||
|
|
||||||
// Deletes the content of this object within the given range
|
// Deletes the content of this object within the given range
|
||||||
obj->DeleteRange(range);
|
obj->DeleteRange(range);
|
||||||
@@ -1486,7 +1490,14 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
|
|||||||
|
|
||||||
wxTextAttrEx nextParaAttr;
|
wxTextAttrEx nextParaAttr;
|
||||||
if (applyFinalParagraphStyle)
|
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)
|
if (firstPara && nextParagraph && firstPara != nextParagraph)
|
||||||
{
|
{
|
||||||
@@ -5000,17 +5011,19 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
|
|||||||
wxRichTextParagraph* para = GetParagraphAtPosition(pos, false);
|
wxRichTextParagraph* para = GetParagraphAtPosition(pos, false);
|
||||||
long pos1 = pos;
|
long pos1 = pos;
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
newPara->SetAttributes(*p);
|
||||||
|
|
||||||
if (flags & wxRICHTEXT_INSERT_INTERACTIVE)
|
if (flags & wxRICHTEXT_INSERT_INTERACTIVE)
|
||||||
{
|
{
|
||||||
if (para && para->GetRange().GetEnd() == pos)
|
if (para && para->GetRange().GetEnd() == pos)
|
||||||
pos1 ++;
|
pos1 ++;
|
||||||
|
if (newPara->GetAttributes().HasBulletNumber())
|
||||||
|
newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
action->SetPosition(pos);
|
action->SetPosition(pos);
|
||||||
|
|
||||||
if (p)
|
|
||||||
newPara->SetAttributes(*p);
|
|
||||||
|
|
||||||
// Use the default character style
|
// Use the default character style
|
||||||
if (!GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst())
|
if (!GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst())
|
||||||
{
|
{
|
||||||
@@ -5153,6 +5166,22 @@ bool wxRichTextBuffer::DeleteRangeWithUndo(const wxRichTextRange& range, wxRichT
|
|||||||
// Copy the fragment that we'll need to restore in Undo
|
// Copy the fragment that we'll need to restore in Undo
|
||||||
CopyFragment(range, action->GetOldParagraphs());
|
CopyFragment(range, action->GetOldParagraphs());
|
||||||
|
|
||||||
|
// 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* para = GetParagraphAtPosition(range.GetStart());
|
||||||
|
if (para && para->GetRange().GetEnd() == range.GetEnd())
|
||||||
|
{
|
||||||
|
wxRichTextParagraph* nextPara = GetParagraphAtPosition(range.GetStart()+1);
|
||||||
|
if (nextPara && nextPara != para)
|
||||||
|
{
|
||||||
|
action->GetOldParagraphs().GetChildren().GetFirst()->GetData()->SetAttributes(nextPara->GetAttributes());
|
||||||
|
action->GetOldParagraphs().GetAttributes().SetFlags(action->GetOldParagraphs().GetAttributes().GetFlags() | wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SubmitAction(action);
|
SubmitAction(action);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user