X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/412e0d47c05d69cb029e9dbd11b31ce24fb2377e..77a1771911ed222ba6861ead327c3735fc16a0b1:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 3e4e08a5bf..3f714632a4 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -567,7 +567,9 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl if (firstParagraph) { wxRichTextObjectList::compatibility_iterator firstNode = m_children.Find(firstParagraph); - wxRichTextObjectList::compatibility_iterator previousNode = firstNode ? firstNode->GetPrevious() : wxRichTextObjectList::compatibility_iterator(); + wxRichTextObjectList::compatibility_iterator previousNode; + if ( firstNode ) + previousNode = firstNode->GetPrevious(); if (firstNode && previousNode) { wxRichTextParagraph* previousParagraph = wxDynamicCast(previousNode->GetData(), wxRichTextParagraph); @@ -589,10 +591,13 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl // Assume this box only contains paragraphs wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph); - wxASSERT (child != NULL); + wxCHECK_MSG( child, false, _T("Unknown object in layout") ); // TODO: what if the child hasn't been laid out (e.g. involved in Undo) but still has 'old' lines - if (child && !forceQuickLayout && (layoutAll || child->GetLines().GetCount() == 0 || !child->GetRange().IsOutside(invalidRange))) + if ( !forceQuickLayout && + (layoutAll || + child->GetLines().IsEmpty() || + !child->GetRange().IsOutside(invalidRange)) ) { child->Layout(dc, availableSpace, style); @@ -1130,8 +1135,6 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm return true; } - - return false; } /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'. @@ -1591,8 +1594,8 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxRichTextObjectList::compatibility_iterator firstNode = newPara->GetChildren().Find(firstObject); wxRichTextObjectList::compatibility_iterator lastNode = newPara->GetChildren().Find(lastObject); - wxASSERT(firstNode != NULL); - wxASSERT(lastNode != NULL); + wxASSERT(firstNode); + wxASSERT(lastNode); wxRichTextObjectList::compatibility_iterator node2 = firstNode; @@ -3409,7 +3412,7 @@ bool wxRichTextBuffer::BeginStyle(const wxTextAttrEx& style) /// End the style bool wxRichTextBuffer::EndStyle() { - if (m_attributeStack.GetFirst() == NULL) + if (!m_attributeStack.GetFirst()) { wxLogDebug(_("Too many EndStyle calls!")); return false; @@ -3851,6 +3854,7 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) wxTextDataObject data; wxTheClipboard->GetData(data); wxString text(data.GetText()); + text.Replace(_T("\r\n"), _T("\n")); InsertTextWithUndo(position+1, text, GetRichTextCtrl());