From: Julian Smart Date: Fri, 25 Feb 2011 12:21:56 +0000 (+0000) Subject: Applied #12601: Background color when saving wxRichText to HTML file X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5701f8338e4e2f98e4f72fa6cc939becd15f73c4 Applied #12601: Background color when saving wxRichText to HTML file git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index e720fb4496..7576075bc8 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -196,10 +196,27 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxRichTextAttr& curre } if (thisStyle.GetFontSize() != currentStyle.GetFontSize()) style += wxString::Format(wxT(" size=\"%ld\""), PtToSize(thisStyle.GetFontSize())); - if (thisStyle.GetTextColour() != currentStyle.GetTextColour() ) + + bool bTextColourChanged = (thisStyle.GetTextColour() != currentStyle.GetTextColour()); + bool bBackgroundColourChanged = (thisStyle.GetBackgroundColour() != currentStyle.GetBackgroundColour()); + if (bTextColourChanged || bBackgroundColourChanged) { - wxString color(thisStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX)); - style += wxString::Format(wxT(" color=\"%s\""), color.c_str()); + style += wxT(" style=\""); + + if (bTextColourChanged) + { + wxString color(thisStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX)); + style += wxString::Format(wxT("color: %s"), color.c_str()); + } + if (bTextColourChanged && bBackgroundColourChanged) + style += wxT(";"); + if (bBackgroundColourChanged) + { + wxString color(thisStyle.GetBackgroundColour().GetAsString(wxC2S_HTML_SYNTAX)); + style += wxString::Format(wxT("background-color: %s"), color.c_str()); + } + + style += wxT("\""); } if (style.size())