X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31002e44b5b5d096f31216a1606dbfd8653c45cf..143591e943c40bd8264cca2a70d8d8688b224ba7:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 4ac92a5b52..84c330f04e 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -688,6 +688,7 @@ void wxRichTextParagraphLayoutBox::Copy(const wxRichTextParagraphLayoutBox& obj) wxRichTextBox::Copy(obj); m_partialParagraph = obj.m_partialParagraph; + m_defaultAttributes = obj.m_defaultAttributes; } /// Get/set the size for the given range. @@ -1429,8 +1430,6 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra wxRichTextObject* child = node->GetData(); if (!child->GetRange().IsOutside(range)) { -// if (lineCount > 0) -// text += wxT("\n"); wxRichTextRange childRange = range; childRange.LimitTo(child->GetRange()); @@ -1438,7 +1437,7 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra text += childText; - if (childRange.GetEnd() == child->GetRange().GetEnd()) + if ((childRange.GetEnd() == child->GetRange().GetEnd()) && node->GetNext()) text += wxT("\n"); lineCount ++; @@ -3152,7 +3151,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) int lineSpacing = 0; // Let's assume line spacing of 10 is normal, 15 is 1.5, 20 is 2, etc. - if (attr.GetLineSpacing() > 10 && attr.GetFont().Ok()) + if (attr.GetLineSpacing() != 10 && attr.GetFont().Ok()) { dc.SetFont(attr.GetFont()); lineSpacing = (ConvertTenthsMMToPixels(dc, dc.GetCharHeight()) * attr.GetLineSpacing())/10; @@ -5905,7 +5904,7 @@ public: wxRichTextBuffer::InitStandardHandlers(); wxRichTextParagraph::InitDefaultTabs(); return true; - }; + } void OnExit() { wxRichTextBuffer::CleanUpHandlers(); @@ -5913,7 +5912,7 @@ public: wxRichTextParagraph::ClearDefaultTabs(); wxRichTextCtrl::ClearAvailableFontNames(); wxRichTextBuffer::SetRenderer(NULL); - }; + } }; IMPLEMENT_DYNAMIC_CLASS(wxRichTextModule, wxModule) @@ -6324,7 +6323,7 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent m_ctrl->Refresh(false); if (sendUpdateEvent) - m_ctrl->SendTextUpdatedEvent(); + wxTextCtrl::SendTextUpdatedEvent(m_ctrl); } } } @@ -6563,6 +6562,9 @@ bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2, i attr1.GetFont().GetUnderlined() != attr2.GetFont().GetUnderlined()) return false; + if ((flags & wxTEXT_ATTR_URL) && attr1.GetURL() != attr2.GetURL()) + return false; + if ((flags & wxTEXT_ATTR_ALIGNMENT) && attr1.GetAlignment() != attr2.GetAlignment()) return false; @@ -6669,6 +6671,9 @@ bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2, attr1.GetFont().GetUnderlined() != attr2.GetFontUnderlined()) return false; + if ((flags & wxTEXT_ATTR_URL) && attr1.GetURL() != attr2.GetURL()) + return false; + if ((flags & wxTEXT_ATTR_ALIGNMENT) && attr1.GetAlignment() != attr2.GetAlignment()) return false; @@ -7902,7 +7907,7 @@ wxTextAttrEx wxTextAttrEx::CombineEx(const wxTextAttrEx& attr, IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject) -#if wxUSE_STREAMS +#if wxUSE_FFILE && wxUSE_STREAMS bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename) { wxFFileInputStream stream(filename); @@ -7920,7 +7925,7 @@ bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& f return false; } -#endif // wxUSE_STREAMS +#endif // wxUSE_FFILE && wxUSE_STREAMS /// Can we handle this filename (if using files)? By default, checks the extension. bool wxRichTextFileHandler::CanHandle(const wxString& filename) const @@ -8175,16 +8180,33 @@ bool wxRichTextImageBlock::Load(wxImage& image) // Write data in hex to a stream bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream) { - wxString hex; - int i; - for (i = 0; i < (int) m_dataSize; i++) + const int bufSize = 512; + char buf[bufSize+1]; + + int left = m_dataSize; + int n, i, j; + j = 0; + while (left > 0) { - hex = wxDecToHex(m_data[i]); - wxCharBuffer buf = hex.ToAscii(); + if (left*2 > bufSize) + { + n = bufSize; left -= (bufSize/2); + } + else + { + n = left*2; left = 0; + } - stream.Write((const char*) buf, hex.length()); - } + char* b = buf; + for (i = 0; i < (n/2); i++) + { + wxDecToHex(m_data[j], b, b+1); + b += 2; j ++; + } + buf[n] = 0; + stream.Write((const char*) buf, n); + } return true; } @@ -8196,13 +8218,13 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT if (m_data) delete[] m_data; - wxString str(wxT(" ")); + wxChar str[2]; m_data = new unsigned char[dataSize]; int i; for (i = 0; i < dataSize; i ++) { - str[0] = stream.GetC(); - str[1] = stream.GetC(); + str[0] = (char)stream.GetC(); + str[1] = (char)stream.GetC(); m_data[i] = (unsigned char)wxHexToDec(str); }