From a3236d4c959035766701d5c2f1c6a5f3dd3c31ca Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Wed, 29 Oct 2003 13:48:21 +0000 Subject: [PATCH] Small refactoring of DocBook stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8003 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/buffer.C | 36 +++++++++--------------------------- src/insets/ChangeLog | 4 ++++ src/insets/insettext.C | 34 ++++++++-------------------------- src/sgml.C | 17 +++++++++++++++++ src/sgml.h | 7 +++++++ 6 files changed, 50 insertions(+), 53 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fccc3eae36..9ad09b612b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-10-29 Martin Vermeer + + * sgml.[Ch]: + * buffer.C: small refactoring of docbook stuff + 2003-10-29 Lars Gullik Bjønnes * dispatchresult.h: remove FINISHED_POP as FINISHED has the same diff --git a/src/buffer.C b/src/buffer.C index 8783c30d22..70ed34cfbf 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1765,12 +1765,9 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) // environment tag closing for (; depth > par->params().depth(); --depth) { - if (environment_inner[depth] != "!-- --" && !environment_inner[depth].empty()) { - item_name = "listitem"; - sgml::closeTag(ofs, command_depth + depth, false, item_name); - if (environment_inner[depth] == "varlistentry") - sgml::closeTag(ofs, depth+command_depth, false, environment_inner[depth]); - } + if (!environment_inner[depth].empty()) + sgml::closeEnvTags(ofs, false, environment_inner[depth], + command_depth + depth); sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]); environment_stack[depth].erase(); environment_inner[depth].erase(); @@ -1779,13 +1776,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) if (depth == par->params().depth() && environment_stack[depth] != style->latexname() && !environment_stack[depth].empty()) { - if (environment_inner[depth] != "!-- --") { - item_name= "listitem"; - sgml::closeTag(ofs, command_depth+depth, false, item_name); - if (environment_inner[depth] == "varlistentry") - sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]); - } - + sgml::closeEnvTags(ofs, false, environment_inner[depth], + command_depth + depth); sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]); environment_stack[depth].erase(); @@ -1872,12 +1864,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) environment_inner[depth] = "!-- --"; sgml::openTag(ofs, depth + command_depth, false, environment_stack[depth]); } else { - if (environment_inner[depth] != "!-- --") { - item_name= "listitem"; - sgml::closeTag(ofs, command_depth + depth, false, item_name); - if (environment_inner[depth] == "varlistentry") - sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]); - } + sgml::closeEnvTags(ofs, false, environment_inner[depth], + command_depth + depth); } if (style->latextype == LATEX_ENVIRONMENT) { @@ -1942,14 +1930,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) // Close open tags for (int d = depth; d >= 0; --d) { if (!environment_stack[depth].empty()) { - if (environment_inner[depth] != "!-- --") { - item_name = "listitem"; - sgml::closeTag(ofs, command_depth + depth, false, item_name); - if (environment_inner[depth] == "varlistentry") - sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]); - } - - sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]); + sgml::closeEnvTags(ofs, false, environment_inner[depth], + command_depth + depth); } } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index d2fcfbbd09..bfa50b00d7 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-10-29 Martin Vermeer + + * insettext.C: small refactoring of docbook stuff + 2003-10-29 Lars Gullik Bjønnes * insettext.C (lfunMouseRelease): dont use implicit conversion to bool diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 45125ded5f..3367401846 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -993,12 +993,8 @@ int InsetText::docbook(Buffer const & buf, ostream & os, bool mixcont) const // environment tag closing for (; depth > pit->params().depth(); --depth) { - if (environment_inner[depth] != "!-- --") { - item_name = "listitem"; - lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name); - if (environment_inner[depth] == "varlistentry") - lines += sgml::closeTag(os, depth+command_depth, mixcont, environment_inner[depth]); - } + lines += sgml::closeEnvTags(os, mixcont, environment_inner[depth], + command_depth + depth); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]); environment_stack[depth].erase(); environment_inner[depth].erase(); @@ -1007,13 +1003,8 @@ int InsetText::docbook(Buffer const & buf, ostream & os, bool mixcont) const if (depth == pit->params().depth() && environment_stack[depth] != style->latexname() && !environment_stack[depth].empty()) { - if (environment_inner[depth] != "!-- --") { - item_name= "listitem"; - lines += sgml::closeTag(os, command_depth+depth, mixcont, item_name); - if (environment_inner[depth] == "varlistentry") - lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]); - } - + lines += sgml::closeEnvTags(os, mixcont, environment_inner[depth], + command_depth + depth); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]); environment_stack[depth].erase(); @@ -1047,12 +1038,8 @@ int InsetText::docbook(Buffer const & buf, ostream & os, bool mixcont) const environment_inner[depth] = "!-- --"; lines += sgml::openTag(os, depth + command_depth, mixcont, environment_stack[depth]); } else { - if (environment_inner[depth] != "!-- --") { - item_name= "listitem"; - lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name); - if (environment_inner[depth] == "varlistentry") - lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]); - } + lines += sgml::closeEnvTags(os, mixcont, environment_inner[depth], + command_depth + depth); } if (style->latextype == LATEX_ENVIRONMENT) { @@ -1110,13 +1097,8 @@ int InsetText::docbook(Buffer const & buf, ostream & os, bool mixcont) const // Close open tags for (int d = depth; d >= 0; --d) { if (!environment_stack[depth].empty()) { - if (environment_inner[depth] != "!-- --") { - item_name = "listitem"; - lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name); - if (environment_inner[depth] == "varlistentry") - lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]); - } - + lines += sgml::closeEnvTags(os, mixcont, environment_inner[depth], + command_depth + depth); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]); } } diff --git a/src/sgml.C b/src/sgml.C index 6309fa0b2e..7d6c00a3ac 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -115,4 +115,21 @@ int closeTag(ostream & os, Paragraph::depth_type depth, return !mixcont; } + +unsigned int closeEnvTags(ostream & ofs, bool mixcont, + string const & environment_inner_depth, + lyx::depth_type total_depth) +{ + unsigned int lines; + if (environment_inner_depth != "!-- --") { + string item_name= "listitem"; + lines += closeTag(ofs, total_depth, mixcont, item_name); + if (environment_inner_depth == "varlistentry") + lines += closeTag(ofs, total_depth, mixcont, + environment_inner_depth); + } + return lines; +} + + } // namespace sgml diff --git a/src/sgml.h b/src/sgml.h index 73b23346c1..9abc886133 100644 --- a/src/sgml.h +++ b/src/sgml.h @@ -34,6 +34,13 @@ int openTag(std::ostream & os, lyx::depth_type depth, /// FIXME int closeTag(std::ostream & os, lyx::depth_type depth, bool mixcont, std::string const & latexname); + +/// +unsigned int closeEnvTags(std::ostream & os, + bool mixcont, + std::string const & environment_inner_depth, + lyx::depth_type total_depth); + } #endif // SGML_H