On Tue, Oct 28, 2003 at 01:10:39PM +0000, Angus Leeming spake thusly: ... > The philosophy is that Buffer should be minimal but complete and that > we should provide free functions that operate on a Buffer instance. > Clearly this isn't the case at the moment but small steps... > > In this instance the free fuction is specific to sgml, so I'd put it > in the sgml.[Ch] file. > > -- > Angus
OK, so done. I plan to commit the attached later today. - Martin BTW does anyone have a large and complex LyX source file in the docbook class? The example is a bit thin :-( -- Martin Vermeer [EMAIL PROTECTED] Helsinki University of Technology Dept. of Surveying, Inst. of Geodesy P.O. Box 1200, FIN-02015 HUT, Finland :wq
Index: sgml.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/sgml.C,v retrieving revision 1.10 diff -u -p -r1.10 sgml.C --- sgml.C 6 Oct 2003 15:42:32 -0000 1.10 +++ sgml.C 29 Oct 2003 08:06:29 -0000 @@ -115,4 +115,21 @@ int closeTag(ostream & os, Paragraph::de 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 Index: sgml.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/sgml.h,v retrieving revision 1.9 diff -u -p -r1.9 sgml.h --- sgml.h 6 Oct 2003 15:42:32 -0000 1.9 +++ sgml.h 29 Oct 2003 08:06:29 -0000 @@ -34,6 +34,13 @@ int openTag(std::ostream & os, lyx::dept /// 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 Index: buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.534 diff -u -p -r1.534 buffer.C --- buffer.C 22 Oct 2003 14:40:24 -0000 1.534 +++ buffer.C 29 Oct 2003 08:06:29 -0000 @@ -1765,12 +1765,9 @@ void Buffer::makeDocBookFile(string cons // 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 cons 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 cons 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 cons // 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); } } Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.514 diff -u -p -r1.514 insettext.C --- insets/insettext.C 24 Oct 2003 09:45:07 -0000 1.514 +++ insets/insettext.C 29 Oct 2003 08:06:29 -0000 @@ -992,12 +992,8 @@ int InsetText::docbook(Buffer const & bu // 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(); @@ -1006,13 +1002,8 @@ int InsetText::docbook(Buffer const & bu 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(); @@ -1046,12 +1037,8 @@ int InsetText::docbook(Buffer const & bu 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) { @@ -1109,13 +1096,8 @@ int InsetText::docbook(Buffer const & bu // 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]); } }
pgp00000.pgp
Description: PGP signature