+2004-10-30 José Matos <jamatos@lyx.org>
+
+ * paragraph.[Ch] (onlyText): Checks if the paragraph contains only
+ text and no inset or font change. This allows to use CDATA
+ sections just for the whole paragraph.
+
2004-10-30 José Matos <jamatos@lyx.org>
* paragraph.C (getFirstWord): remove unused variable.
+2004-10-30 José Matos <jamatos@lyx.org>
+
+ * insetcharstyle.C (docbook): a compromisse solution. Don't output
+ paragraph tags inside inline elements.
+
2004-10-30 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetcharstyle.C (latex, linuxdoc, docbook, plaintext): use
#include "lyxtext.h"
#include "metricsinfo.h"
#include "paragraph.h"
+#include "paragraph_funcs.h"
#include "sgml.h"
#include "frontends/font_metrics.h"
int InsetCharStyle::docbook(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
- sgml::openTag(os, params_.latexname, params_.latexparam);
- int i = InsetText::docbook(buf, os, runparams);
+ ParagraphList::const_iterator par = paragraphs().begin();
+ ParagraphList::const_iterator end = paragraphs().end();
+
+ sgml::openTag(os, params_.latexname, par->getID() + params_.latexparam);
+
+ for (; par != end; ++par) {
+ par->simpleDocBookOnePar(buf, os, runparams,
+ outerFont(par - paragraphs().begin(),
+ paragraphs()));
+ }
+
sgml::closeTag(os, params_.latexname);
- return i;
+ return 0;
}
return i;
}
+
+bool Paragraph::onlyText(Buffer const & buf, LyXFont const & outerfont, pos_type initial) const
+{
+ LyXLayout_ptr const & style = layout();
+ LyXFont font_old;
+
+ for (pos_type i = initial; i < size(); ++i) {
+ LyXFont font = getFont(buf.params(), i, outerfont);
+ if (isInset(i))
+ return false;
+ if ( i != initial and font != font_old)
+ return false;
+ font_old = font;
+ }
+
+ return true;
+}
+
+
void Paragraph::simpleDocBookOnePar(Buffer const & buf,
ostream & os,
OutputParams const & runparams,
LyXFont font_old =
style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
- bool cdata = style->pass_thru;
+ if (style->pass_thru and not onlyText(buf, outerfont, initial))
+ os << "]]>";
// parsing main loop
for (pos_type i = initial; i < size(); ++i) {
LyXFont font = getFont(buf.params(), i, outerfont);
// handle <emphasis> tag
if (font_old.emph() != font.emph()) {
if (font.emph() == LyXFont::ON) {
- if (cdata)
- os << "]]>";
os << "<emphasis>";
- if (cdata)
- os << "<![CDATA[";
emph_flag = true;
} else if (i != initial) {
- if (cdata)
- os << "]]>";
os << "</emphasis>";
- if (cdata)
- os << "<![CDATA[";
emph_flag = false;
}
}
if (isInset(i)) {
InsetBase const * inset = getInset(i);
- if (cdata)
- os << "]]>";
inset->docbook(buf, os, runparams);
- if (cdata)
- os << "<![CDATA[";
} else {
char c = getChar(i);
bool ws;
}
if (emph_flag) {
- if (cdata)
- os << "]]>";
os << "</emphasis>";
- if (cdata)
- os << "<![CDATA[";
}
if (style->free_spacing)
os << '\n';
+ if (style->pass_thru and not onlyText(buf, outerfont, initial))
+ os << "<![CDATA[";
}
std::ostream & os,
OutputParams const & runparams) const;
+ /// Checks if the paragraph contains only text and no inset or font change.
+ bool onlyText(Buffer const & buf, LyXFont const & outerfont,
+ lyx::pos_type initial) const;
+
/// Writes to stream the docbook representation
void simpleDocBookOnePar(Buffer const & buf,
std::ostream &,