From ec2d9a2f8992e58ce2d28440c78594d1eecf1e28 Mon Sep 17 00:00:00 2001 From: JulianSmart Date: Sat, 14 Nov 2015 18:50:30 +0000 Subject: [PATCH] Ensure paragraph properties are preserved when inserting a fragment in wxRTC --- src/richtext/richtextbuffer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 79f80b37f9..ff189902f9 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -2881,6 +2881,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag if (para) { wxRichTextAttr originalAttr = para->GetAttributes(); + wxRichTextProperties originalProperties = para->GetProperties(); wxRichTextObjectList::compatibility_iterator node = m_children.Find(para); @@ -2950,7 +2951,10 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag wxASSERT(firstPara != NULL); if (!(fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE)) + { para->SetAttributes(firstPara->GetAttributes()); + para->SetProperties(firstPara->GetProperties()); + } // Save empty paragraph attributes for appending later // These are character attributes deliberately set for a new paragraph. Without this, @@ -3028,9 +3032,15 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag } if ((fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE) && firstPara) + { finalPara->SetAttributes(firstPara->GetAttributes()); + finalPara->SetProperties(firstPara->GetProperties()); + } else if (finalPara && finalPara != para) + { finalPara->SetAttributes(originalAttr); + finalPara->SetProperties(originalProperties); + } return true; }