X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fparagraph.C;h=9dce9f546ec3599fe3a5f67f9882e5cb51f19e77;hb=69bee02a8901793b34ac5ca6d07e93910cef4005;hp=4176e2f9309ee997bca432e568430309c6960c57;hpb=3159d1a52e777f62531932edc010bf5f8b9d6d59;p=lyx.git diff --git a/src/paragraph.C b/src/paragraph.C index 4176e2f930..9dce9f546e 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -22,6 +22,7 @@ #include "buffer.h" #include "bufferparams.h" +#include "counters.h" #include "encoding.h" #include "debug.h" #include "gettext.h" @@ -39,10 +40,12 @@ #include "insets/insetoptarg.h" #include "support/lstrings.h" -#include "support/textutils.h" #include "support/std_sstream.h" +#include "support/textutils.h" +#include "support/tostr.h" #include +#include #include #include @@ -268,10 +271,8 @@ void Paragraph::insert(pos_type start, string const & str, } -bool Paragraph::checkInsertChar(LyXFont & font) +bool Paragraph::checkInsertChar(LyXFont &) { - if (pimpl_->inset_owner) - return pimpl_->inset_owner->checkInsertChar(font); return true; } @@ -590,9 +591,7 @@ int Paragraph::stripLeadingSpaces() bool Paragraph::hasSameLayout(Paragraph const & par) const { - return - par.layout() == layout() && - params().sameLayout(par.params()); + return par.layout() == layout() && params().sameLayout(par.params()); } @@ -644,8 +643,6 @@ void Paragraph::applyLayout(LyXLayout_ptr const & new_layout) layout(new_layout); params().labelWidthString(string()); params().align(LYX_ALIGN_LAYOUT); - params().spaceTop(VSpace(VSpace::NONE)); - params().spaceBottom(VSpace(VSpace::NONE)); params().spacing(Spacing(Spacing::Default)); } @@ -706,17 +703,19 @@ int Paragraph::getPositionOfInset(InsetOld const * inset) const InsetBibitem * Paragraph::bibitem() const { - InsetList::const_iterator it = insetlist.begin(); - if (it != insetlist.end() && it->inset->lyxCode() == InsetOld::BIBTEX_CODE) - return static_cast(it->inset); + if (!insetlist.empty()) { + InsetOld * inset = insetlist.begin()->inset; + if (inset->lyxCode() == InsetOld::BIBTEX_CODE) + return static_cast(inset); + } return 0; } namespace { -/* paragraphs inside floats need different alignment tags to avoid -unwanted space */ +// paragraphs inside floats need different alignment tags to avoid +// unwanted space bool noTrivlistCentering(UpdatableInset const * inset) { @@ -1273,9 +1272,9 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, char c = getChar(i); + if (c == Paragraph::META_INSET) { - InsetOld const * inset = getInset(i); - inset->linuxdoc(buf, os, runparams); + getInset(i)->linuxdoc(buf, os, runparams); font_old = font; continue; } @@ -1292,8 +1291,7 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, if (ws && !isFreeSpacing()) { // in freespacing mode, spaces are // non-breaking characters - if (desc_on) {// if char is ' ' then... - + if (desc_on) { // if char is ' ' then... ++char_line_count; sgmlLineBreak(os, char_line_count, 6); os << ""; @@ -1327,19 +1325,44 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, void Paragraph::simpleDocBookOnePar(Buffer const & buf, ostream & os, LyXFont const & outerfont, - int & desc_on, OutputParams const & runparams, - lyx::depth_type depth) const + lyx::depth_type depth, + bool labelid) const { bool emph_flag = false; LyXLayout_ptr const & style = layout(); + LyXLayout_ptr const & defaultstyle = + buf.params().getLyXTextClass().defaultLayout(); - LyXFont font_old = (style->labeltype == LABEL_MANUAL ? style->labelfont : style->font); + LyXFont font_old = + style->labeltype == LABEL_MANUAL ? style->labelfont : style->font; int char_line_count = depth; - //if (!style.free_spacing) - // os << string(depth,' '); + bool label_closed = true; + bool para_closed = true; + + if (style->latextype == LATEX_ITEM_ENVIRONMENT) { + string ls = ""; + Counters & counters = buf.params().getLyXTextClass().counters(); + if (!style->free_spacing) + os << string(depth,' '); + if (!style->labeltag().empty()) { + os << "<" << style->labeltag() << ">\n"; + label_closed = false; + } else { + if (!defaultstyle->latexparam().empty()) { + counters.step("para"); + ls = tostr(counters.value("para")); + ls = " id=\"" + + subst(defaultstyle->latexparam(), "#", ls) + '"'; + } + os << "<" << style->itemtag() << ">\n" + << string(depth, ' ') << "<" + << defaultstyle->latexname() << ls << ">\n"; + para_closed = false; + } + } // parsing main loop for (pos_type i = 0; i < size(); ++i) { @@ -1368,7 +1391,8 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, if (isInset(i)) { InsetOld const * inset = getInset(i); // don't print the inset in position 0 if desc_on == 3 (label) - if (i || desc_on != 3) { + //if (i || desc_on != 3) { + if (!labelid) { if (style->latexparam() == "CDATA") os << "]]>"; inset->docbook(buf, os, runparams); @@ -1385,10 +1409,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, os << c; } else if (isFreeSpacing() || c != ' ') { os << str; - } else if (desc_on == 1) { + } else if (!style->labeltag().empty() && !label_closed) { ++char_line_count; - os << "\n"; - desc_on = 2; + os << "\nlabeltag() << "><" + << style->itemtag() << "><" + << defaultstyle->latexname() << ">"; + label_closed = true; + para_closed = false; } else { os << ' '; } @@ -1405,9 +1432,15 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, } // resets description flag correctly - if (desc_on == 1) { + if (!label_closed) { // not closed... - os << "\n "; + os << "labeltag() << ">\n<" + << style->itemtag() << "><" + << defaultstyle->latexname() << "> "; + } + if (!para_closed) { + os << "\n" << string(depth, ' ') << "latexname() << ">\n"; } if (style->free_spacing) os << '\n';