+bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextStyleDefinition* def, int level)
+{
+ wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
+ wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
+ wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
+
+ wxString baseStyle = def->GetBaseStyle();
+ wxString baseStyleProp;
+ if (!baseStyle.IsEmpty())
+ baseStyleProp = wxT(" basestyle=\"") + baseStyle + wxT("\"");
+
+ wxString descr = def->GetDescription();
+ wxString descrProp;
+ if (!descr.IsEmpty())
+ descrProp = wxT(" description=\"") + descr + wxT("\"");
+
+ if (charDef)
+ {
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("<characterstyle") + baseStyleProp + descrProp + wxT(">"), convMem, convFile);
+
+ level ++;
+
+ wxString style = CreateStyle(def->GetStyle(), false);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("<style ") + style + wxT(">"), convMem, convFile);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</style>"), convMem, convFile);
+
+ level --;
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</characterstyle>"), convMem, convFile);
+ }
+ else if (listDef)
+ {
+ OutputIndentation(stream, level);
+
+ if (!listDef->GetNextStyle().IsEmpty())
+ baseStyleProp << wxT(" basestyle=\"") << listDef->GetNextStyle() << wxT("\"");
+
+ OutputString(stream, wxT("<liststyle") + baseStyleProp + descrProp + wxT(">"), convMem, convFile);
+
+ level ++;
+
+ wxString style = CreateStyle(def->GetStyle(), false);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("<style ") + style + wxT(">"), convMem, convFile);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</style>"), convMem, convFile);
+
+ int i;
+ for (i = 0; i < 10; i ++)
+ {
+ wxTextAttr* levelAttr = listDef->GetLevelAttributes(i);
+ if (levelAttr)
+ {
+ wxString style = CreateStyle(def->GetStyle(), false);
+ wxString levelStr = wxString::Format(wxT(" level=\"%d\" "), (i+1));
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("<style ") + levelStr + style + wxT(">"), convMem, convFile);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</style>"), convMem, convFile);
+ }
+ }
+
+ level --;
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</liststyle>"), convMem, convFile);
+ }
+ else if (paraDef)
+ {
+ OutputIndentation(stream, level);
+
+ if (!paraDef->GetNextStyle().IsEmpty())
+ baseStyleProp << wxT(" basestyle=\"") << paraDef->GetNextStyle() << wxT("\"");
+
+ OutputString(stream, wxT("<paragraphstyle") + baseStyleProp + descrProp + wxT(">"), convMem, convFile);
+
+ level ++;
+
+ wxString style = CreateStyle(def->GetStyle(), false);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("<style ") + style + wxT(">"), convMem, convFile);
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</style>"), convMem, convFile);
+
+ level --;
+
+ OutputIndentation(stream, level);
+ OutputString(stream, wxT("</paragraphstyle>"), convMem, convFile);
+ }
+
+ return true;
+}
+