IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler)
+wxStringToStringHashMap wxRichTextXMLHandler::sm_nodeNameToClassMap;
+
void wxRichTextXMLHandler::Init()
{
#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
/// Creates an object given an XML element name
wxRichTextObject* wxRichTextXMLHandler::CreateObjectForXMLName(wxRichTextObject* WXUNUSED(parent), const wxString& name) const
{
- if (name == wxT("text") || name == wxT("symbol"))
- return new wxRichTextPlainText;
- else if (name == wxT("image"))
- return new wxRichTextImage;
- else if (name == wxT("paragraph"))
- return new wxRichTextParagraph;
- else if (name == wxT("paragraphlayout"))
- return new wxRichTextParagraphLayoutBox;
- else if (name == wxT("textbox"))
- return new wxRichTextBox;
- else if (name == wxT("cell"))
- return new wxRichTextCell;
- else if (name == wxT("table"))
- return new wxRichTextTable;
- else
+ // The standard node to class mappings are added in wxRichTextModule::OnInit in richtextbuffer.cpp
+ wxStringToStringHashMap::const_iterator it = sm_nodeNameToClassMap.find(name);
+ if (it == sm_nodeNameToClassMap.end())
return NULL;
+ else
+ return wxDynamicCast(wxCreateDynamicObject(it->second), wxRichTextObject);
}
/// Recursively import an object
}
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)
wxVariant var = MakePropertyFromString(name, value, type);
if (!var.IsNull())
{
- obj->GetProperties().SetProperty(var);
+ properties.SetProperty(var);
}
}
propertyChild = propertyChild->GetNext();
child = child->GetNext();
}
+ ImportProperties(def->GetProperties(), node);
+
sheet->AddCharacterStyle(def);
}
else if (styleType == wxT("paragraphstyle"))
child = child->GetNext();
}
+ ImportProperties(def->GetProperties(), node);
+
sheet->AddParagraphStyle(def);
}
else if (styleType == wxT("boxstyle"))
child = child->GetNext();
}
+ ImportProperties(def->GetProperties(), node);
+
sheet->AddBoxStyle(def);
}
else if (styleType == wxT("liststyle"))
child = child->GetNext();
}
+ ImportProperties(def->GetProperties(), node);
+
sheet->AddListStyle(def);
}
wxRichTextBoxStyleDefinition* def = buffer->GetStyleSheet()->GetBoxStyle(i);
ExportStyleDefinition(styleSheetNode, def);
}
+
+ WriteProperties(styleSheetNode, buffer->GetStyleSheet()->GetProperties());
}
bool success = ExportXML(rootNode, *buffer);
#if wxRICHTEXT_USE_OUTPUT_TIMINGS
ExportStyleDefinition(stream, def, level + 1);
}
+ WriteProperties(stream, buffer->GetStyleSheet()->GetProperties(), level);
+
OutputIndentation(stream, level);
OutputString(stream, wxT("</stylesheet>"));
}
OutputString(stream, wxT("</boxstyle>"));
}
+ WriteProperties(stream, def->GetProperties(), level);
return true;
}
if (!attr.GetListStyleName().empty())
AddAttribute(str, wxT("liststyle"), AttributeToXML(attr.GetListStyleName()));
+ if (!attr.GetTextBoxAttr().GetBoxStyleName().empty())
+ AddAttribute(str, wxT("boxstyle"), AttributeToXML(attr.GetTextBoxAttr().GetBoxStyleName()));
+
if (attr.HasTabs())
{
wxString strTabs;
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())
{
level ++;
OutputIndentation(stream, level);
- OutputString(stream, wxT("<properties"));
+ OutputString(stream, wxT("<properties>"));
level ++;
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 --;
}
AddAttributes(styleNode, def->GetStyle(), true);
}
+ WriteProperties(defNode, def->GetProperties());
+
return true;
}
if (!attr.GetListStyleName().empty())
node->AddAttribute(wxT("liststyle"), attr.GetListStyleName());
+ if (!attr.GetTextBoxAttr().GetBoxStyleName().empty())
+ node->AddAttribute(wxT("boxstyle"), attr.GetTextBoxAttr().GetBoxStyleName());
+
if (attr.HasTabs())
{
wxString tabs;
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())
{
attr.SetListStyleName(value);
}
}
+ else if (name == wxT("boxstyle"))
+ {
+ if (!value.empty())
+ {
+ attr.GetTextBoxAttr().SetBoxStyleName(value);
+ }
+ }
else if (name == wxT("tabs"))
{
if (!value.empty())
{
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"))
{
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