]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextxml.cpp
Don't remove the last slash from "/" directory name under Unix.
[wxWidgets.git] / src / richtext / richtextxml.cpp
index a8d3894417aa7f8c1875bdacdb069054f8a4152c..e798ee5935a5349537038e3f5fe5315fc3b9acf3 100644 (file)
@@ -207,6 +207,11 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxRichTextObject*
 }
 
 bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* node)
+{
+    return ImportProperties(obj->GetProperties(), node);
+}
+
+bool wxRichTextXMLHandler::ImportProperties(wxRichTextProperties& properties, wxXmlNode* node)
 {
     wxXmlNode* child = node->GetChildren();
     while (child)
@@ -225,7 +230,7 @@ bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* no
                     wxVariant var = MakePropertyFromString(name, value, type);
                     if (!var.IsNull())
                     {
-                        obj->GetProperties().SetProperty(var);
+                        properties.SetProperty(var);
                     }
                 }
                 propertyChild = propertyChild->GetNext();
@@ -262,6 +267,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
             child = child->GetNext();
         }
 
+        ImportProperties(def->GetProperties(), node);
+
         sheet->AddCharacterStyle(def);
     }
     else if (styleType == wxT("paragraphstyle"))
@@ -284,6 +291,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
             child = child->GetNext();
         }
 
+        ImportProperties(def->GetProperties(), node);
+
         sheet->AddParagraphStyle(def);
     }
     else if (styleType == wxT("boxstyle"))
@@ -304,6 +313,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
             child = child->GetNext();
         }
 
+        ImportProperties(def->GetProperties(), node);
+
         sheet->AddBoxStyle(def);
     }
     else if (styleType == wxT("liststyle"))
@@ -339,6 +350,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
             child = child->GetNext();
         }
 
+        ImportProperties(def->GetProperties(), node);
+
         sheet->AddListStyle(def);
     }
 
@@ -835,6 +848,8 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
             wxRichTextBoxStyleDefinition* def = buffer->GetStyleSheet()->GetBoxStyle(i);
             ExportStyleDefinition(styleSheetNode, def);
         }
+
+        WriteProperties(styleSheetNode, buffer->GetStyleSheet()->GetProperties());
     }
     bool success = ExportXML(rootNode, *buffer);
 #if wxRICHTEXT_USE_OUTPUT_TIMINGS
@@ -910,6 +925,8 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
             ExportStyleDefinition(stream, def, level + 1);
         }
 
+        WriteProperties(stream, buffer->GetStyleSheet()->GetProperties(), level);
+
         OutputIndentation(stream, level);
         OutputString(stream, wxT("</stylesheet>"));
     }
@@ -1193,6 +1210,10 @@ wxString wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr& attr, bool is
     AddAttribute(str, wxT("outline"), attr.GetTextBoxAttr().GetOutline());
     AddAttribute(str, wxT("width"), attr.GetTextBoxAttr().GetWidth());
     AddAttribute(str, wxT("height"), attr.GetTextBoxAttr().GetHeight());
+    AddAttribute(str, wxT("minwidth"), attr.GetTextBoxAttr().GetMinSize().GetWidth());
+    AddAttribute(str, wxT("minheight"), attr.GetTextBoxAttr().GetMinSize().GetHeight());
+    AddAttribute(str, wxT("maxwidth"), attr.GetTextBoxAttr().GetMaxSize().GetWidth());
+    AddAttribute(str, wxT("maxheight"), attr.GetTextBoxAttr().GetMaxSize().GetHeight());
 
     if (attr.GetTextBoxAttr().HasVerticalAlignment())
     {
@@ -1262,7 +1283,7 @@ bool wxRichTextXMLHandler::WriteProperties(wxOutputStream& stream, const wxRichT
         level ++;
 
         OutputIndentation(stream, level);
-        OutputString(stream, wxT("<properties"));
+        OutputString(stream, wxT("<properties>"));
 
         level ++;
 
@@ -1279,14 +1300,14 @@ bool wxRichTextXMLHandler::WriteProperties(wxOutputStream& stream, const wxRichT
                 OutputString(stream, wxT("<property name=\"") + name +
                     wxT("\" type=\"") + var.GetType() + wxT("\" value=\""));
                 OutputStringEnt(stream, value);
-                OutputString(stream, wxT("\"/>\n"));
+                OutputString(stream, wxT("\"/>"));
             }
         }
 
         level --;
 
         OutputIndentation(stream, level);
-        OutputString(stream, wxT("</properties>\n"));
+        OutputString(stream, wxT("</properties>"));
 
         level --;
     }
@@ -1369,6 +1390,8 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxXmlNode* parent, wxRichTextSt
         AddAttributes(styleNode, def->GetStyle(), true);
     }
 
+    WriteProperties(defNode, def->GetProperties());
+
     return true;
 }
 
@@ -1484,6 +1507,10 @@ bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr,
     AddAttribute(node, wxT("outline"), attr.GetTextBoxAttr().GetOutline());
     AddAttribute(node, wxT("width"), attr.GetTextBoxAttr().GetWidth());
     AddAttribute(node, wxT("height"), attr.GetTextBoxAttr().GetHeight());
+    AddAttribute(node, wxT("minwidth"), attr.GetTextBoxAttr().GetMinSize().GetWidth());
+    AddAttribute(node, wxT("minheight"), attr.GetTextBoxAttr().GetMinSize().GetHeight());
+    AddAttribute(node, wxT("maxwidth"), attr.GetTextBoxAttr().GetMaxSize().GetWidth());
+    AddAttribute(node, wxT("maxheight"), attr.GetTextBoxAttr().GetMaxSize().GetHeight());
 
     if (attr.GetTextBoxAttr().HasVerticalAlignment())
     {
@@ -1863,6 +1890,22 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo
             {
                 attr.GetTextBoxAttr().GetHeight().SetValue(wxRichTextParseDimension(value));
             }
+            else if (name == wxT("minwidth"))
+            {
+                attr.GetTextBoxAttr().GetMinSize().GetWidth().SetValue(wxRichTextParseDimension(value));
+            }
+            else if (name == wxT("minheight"))
+            {
+                attr.GetTextBoxAttr().GetMinSize().GetHeight().SetValue(wxRichTextParseDimension(value));
+            }
+            else if (name == wxT("maxwidth"))
+            {
+                attr.GetTextBoxAttr().GetMaxSize().GetWidth().SetValue(wxRichTextParseDimension(value));
+            }
+            else if (name == wxT("maxheight"))
+            {
+                attr.GetTextBoxAttr().GetMaxSize().GetHeight().SetValue(wxRichTextParseDimension(value));
+            }
 
             else if (name == wxT("verticalalignment"))
             {
@@ -2508,6 +2551,7 @@ bool wxRichTextParagraphLayoutBox::ImportFromXML(wxRichTextBuffer* buffer, wxXml
 
             child2 = child2->GetNext();
         }
+        handler->ImportProperties(sheet->GetProperties(), child);
 
         // Notify that styles have changed. If this is vetoed by the app,
         // the new sheet will be deleted. If it is not vetoed, the