]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextxml.cpp
generate size event when the dialog is shown for consistency with frames and other...
[wxWidgets.git] / src / richtext / richtextxml.cpp
index 8b914fb646eefc773d33eb313451f47866b2e7f8..74d6bbf9d70103bc042ae2e3abc434fb65965175 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef WX_PRECOMP
     #include "wx/intl.h"
     #include "wx/module.h"
+    #include "wx/log.h"
 #endif
 
 #include "wx/filename.h"
@@ -172,10 +173,18 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
             }
             else if (childName == wxT("image"))
             {
-                int imageType = wxBITMAP_TYPE_PNG;
+                wxBitmapType imageType = wxBITMAP_TYPE_PNG;
                 wxString value = node->GetAttribute(wxT("imagetype"), wxEmptyString);
                 if (!value.empty())
-                    imageType = wxAtoi(value);
+                {
+                    int type = wxAtoi(value);
+
+                    // note: 0 == wxBITMAP_TYPE_INVALID
+                    if (type <= 0 || type >= wxBITMAP_TYPE_MAX)
+                        wxLogWarning("Invalid bitmap type specified for <image> tag: %d", type);
+                    else
+                        imageType = (wxBitmapType)type;
+                }
 
                 wxString data;
 
@@ -706,10 +715,19 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem,
         int last = 0;
         const wxString& text = textObj.GetText();
         int len = (int) text.Length();
-        for (i = 0; i < len; i++)
+
+        if (len == 0)
+        {
+            i = 0;
+            OutputIndentation(stream, indent);
+            OutputString(stream, wxT("<") + objectName, convMem, convFile);
+            OutputString(stream, style + wxT(">"), convMem, convFile);
+            OutputString(stream, wxT("</text>"), convMem, convFile);
+        }
+        else for (i = 0; i < len; i++)
         {
             int c = (int) text[i];
-            if (c < 32 && c != 9 && c != 10 && c != 13)
+            if ((c < 32 || c == 34) && c != 9 && c != 10 && c != 13)
             {
                 if (i > 0)
                 {