-2004-10-24 José Matos <jamatos@lyx.org>
+2004-10-24 José Matos <jamatos@lyx.org>
+
+ * buffer.C (makeLinuxDocFile, makeDocBookFile):
+ * output_docbook.C (makeParagraph, makeEnvironment, makeCommand):
+ * output_linuxdoc.C (linuxdocParagraphs):
+ * sgml.[Ch] (openTag): )move paragraph counting code to openTag, and
+ add buffer as argument.
+
+2004-10-24 José Matos <jamatos@lyx.org>
* output_docbook.C (makeEnvironment, searchEnvironment): place
CDATA inside paragraphs and fix scope for listitems.
ofs << ">\n\n";
if (params().options.empty())
- sgml::openTag(ofs, 0, false, top_element);
+ sgml::openTag(*this, ofs, 0, false, top_element);
else {
string top = top_element;
top += ' ';
top += params().options;
- sgml::openTag(ofs, 0, false, top);
+ sgml::openTag(*this, ofs, 0, false, top);
}
}
params().getLyXTextClass().counters().reset();
- sgml::openTag(ofs, 0, false, top);
+ sgml::openTag(*this, ofs, 0, false, top);
ofs << '\n';
docbookParagraphs(paragraphs(), *this, ofs, runparams);
sgml::closeTag(ofs, 0, false, top_element);
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend) {
ParagraphList::const_iterator par = pbegin;
- Counters & counters = buf.params().getLyXTextClass().counters();
const int depth = 0;
-
for(; par != pend; ++par) {
LyXLayout_ptr const & style = par->layout();
string id = par->getDocbookId();
-
- if (!style->latexparam().empty()) {
- counters.step("para");
- int i = counters.value("para");
- id = subst(style->latexparam(), "#", tostr(i));
- }
-
id = id.empty()? "": " id = \"" + id + "\"";
- sgml::openTag(os, depth, true, style->latexname(), id);
+
+ sgml::openTag(buf, os, depth, true, style->latexname(), id);
par->simpleDocBookOnePar(buf, os, outerFont(par - paragraphs.begin(), paragraphs), runparams, depth);
sgml::closeTag(os, depth, true, style->latexname());
ParagraphList::const_iterator const & pend) {
ParagraphList::const_iterator par = pbegin;
- Counters & counters = buf.params().getLyXTextClass().counters();
LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout();
const int depth = 0;
string id = par->getDocbookId();
string env_name = bstyle->latexname();
// Opening outter tag
- sgml::openTag(os, depth, false, env_name, bstyle->latexparam() + id);
+ sgml::openTag(buf, os, depth, false, env_name, bstyle->latexparam() + id);
os << '\n';
if (bstyle->latextype == LATEX_ENVIRONMENT and bstyle->innertag() == "CDATA")
os << "<![CDATA[";
switch (bstyle->latextype) {
case LATEX_ENVIRONMENT:
if (!bstyle->innertag().empty() and bstyle->innertag() != "CDATA") {
- sgml::openTag(os, depth, true, bstyle->innertag());
+ sgml::openTag(buf, os, depth, true, bstyle->innertag());
}
break;
case LATEX_ITEM_ENVIRONMENT:
if (!bstyle->labeltag().empty()) {
- sgml::openTag(os, depth, true, bstyle->labeltag());
+ sgml::openTag(buf, os, depth, true, bstyle->labeltag());
} else {
- if (!defaultstyle->latexparam().empty()) {
- counters.step("para");
- id = tostr(counters.value("para"));
- id = " id=\""+ subst(defaultstyle->latexparam(), "#", id) + '"';
- }
wrapper = defaultstyle->latexname();
- sgml::openTag(os, depth, true, bstyle->itemtag());
+ sgml::openTag(buf, os, depth, true, bstyle->itemtag());
}
default:
break;
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: {
if(par->params().depth() == pbegin->params().depth()) {
- sgml::openTag(os, depth, true, wrapper, id);
+ sgml::openTag(buf, os, depth, true, wrapper, id);
par->simpleDocBookOnePar(buf, os, outerFont(par - paragraphs.begin(), paragraphs), runparams, depth);
sgml::closeTag(os, depth, true, wrapper);
++par;
Paragraph::depth_type depth = 0; // paragraph depth
ParagraphList::const_iterator par = pbegin;
-
Counters & counters = buf.params().getLyXTextClass().counters();
LyXLayout_ptr const & bstyle = par->layout();
}
//Open outter tag
- sgml::openTag(os, depth, false, bstyle->latexname(), id);
+ sgml::openTag(buf, os, depth, false, bstyle->latexname(), id);
os << '\n';
// Label around sectioning number:
if (!bstyle->labeltag().empty()) {
- sgml::openTag(os, depth, false, bstyle->labeltag());
+ sgml::openTag(buf, os, depth, false, bstyle->labeltag());
os << expandLabel(buf.params().getLyXTextClass(), bstyle, false);
sgml::closeTag(os, depth, false, bstyle->labeltag());
}
// Opend inner tag
- sgml::openTag(os, depth, true, bstyle->innertag());
+ sgml::openTag(buf, os, depth, true, bstyle->innertag());
par->simpleDocBookOnePar(buf, os, outerFont(par - paragraphs.begin(), paragraphs),
runparams, depth);
InsetBase const * inset = pit->getInset(0);
if (inset->lyxCode() == InsetOld::TOC_CODE) {
string const temp = "toc";
- sgml::openTag(os, depth, false, temp);
+ sgml::openTag(buf, os, depth, false, temp);
continue;
}
}
else
os << "</p>";
}
- sgml::openTag(os, depth, false, style->latexname());
+ sgml::openTag(buf, os, depth, false, style->latexname());
break;
case LATEX_COMMAND:
}
environment_stack[depth].erase();
- sgml::openTag(os, depth, false, style->latexname());
+ sgml::openTag(buf, os, depth, false, style->latexname());
break;
case LATEX_ENVIRONMENT:
}
if (environment_stack[depth] != latexname) {
if (depth == 0) {
- sgml::openTag(os, depth, false, "p");
+ sgml::openTag(buf, os, depth, false, "p");
}
- sgml::openTag(os, depth, false, latexname);
+ sgml::openTag(buf, os, depth, false, latexname);
if (environment_stack.size() == depth + 1)
environment_stack.push_back("!-- --");
else
item_name = "item";
- sgml::openTag(os, depth + 1, false, item_name);
+ sgml::openTag(buf, os, depth + 1, false, item_name);
}
break;
default:
- sgml::openTag(os, depth, false, style->latexname());
+ sgml::openTag(buf, os, depth, false, style->latexname());
break;
}
#include <config.h>
-#include "support/std_ostream.h"
+#include "sgml.h"
+#include "buffer.h"
+#include "bufferparams.h"
+#include "counters.h"
+#include "lyxtext.h"
#include "paragraph.h"
-#include "sgml.h"
-using std::endl;
+#include "support/lstrings.h"
+#include "support/std_ostream.h"
+#include "support/tostr.h"
+
+using lyx::support::subst;
+
using std::make_pair;
using std::ostream;
}
-int openTag(ostream & os, Paragraph::depth_type depth,
- bool mixcont, string const & latexname,
- string const & latexparam)
+int openTag(Buffer const & buf, ostream & os, Paragraph::depth_type depth,
+ bool mixcont, string const & name, string const & param)
{
- if (!latexname.empty() && latexname != "!-- --") {
+ Counters & counters = buf.params().getLyXTextClass().counters();
+ LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout();
+
+ string attribute = param;
+ // code for paragraphs like the standard paragraph in AGU.
+ if ( defaultstyle->latexname() == name and !defaultstyle->latexparam().empty()) {
+ counters.step(name);
+ int i = counters.value(name);
+ attribute += "" + subst(defaultstyle->latexparam(), "#", tostr(i));
+ }
+
+ if (!name.empty() && name != "!-- --") {
if (!mixcont)
os << string(depth, ' ');
- os << '<' << latexname;
- if (!latexparam.empty())
- os << " " << latexparam;
+ os << '<' << name;
+ if (!attribute.empty())
+ os << " " << attribute;
os << '>';
}
int closeTag(ostream & os, Paragraph::depth_type depth,
- bool mixcont, string const & latexname)
+ bool mixcont, string const & name)
{
- if (!latexname.empty() && latexname != "!-- --") {
+ if (!name.empty() && name != "!-- --") {
if (!mixcont)
os << '\n' << string(depth, ' ');
- os << "</" << latexname << '>';
+ os << "</" << name << '>';
}
if (!mixcont)
#include <iosfwd>
#include <utility>
+class Buffer;
+
namespace sgml {
/**
- * Escape the given character if necessary
+ * Escape the given character, if necessary,
* to an SGML entity. Returns true
* if it was a whitespace character.
*/
std::pair<bool, std::string> escapeChar(char c);
-/// FIXME
-int openTag(std::ostream & os, lyx::depth_type depth,
- bool mixcont, std::string const & latexname,
- std::string const & latexparam = std::string());
+/// Opens tag
+int openTag(Buffer const & buf, std::ostream & os, lyx::depth_type depth,
+ bool mixcont, std::string const & name,
+ std::string const & param = std::string());
-/// FIXME
+/// Close tag
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,
- std::string const & item_tag,
- lyx::depth_type total_depth);
+ bool mixcont, std::string const & name);
}
-
#endif // SGML_H