Small refactoring of DocBook stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8003 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2003-10-29 13:48:21 +00:00
parent 3df493e9d6
commit a3236d4c95
6 changed files with 50 additions and 53 deletions

View File

@ -1,3 +1,8 @@
2003-10-29 Martin Vermeer <martin.vermeer@hut.fi>
* sgml.[Ch]:
* buffer.C: small refactoring of docbook stuff
2003-10-29 Lars Gullik Bjønnes <larsbj@gullik.net>
* dispatchresult.h: remove FINISHED_POP as FINISHED has the same

View File

@ -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);
}
}

View File

@ -1,3 +1,7 @@
2003-10-29 Martin Vermeer <martin.vermeer@hut.fi>
* insettext.C: small refactoring of docbook stuff
2003-10-29 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (lfunMouseRelease): dont use implicit conversion to bool

View File

@ -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]);
}
}

View File

@ -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

View File

@ -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