Make the standard paragraph an empty paragraph if its content allows it.

Fix bug 1708.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9143 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2004-10-30 13:05:31 +00:00
parent 8e27aa2fb7
commit 876a495c6b
4 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2004-10-30 José Matos <jamatos@lyx.org>
* output_docbook.C (makeParagraphs):
* paragraph.[Ch] (emptyTag): for docbook and company, if the
standard paragraph has only a given type of content drop the wrapper.
2004-10-29 José Matos <jamatos@lyx.org>
* output_docbook.C (makeEnvironment):

View File

@ -102,11 +102,16 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout();
for(ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
sgml::openTag(buf, os, *par);
par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
sgml::closeTag(os, *par);
os << '\n';
if (par->layout() == defaultstyle && par->emptyTag()) {
par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
} else {
sgml::openTag(buf, os, *par);
par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
sgml::closeTag(os, *par);
os << '\n';
}
}
return pend;
}

View File

@ -1331,6 +1331,31 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf,
}
bool Paragraph::emptyTag() const
{
for (pos_type i = 0; i < size(); ++i) {
if (isInset(i)) {
InsetBase const * inset = getInset(i);
InsetBase::Code lyx_code = inset->lyxCode();
if (lyx_code != InsetBase::TOC_CODE and
lyx_code != InsetBase::INCLUDE_CODE and
lyx_code != InsetBase::GRAPHICS_CODE and
lyx_code != InsetBase::ERT_CODE and
lyx_code != InsetBase::FLOAT_CODE and
lyx_code != InsetBase::TABULAR_CODE) {
return false;
}
} else {
char c = getChar(i);
if(c!= ' ' and c!= '\t')
return false;
}
}
return true;
}
string Paragraph::getID() const
{
for (pos_type i = 0; i < size(); ++i) {

View File

@ -122,13 +122,16 @@ public:
LyXFont const & outerfont, std::ostream &,
TexRow & texrow, OutputParams const &) const;
///
/// Writes to stream the content of the paragraph for linuxdoc
void simpleLinuxDocOnePar(Buffer const & buf,
std::ostream & os,
LyXFont const & outerfont,
OutputParams const & runparams,
lyx::depth_type depth) const;
/// Can we drop the standard paragraph wrapper?
bool Paragraph::emptyTag() const;
/// Get the id of the paragraph, usefull for docbook and linuxdoc
std::string getID() const;