1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "paragraph.h"
18 #include "paragraph_pimpl.h"
22 #include "tex-strings.h"
24 #include "bufferparams.h"
26 #include "LaTeXFeatures.h"
28 #include "BufferView.h"
30 #include "ParameterStruct.h"
32 #include "lyxtextclasslist.h"
34 #include "insets/insetinclude.h"
35 #include "insets/insetbib.h"
36 #include "insets/insettext.h"
38 #include "support/filetools.h"
39 #include "support/lstrings.h"
40 #include "support/lyxmanip.h"
41 #include "support/FileInfo.h"
42 #include "support/LAssert.h"
43 #include "support/textutils.h"
53 using std::lower_bound;
54 using std::upper_bound;
59 int tex_code_break_column = 72; // needs non-zero initialization. set later.
60 // this is a bad idea, but how can Paragraph find its buffer to get
61 // parameters? (JMarc)
63 extern string bibitemWidest(Buffer const *);
65 // this is a minibuffer
70 LyXFont minibuffer_font;
71 Inset * minibuffer_inset;
76 extern BufferView * current_view;
79 Paragraph::Paragraph()
80 : pimpl_(new Paragraph::Pimpl(this))
82 for (int i = 0; i < 10; ++i)
88 bibkey = 0; // ale970302
93 // This constructor inserts the new paragraph in a list.
94 Paragraph::Paragraph(Paragraph * par)
95 : pimpl_(new Paragraph::Pimpl(this))
97 for (int i = 0; i < 10; ++i)
102 // double linked list begin
105 next_->previous_ = this;
107 previous_->next_ = this;
110 bibkey = 0; // ale970302
115 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
116 : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
118 for (int i = 0; i < 10; ++i)
125 // this is because of the dummy layout of the paragraphs that
127 layout_ = lp.layout();
131 bibkey = static_cast<InsetBibKey *>
132 (lp.bibkey->clone(*current_view->buffer()));
137 // copy everything behind the break-position to the new paragraph
138 insetlist = lp.insetlist;
139 for (InsetList::iterator it = insetlist.begin();
140 it != insetlist.end(); ++it)
142 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
143 // tell the new inset who is the boss now
144 it->inset->parOwner(this);
149 // the destructor removes the new paragraph from the list
150 Paragraph::~Paragraph()
153 previous_->next_ = next_;
155 next_->previous_ = previous_;
157 for (InsetList::iterator it = insetlist.begin();
158 it != insetlist.end(); ++it) {
167 //lyxerr << "Paragraph::paragraph_id = "
168 // << Paragraph::paragraph_id << endl;
172 void Paragraph::writeFile(Buffer const * buf, ostream & os,
173 BufferParams const & bparams,
174 depth_type dth) const
176 // The beginning or end of a deeper (i.e. nested) area?
177 if (dth != params().depth()) {
178 if (params().depth() > dth) {
179 while (params().depth() > dth) {
180 os << "\n\\begin_deeper ";
184 while (params().depth() < dth) {
185 os << "\n\\end_deeper ";
191 // First write the layout
192 string lay = layout();
194 lay = textclasslist[bparams.textclass].defaultLayoutName();
197 os << "\n\\layout " << layout() << "\n";
199 // Maybe some vertical spaces.
200 if (params().spaceTop().kind() != VSpace::NONE)
201 os << "\\added_space_top "
202 << params().spaceTop().asLyXCommand() << " ";
203 if (params().spaceBottom().kind() != VSpace::NONE)
204 os << "\\added_space_bottom "
205 << params().spaceBottom().asLyXCommand() << " ";
207 // Maybe the paragraph has special spacing
208 params().spacing().writeFile(os, true);
210 // The labelwidth string used in lists.
211 if (!params().labelWidthString().empty())
212 os << "\\labelwidthstring "
213 << params().labelWidthString() << '\n';
215 // Lines above or below?
216 if (params().lineTop())
218 if (params().lineBottom())
219 os << "\\line_bottom ";
221 // Pagebreaks above or below?
222 if (params().pagebreakTop())
223 os << "\\pagebreak_top ";
224 if (params().pagebreakBottom())
225 os << "\\pagebreak_bottom ";
227 // Start of appendix?
228 if (params().startOfAppendix())
229 os << "\\start_of_appendix ";
232 if (params().noindent())
236 if (params().align() != LYX_ALIGN_LAYOUT) {
238 switch (params().align()) {
239 case LYX_ALIGN_LEFT: h = 1; break;
240 case LYX_ALIGN_RIGHT: h = 2; break;
241 case LYX_ALIGN_CENTER: h = 3; break;
242 default: h = 0; break;
244 os << "\\align " << string_align[h] << " ";
249 bibkey->write(buf, os);
251 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
254 for (pos_type i = 0; i < size(); ++i) {
260 // Write font changes
261 LyXFont font2 = getFontSettings(bparams, i);
262 if (font2 != font1) {
263 #ifndef INHERIT_LANGUAGE
264 font2.lyxWriteChanges(font1, os);
266 font2.lyxWriteChanges(font1, bparams.language, os);
272 value_type const c = getChar(i);
276 Inset const * inset = getInset(i);
278 if (inset->directWrite()) {
279 // international char, let it write
280 // code directly so it's shorter in
282 inset->write(buf, os);
284 os << "\n\\begin_inset ";
285 inset->write(buf, os);
286 os << "\n\\end_inset \n\n";
292 os << "\n\\newline \n";
296 os << "\n\\hfill \n";
300 os << "\n\\backslash \n";
304 if (i + 1 < size() && getChar(i + 1) == ' ') {
311 if ((column > 70 && c == ' ')
316 // this check is to amend a bug. LyX sometimes
317 // inserts '\0' this could cause problems.
321 lyxerr << "ERROR (Paragraph::writeFile):"
322 " NULL char in structure." << endl;
328 // now write the next paragraph
330 next_->writeFile(buf, os, bparams, dth);
334 void Paragraph::validate(LaTeXFeatures & features) const
336 BufferParams const & bparams = features.bufferParams();
339 if (params().lineTop() || params().lineBottom())
340 features.require("lyxline");
341 if (!params().spacing().isDefault())
342 features.require("setspace");
345 features.useLayout(layout());
348 Language const * doc_language = bparams.language;
350 Pimpl::FontList::const_iterator fcit = pimpl_->fontlist.begin();
351 Pimpl::FontList::const_iterator fend = pimpl_->fontlist.end();
352 for (; fcit != fend; ++fcit) {
353 if (fcit->font().noun() == LyXFont::ON) {
354 lyxerr[Debug::LATEX] << "font.noun: "
355 << fcit->font().noun()
357 features.require("noun");
358 lyxerr[Debug::LATEX] << "Noun enabled. Font: "
359 << fcit->font().stateText(0)
362 switch (fcit->font().color()) {
364 case LColor::inherit:
366 // probably we should put here all interface colors used for
367 // font displaying! For now I just add this ones I know of (Jug)
372 features.require("color");
373 lyxerr[Debug::LATEX] << "Color enabled. Font: "
374 << fcit->font().stateText(0)
378 Language const * language = fcit->font().language();
379 if (language->babel() != doc_language->babel() &&
380 language != ignore_language &&
381 #ifdef INHERIT_LANGUAGE
382 language != inherit_language &&
384 language != latex_language)
386 features.useLanguage(language);
387 lyxerr[Debug::LATEX] << "Found language "
388 << language->babel() << endl;
393 LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
395 InsetList::const_iterator icit = insetlist.begin();
396 InsetList::const_iterator iend = insetlist.end();
397 for (; icit != iend; ++icit) {
399 icit->inset->validate(features);
400 if (lout.needprotect &&
401 icit->inset->lyxCode() == Inset::FOOT_CODE)
402 features.require("NeedLyXFootnoteCode");
408 // First few functions needed for cut and paste and paragraph breaking.
409 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
411 BufferParams bparams = buffer.params;
413 minibuffer_char = getChar(pos);
414 minibuffer_font = getFontSettings(bparams, pos);
415 minibuffer_inset = 0;
416 if (minibuffer_char == Paragraph::META_INSET) {
418 minibuffer_inset = getInset(pos)->clone(buffer);
420 minibuffer_inset = 0;
421 minibuffer_char = ' ';
422 // This reflects what GetInset() does (ARRae)
428 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
430 minibuffer_char = getChar(pos);
431 minibuffer_font = getFontSettings(bparams, pos);
432 minibuffer_inset = 0;
433 if (minibuffer_char == Paragraph::META_INSET) {
435 minibuffer_inset = getInset(pos);
436 // This is a little hack since I want exactly
437 // the inset, not just a clone. Otherwise
438 // the inset would be deleted when calling Erase(pos)
440 InsetList::iterator it = insetlist.begin();
441 InsetList::iterator end = insetlist.end();
442 for (; it != end; ++it) {
447 if (it != end && it->pos == pos)
449 // the inset is not in a paragraph anymore
450 minibuffer_inset->parOwner(0);
452 minibuffer_inset = 0;
453 minibuffer_char = ' ';
454 // This reflects what GetInset() does (ARRae)
459 // Erase(pos); now the caller is responsible for that.
463 bool Paragraph::insertFromMinibuffer(pos_type pos)
465 if (minibuffer_char == Paragraph::META_INSET) {
466 if (!insetAllowed(minibuffer_inset->lyxCode())) {
469 insertInset(pos, minibuffer_inset, minibuffer_font);
471 LyXFont f = minibuffer_font;
472 if (!checkInsertChar(f)) {
475 insertChar(pos, minibuffer_char, f);
483 void Paragraph::erase(pos_type pos)
489 bool Paragraph::checkInsertChar(LyXFont & font)
491 if (pimpl_->inset_owner)
492 return pimpl_->inset_owner->checkInsertChar(font);
497 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
499 LyXFont const f(LyXFont::ALL_INHERIT);
500 insertChar(pos, c, f);
504 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
505 LyXFont const & font)
507 pimpl_->insertChar(pos, c, font);
511 void Paragraph::insertInset(pos_type pos, Inset * inset)
513 LyXFont const f(LyXFont::ALL_INHERIT);
514 insertInset(pos, inset, f);
518 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
520 pimpl_->insertInset(pos, inset, font);
524 bool Paragraph::insetAllowed(Inset::Code code)
526 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
528 if (pimpl_->inset_owner)
529 return pimpl_->inset_owner->insetAllowed(code);
534 Inset * Paragraph::getInset(pos_type pos)
536 lyx::Assert(pos < size());
539 InsetList::iterator it = insetlist.begin();
540 InsetList::iterator end = insetlist.end();
541 for (; it != end; ++it) {
546 if (it != end && it->pos == pos)
549 lyxerr << "ERROR (Paragraph::getInset): "
550 << "Inset does not exist: " << pos << endl;
553 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
554 // Did this commenting out introduce a bug? So far I have not
555 // see any, please enlighten me. (Lgb)
556 // My guess is that since the inset does not exist, we might
557 // as well replace it with a space to prevent craches. (Asger)
562 Inset const * Paragraph::getInset(pos_type pos) const
564 lyx::Assert(pos < size());
567 InsetList::const_iterator cit = insetlist.begin();
568 InsetList::const_iterator end = insetlist.end();
569 for (; cit != end; ++cit) {
574 if (cit != end && cit->pos == pos)
577 lyxerr << "ERROR (Paragraph::getInset): "
578 << "Inset does not exist: " << pos << endl;
580 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
581 // Did this commenting out introduce a bug? So far I have not
582 // see any, please enlighten me. (Lgb)
583 // My guess is that since the inset does not exist, we might
584 // as well replace it with a space to prevent craches. (Asger)
589 // Gets uninstantiated font setting at position.
590 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
593 lyx::Assert(pos <= size());
595 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
596 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
597 for (; cit != end; ++cit) {
598 if (cit->pos() >= pos)
604 retfont = cit->font();
605 } else if (pos == size() && size()) {
606 retfont = getFontSettings(bparams, pos - 1);
608 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
609 #ifdef INHERIT_LANGUAGE
610 if (retfont.language() == inherit_language)
611 retfont.setLanguage(bparams.language);
618 // Gets uninstantiated font setting at position 0
619 LyXFont const Paragraph::getFirstFontSettings() const
621 if (size() > 0 && !pimpl_->fontlist.empty())
622 return pimpl_->fontlist[0].font();
624 return LyXFont(LyXFont::ALL_INHERIT);
628 // Gets the fully instantiated font at a given position in a paragraph
629 // This is basically the same function as LyXText::GetFont() in text2.C.
630 // The difference is that this one is used for generating the LaTeX file,
631 // and thus cosmetic "improvements" are disallowed: This has to deliver
632 // the true picture of the buffer. (Asger)
633 // If position is -1, we get the layout font of the paragraph.
634 // If position is -2, we get the font of the manual label of the paragraph.
635 LyXFont const Paragraph::getFont(BufferParams const & bparams,
638 lyx::Assert(pos >= 0);
640 LyXLayout const & lout =
641 textclasslist[bparams.textclass][layout()];
642 pos_type main_body = 0;
643 if (lout.labeltype == LABEL_MANUAL)
644 main_body = beginningOfMainBody();
648 layoutfont = lout.labelfont;
650 layoutfont = lout.font;
652 LyXFont tmpfont = getFontSettings(bparams, pos);
653 #ifndef INHERIT_LANGUAGE
654 tmpfont.realize(layoutfont);
656 tmpfont.realize(layoutfont, bparams.language);
659 return pimpl_->realizeFont(tmpfont, bparams);
663 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
665 LyXLayout const & lout =
666 textclasslist[bparams.textclass][layout()];
668 LyXFont tmpfont = lout.labelfont;
669 tmpfont.setLanguage(getParLanguage(bparams));
671 return pimpl_->realizeFont(tmpfont, bparams);
675 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
677 LyXLayout const & lout =
678 textclasslist[bparams.textclass][layout()];
680 LyXFont tmpfont = lout.font;
681 tmpfont.setLanguage(getParLanguage(bparams));
683 return pimpl_->realizeFont(tmpfont, bparams);
687 /// Returns the height of the highest font in range
689 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
690 LyXFont::FONT_SIZE const def_size) const
692 if (pimpl_->fontlist.empty())
695 Pimpl::FontList::const_iterator end_it = pimpl_->fontlist.begin();
696 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
697 for (; end_it != end; ++end_it) {
698 if (end_it->pos() >= endpos)
705 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
706 for (; cit != end; ++cit) {
707 if (cit->pos() >= startpos)
711 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
712 for (; cit != end_it; ++cit) {
713 LyXFont::FONT_SIZE size = cit->font().size();
714 if (size == LyXFont::INHERIT_SIZE)
716 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
723 Paragraph::value_type
724 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
726 value_type c = getChar(pos);
727 if (!lyxrc.rtl_support)
757 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
764 void Paragraph::setFont(pos_type pos, LyXFont const & font)
766 lyx::Assert(pos <= size());
768 // First, reduce font against layout/label font
769 // Update: The SetCharFont() routine in text2.C already
770 // reduces font, so we don't need to do that here. (Asger)
771 // No need to simplify this because it will disappear
772 // in a new kernel. (Asger)
773 // Next search font table
775 Pimpl::FontList::iterator beg = pimpl_->fontlist.begin();
776 Pimpl::FontList::iterator it = beg;
777 Pimpl::FontList::iterator endit = pimpl_->fontlist.end();
778 for (; it != endit; ++it) {
779 if (it->pos() >= pos)
782 unsigned int i = std::distance(beg, it);
783 bool notfound = (it == endit);
785 if (!notfound && pimpl_->fontlist[i].font() == font)
788 bool begin = pos == 0 || notfound ||
789 (i > 0 && pimpl_->fontlist[i - 1].pos() == pos - 1);
790 // Is position pos is a beginning of a font block?
791 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
792 // Is position pos is the end of a font block?
793 if (begin && end) { // A single char block
794 if (i + 1 < pimpl_->fontlist.size() &&
795 pimpl_->fontlist[i + 1].font() == font) {
796 // Merge the singleton block with the next block
797 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
798 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
799 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
800 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
801 // Merge the singleton block with the previous block
802 pimpl_->fontlist[i - 1].pos(pos);
803 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
805 pimpl_->fontlist[i].font(font);
807 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
808 pimpl_->fontlist[i - 1].pos(pos);
810 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
811 Pimpl::FontTable(pos, font));
813 pimpl_->fontlist[i].pos(pos - 1);
814 if (!(i + 1 < pimpl_->fontlist.size() &&
815 pimpl_->fontlist[i + 1].font() == font))
816 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
817 Pimpl::FontTable(pos, font));
818 } else { // The general case. The block is splitted into 3 blocks
819 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
820 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
821 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
822 Pimpl::FontTable(pos, font));
828 void Paragraph::next(Paragraph * p)
834 // This function is able to hide closed footnotes.
835 Paragraph * Paragraph::next()
841 Paragraph const * Paragraph::next() const
847 void Paragraph::previous(Paragraph * p)
853 // This function is able to hide closed footnotes.
854 Paragraph * Paragraph::previous()
860 // This function is able to hide closed footnotes.
861 Paragraph const * Paragraph::previous() const
867 void Paragraph::breakParagraph(BufferParams const & bparams,
871 // create a new paragraph
872 Paragraph * tmp = new Paragraph(this);
873 tmp->layout(textclasslist[bparams.textclass].defaultLayoutName());
875 // remember to set the inset_owner
876 tmp->setInsetOwner(inInset());
878 // this is an idea for a more userfriendly layout handling, I will
879 // see what the users say
881 // layout stays the same with latex-environments
883 tmp->layout(layout());
884 tmp->setLabelWidthString(params().labelWidthString());
887 bool isempty = textclasslist[bparams.textclass][layout()].keepempty;
888 if (!isempty && (size() > pos || !size() || flag == 2)) {
889 tmp->layout(layout());
890 tmp->params().align(params().align());
891 tmp->setLabelWidthString(params().labelWidthString());
893 tmp->params().lineBottom(params().lineBottom());
894 params().lineBottom(false);
895 tmp->params().pagebreakBottom(params().pagebreakBottom());
896 params().pagebreakBottom(false);
897 tmp->params().spaceBottom(params().spaceBottom());
898 params().spaceBottom(VSpace(VSpace::NONE));
900 tmp->params().depth(params().depth());
901 tmp->params().noindent(params().noindent());
903 // copy everything behind the break-position
904 // to the new paragraph
905 pos_type pos_end = size() - 1;
908 for (; i <= pos_end; ++i) {
909 cutIntoMinibuffer(bparams, i);
910 if (tmp->insertFromMinibuffer(j - pos))
913 for (i = pos_end; i >= pos; --i) {
918 // just an idea of me
919 if (!isempty && !pos) {
920 tmp->params().lineTop(params().lineTop());
921 tmp->params().pagebreakTop(params().pagebreakTop());
922 tmp->params().spaceTop(params().spaceTop());
923 tmp->bibkey = bibkey;
927 layout(textclasslist[bparams.textclass].defaultLayoutName());
929 // layout stays the same with latex-environments
931 layout(tmp->layout());
932 setLabelWidthString(tmp->params().labelWidthString());
933 params().depth(tmp->params().depth());
939 void Paragraph::makeSameLayout(Paragraph const * par)
941 layout(par->layout());
943 params() = par->params();
947 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
949 if (textclasslist[tclass][layout()].free_spacing ||
955 while (size() && (isNewline(0) || isLineSeparator(0))) {
964 bool Paragraph::hasSameLayout(Paragraph const * par) const
967 par->layout() == layout() &&
968 params().sameLayout(par->params());
972 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
975 // create a new paragraph
976 Paragraph * tmp = new Paragraph(this);
977 tmp->makeSameLayout(this);
979 // When can pos > Last()?
980 // I guess pos == Last() is possible.
982 // copy everything behind the break-position to the new
984 pos_type pos_end = size() - 1;
988 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
989 cutIntoMinibuffer(bparams, i);
990 if (tmp->insertFromMinibuffer(j - pos))
994 for (pos_type k = pos_end; k >= pos; --k) {
1001 // Be carefull, this does not make any check at all.
1002 // This method has wrong name, it combined this par with the next par.
1003 // In that sense it is the reverse of break paragraph. (Lgb)
1004 void Paragraph::pasteParagraph(BufferParams const & bparams)
1006 // copy the next paragraph to this one
1007 Paragraph * the_next = next();
1009 // first the DTP-stuff
1010 params().lineBottom(the_next->params().lineBottom());
1011 params().spaceBottom(the_next->params().spaceBottom());
1012 params().pagebreakBottom(the_next->params().pagebreakBottom());
1014 pos_type pos_end = the_next->pimpl_->size() - 1;
1015 pos_type pos_insert = size();
1017 // ok, now copy the paragraph
1018 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1019 the_next->cutIntoMinibuffer(bparams, i);
1020 if (insertFromMinibuffer(pos_insert + j))
1024 // delete the next paragraph
1025 Paragraph * ppar = the_next->previous_;
1026 Paragraph * npar = the_next->next_;
1032 int Paragraph::getEndLabel(BufferParams const & bparams) const
1034 Paragraph const * par = this;
1035 depth_type par_depth = getDepth();
1037 string const & layout = par->layout();
1038 int const endlabeltype =
1039 textclasslist[bparams.textclass][layout].endlabeltype;
1040 if (endlabeltype != END_LABEL_NO_LABEL) {
1042 return endlabeltype;
1044 depth_type const next_depth = next_->getDepth();
1045 if (par_depth > next_depth ||
1046 (par_depth == next_depth
1047 && layout != next_->layout()))
1048 return endlabeltype;
1053 par = par->outerHook();
1055 par_depth = par->getDepth();
1057 return END_LABEL_NO_LABEL;
1061 Paragraph::depth_type Paragraph::getDepth() const
1063 return params().depth();
1067 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1069 bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
1072 return params().depth() + 1;
1074 return params().depth();
1078 char Paragraph::getAlign() const
1080 return params().align();
1084 string const & Paragraph::getLabelstring() const
1086 return params().labelString();
1090 int Paragraph::getFirstCounter(int i) const
1092 return pimpl_->counter_[i];
1096 // the next two functions are for the manual labels
1097 string const Paragraph::getLabelWidthString() const
1099 if (!params().labelWidthString().empty())
1100 return params().labelWidthString();
1102 return _("Senseless with this layout!");
1106 void Paragraph::setLabelWidthString(string const & s)
1108 params().labelWidthString(s);
1112 void Paragraph::applyLayout(string const & new_layout)
1115 params().labelWidthString(string());
1116 params().align(LYX_ALIGN_LAYOUT);
1117 params().spaceTop(VSpace(VSpace::NONE));
1118 params().spaceBottom(VSpace(VSpace::NONE));
1119 params().spacing(Spacing(Spacing::Default));
1123 // if the layout of a paragraph contains a manual label, the beginning of the
1124 // main body is the beginning of the second word. This is what the par-
1125 // function returns. If the layout does not contain a label, the main
1126 // body always starts with position 0. This differentiation is necessary,
1127 // because there cannot be a newline or a blank <= the beginning of the
1128 // main body in TeX.
1130 int Paragraph::beginningOfMainBody() const
1132 // Unroll the first two cycles of the loop
1133 // and remember the previous character to
1134 // remove unnecessary GetChar() calls
1137 && getChar(i) != Paragraph::META_NEWLINE) {
1139 char previous_char = 0;
1142 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1143 // Yes, this ^ is supposed to be "= " not "=="
1146 && previous_char != ' '
1147 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1149 previous_char = temp;
1158 Paragraph * Paragraph::depthHook(depth_type depth)
1160 Paragraph * newpar = this;
1163 newpar = newpar->previous();
1164 } while (newpar && newpar->getDepth() > depth);
1167 if (previous() || getDepth())
1168 lyxerr << "ERROR (Paragraph::DepthHook): "
1177 Paragraph const * Paragraph::depthHook(depth_type depth) const
1179 Paragraph const * newpar = this;
1182 newpar = newpar->previous();
1183 } while (newpar && newpar->getDepth() > depth);
1186 if (previous() || getDepth())
1187 lyxerr << "ERROR (Paragraph::DepthHook): "
1195 Paragraph * Paragraph::outerHook()
1199 return depthHook(depth_type(getDepth() - 1));
1202 Paragraph const * Paragraph::outerHook() const
1206 return depthHook(depth_type(getDepth() - 1));
1210 Paragraph::inset_iterator
1211 Paragraph::InsetIterator(pos_type pos)
1213 InsetList::iterator it = insetlist.begin();
1214 InsetList::iterator end = insetlist.end();
1215 for (; it != end; ++it) {
1220 return inset_iterator(it);
1224 // returns -1 if inset not found
1225 int Paragraph::getPositionOfInset(Inset const * inset) const
1228 InsetList::const_iterator cit = insetlist.begin();
1229 InsetList::const_iterator end = insetlist.end();
1230 for (; cit != end; ++cit) {
1231 if (cit->inset == inset) {
1235 if (inset == bibkey)
1242 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1243 BufferParams const & bparams,
1244 ostream & os, TexRow & texrow,
1247 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1248 Inset const * in = inInset();
1249 bool further_blank_line = false;
1252 // well we have to check if we are in an inset with unlimited
1253 // lenght (all in one row) if that is true then we don't allow
1254 // any special options in the paragraph and also we don't allow
1255 // any environment other then "Standard" to be valid!
1256 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1257 style = textclasslist[bparams.textclass][layout()];
1259 if (params().startOfAppendix()) {
1260 os << "\\appendix\n";
1264 if (!params().spacing().isDefault()
1265 && (!previous() || !previous()->hasSameLayout(this))) {
1266 os << params().spacing().writeEnvirBegin() << "\n";
1270 if (tex_code_break_column && style.isCommand()) {
1275 if (params().pagebreakTop()) {
1277 further_blank_line = true;
1279 if (params().spaceTop().kind() != VSpace::NONE) {
1280 os << params().spaceTop().asLatexCommand(bparams);
1281 further_blank_line = true;
1284 if (params().lineTop()) {
1285 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1286 << "\\vspace{-1\\parskip}";
1287 further_blank_line = true;
1290 if (further_blank_line) {
1295 style = textclasslist[bparams.textclass].defaultLayout();
1298 Language const * language = getParLanguage(bparams);
1299 Language const * doc_language = bparams.language;
1300 Language const * previous_language = previous()
1301 ? previous()->getParLanguage(bparams) : doc_language;
1303 if (language->babel() != previous_language->babel()
1304 // check if we already put language command in TeXEnvironment()
1305 && !(style.isEnvironment()
1306 && (!previous() || previous()->layout() != layout() ||
1307 previous()->params().depth() != params().depth())))
1309 if (!lyxrc.language_command_end.empty() &&
1310 previous_language->babel() != doc_language->babel())
1312 os << subst(lyxrc.language_command_end, "$$lang",
1313 previous_language->babel())
1318 if (lyxrc.language_command_end.empty() ||
1319 language->babel() != doc_language->babel())
1321 os << subst(lyxrc.language_command_begin, "$$lang",
1328 if (bparams.inputenc == "auto" &&
1329 language->encoding() != previous_language->encoding()) {
1330 os << "\\inputencoding{"
1331 << language->encoding()->LatexName()
1336 switch (style.latextype) {
1339 << style.latexname()
1340 << style.latexparam();
1342 case LATEX_ITEM_ENVIRONMENT:
1344 bibkey->latex(buf, os, false, false);
1348 case LATEX_LIST_ENVIRONMENT:
1355 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1357 // Make sure that \\par is done with the font of the last
1358 // character if this has another size as the default.
1359 // This is necessary because LaTeX (and LyX on the screen)
1360 // calculates the space between the baselines according
1361 // to this font. (Matthias)
1363 // Is this really needed ? (Dekel)
1364 // We do not need to use to change the font for the last paragraph
1365 // or for a command.
1366 LyXFont const font =
1368 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1370 bool is_command = style.isCommand();
1372 if (style.resfont.size() != font.size() && next_ && !is_command) {
1375 os << "\\" << font.latexSize() << " \\par}";
1376 } else if (need_par) {
1378 } else if (is_command)
1381 switch (style.latextype) {
1382 case LATEX_ITEM_ENVIRONMENT:
1383 case LATEX_LIST_ENVIRONMENT:
1384 if (next_ && (params().depth() < next_->params().depth())) {
1389 case LATEX_ENVIRONMENT:
1390 // if its the last paragraph of the current environment
1391 // skip it otherwise fall through
1393 && (next_->layout() != layout()
1394 || next_->params().depth() != params().depth()))
1396 // fall through possible
1398 // we don't need it for the last paragraph!!!
1405 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1406 further_blank_line = false;
1407 if (params().lineBottom()) {
1408 os << "\\lyxline{\\" << font.latexSize() << '}';
1409 further_blank_line = true;
1412 if (params().spaceBottom().kind() != VSpace::NONE) {
1413 os << params().spaceBottom().asLatexCommand(bparams);
1414 further_blank_line = true;
1417 if (params().pagebreakBottom()) {
1419 further_blank_line = true;
1422 if (further_blank_line) {
1427 if (!params().spacing().isDefault()
1428 && (!next_ || !next_->hasSameLayout(this))) {
1429 os << params().spacing().writeEnvirEnd() << "\n";
1434 // we don't need it for the last paragraph!!!
1439 // Since \selectlanguage write the language to the aux file,
1440 // we need to reset the language at the end of footnote or
1443 if (language->babel() != doc_language->babel()) {
1444 if (lyxrc.language_command_end.empty())
1445 os << subst(lyxrc.language_command_begin,
1447 doc_language->babel())
1450 os << subst(lyxrc.language_command_end,
1458 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1462 // This could go to ParagraphParameters if we want to
1463 int Paragraph::startTeXParParams(BufferParams const & bparams,
1468 if (params().noindent()) {
1469 os << "\\noindent ";
1473 switch (params().align()) {
1474 case LYX_ALIGN_NONE:
1475 case LYX_ALIGN_BLOCK:
1476 case LYX_ALIGN_LAYOUT:
1477 case LYX_ALIGN_SPECIAL:
1479 case LYX_ALIGN_LEFT:
1480 if (getParLanguage(bparams)->babel() != "hebrew") {
1481 os << "\\begin{flushleft}";
1484 os << "\\begin{flushright}";
1488 case LYX_ALIGN_RIGHT:
1489 if (getParLanguage(bparams)->babel() != "hebrew") {
1490 os << "\\begin{flushright}";
1493 os << "\\begin{flushleft}";
1497 case LYX_ALIGN_CENTER:
1498 os << "\\begin{center}";
1506 // This could go to ParagraphParameters if we want to
1507 int Paragraph::endTeXParParams(BufferParams const & bparams,
1512 switch (params().align()) {
1513 case LYX_ALIGN_NONE:
1514 case LYX_ALIGN_BLOCK:
1515 case LYX_ALIGN_LAYOUT:
1516 case LYX_ALIGN_SPECIAL:
1518 case LYX_ALIGN_LEFT:
1519 if (getParLanguage(bparams)->babel() != "hebrew") {
1520 os << "\\end{flushleft}";
1523 os << "\\end{flushright}";
1527 case LYX_ALIGN_RIGHT:
1528 if (getParLanguage(bparams)->babel() != "hebrew") {
1529 os << "\\end{flushright}";
1532 os << "\\end{flushleft}";
1536 case LYX_ALIGN_CENTER:
1537 os << "\\end{center}";
1545 // This one spits out the text of the paragraph
1546 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1547 BufferParams const & bparams,
1548 ostream & os, TexRow & texrow,
1551 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1553 bool return_value = false;
1557 // well we have to check if we are in an inset with unlimited
1558 // lenght (all in one row) if that is true then we don't allow
1559 // any special options in the paragraph and also we don't allow
1560 // any environment other then "Standard" to be valid!
1562 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1565 style = textclasslist[bparams.textclass].defaultLayout();
1567 style = textclasslist[bparams.textclass][layout()];
1572 // Maybe we have to create a optional argument.
1574 if (style.labeltype != LABEL_MANUAL)
1577 main_body = beginningOfMainBody();
1581 if (main_body > 0) {
1584 basefont = getLabelFont(bparams);
1586 basefont = getLayoutFont(bparams);
1589 moving_arg |= style.needprotect;
1591 // Which font is currently active?
1592 LyXFont running_font(basefont);
1593 // Do we have an open font change?
1594 bool open_font = false;
1596 texrow.start(this, 0);
1598 // if the paragraph is empty, the loop will not be entered at all
1600 if (style.isCommand()) {
1605 column += startTeXParParams(bparams, os);
1609 for (pos_type i = 0; i < size(); ++i) {
1611 // First char in paragraph or after label?
1612 if (i == main_body) {
1613 if (main_body > 0) {
1615 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1618 basefont = getLayoutFont(bparams);
1619 running_font = basefont;
1623 if (style.isCommand()) {
1629 column += startTeXParParams(bparams, os);
1632 value_type c = getChar(i);
1634 // Fully instantiated font
1635 LyXFont font = getFont(bparams, i);
1637 LyXFont const last_font = running_font;
1639 // Spaces at end of font change are simulated to be
1640 // outside font change, i.e. we write "\textXX{text} "
1641 // rather than "\textXX{text }". (Asger)
1642 if (open_font && c == ' ' && i <= size() - 2) {
1643 LyXFont const & next_font = getFont(bparams, i + 1);
1644 if (next_font != running_font
1645 && next_font != font) {
1650 // We end font definition before blanks
1652 (font != running_font ||
1653 font.language() != running_font.language()))
1655 column += running_font.latexWriteEndChanges(os,
1657 (i == main_body-1) ? basefont : font);
1658 running_font = basefont;
1662 // Blanks are printed before start of fontswitch
1664 // Do not print the separation of the optional argument
1665 if (i != main_body - 1) {
1666 pimpl_->simpleTeXBlanks(os, texrow, i,
1667 column, font, style);
1671 // Do we need to change font?
1672 if ((font != running_font ||
1673 font.language() != running_font.language()) &&
1676 column += font.latexWriteStartChanges(os, basefont,
1678 running_font = font;
1682 if (c == Paragraph::META_NEWLINE) {
1683 // newlines are handled differently here than
1684 // the default in SimpleTeXSpecialChars().
1685 if (!style.newline_allowed) {
1689 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1692 basefont = getLayoutFont(bparams);
1693 running_font = basefont;
1694 if (font.family() ==
1695 LyXFont::TYPEWRITER_FAMILY) {
1703 texrow.start(this, i + 1);
1706 pimpl_->simpleTeXSpecialChars(buf, bparams,
1707 os, texrow, moving_arg,
1709 basefont, open_font,
1710 style, i, column, c);
1714 // If we have an open font definition, we have to close it
1716 #ifdef FIXED_LANGUAGE_END_DETECTION
1719 .latexWriteEndChanges(os, basefont,
1720 next_->getFont(bparams,
1723 running_font.latexWriteEndChanges(os, basefont,
1727 #ifdef WITH_WARNINGS
1728 //#warning For now we ALWAYS have to close the foreign font settings if they are
1729 //#warning there as we start another \selectlanguage with the next paragraph if
1730 //#warning we are in need of this. This should be fixed sometime (Jug)
1732 running_font.latexWriteEndChanges(os, basefont, basefont);
1736 // Needed if there is an optional argument but no contents.
1737 if (main_body > 0 && main_body == size()) {
1739 return_value = false;
1743 column += endTeXParParams(bparams, os);
1746 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1747 return return_value;
1751 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1753 bool retval = false;
1755 case Paragraph::META_HFILL:
1756 sgml_string.erase();
1758 case Paragraph::META_NEWLINE:
1762 sgml_string = "&";
1765 sgml_string = "<";
1768 sgml_string = ">";
1771 sgml_string = "$";
1774 sgml_string = "#";
1777 sgml_string = "%";
1780 sgml_string = "[";
1783 sgml_string = "]";
1786 sgml_string = "{";
1789 sgml_string = "}";
1792 sgml_string = "˜";
1795 sgml_string = """;
1798 sgml_string = "\";
1804 case '\0': // Ignore :-)
1805 sgml_string.erase();
1815 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1816 BufferParams const & bparams,
1817 ostream & os, TexRow & texrow)
1819 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1821 LyXLayout const & style =
1822 textclasslist[bparams.textclass][layout()];
1824 Language const * language = getParLanguage(bparams);
1825 Language const * doc_language = bparams.language;
1826 Language const * previous_language = previous_
1827 ? previous_->getParLanguage(bparams) : doc_language;
1828 if (language->babel() != previous_language->babel()) {
1830 if (!lyxrc.language_command_end.empty() &&
1831 previous_language->babel() != doc_language->babel()) {
1832 os << subst(lyxrc.language_command_end, "$$lang",
1833 previous_language->babel())
1838 if (lyxrc.language_command_end.empty() ||
1839 language->babel() != doc_language->babel()) {
1840 os << subst(lyxrc.language_command_begin, "$$lang",
1847 if (style.isEnvironment()) {
1848 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1849 os << "\\begin{" << style.latexname() << "}{"
1850 << params().labelWidthString() << "}\n";
1851 } else if (style.labeltype == LABEL_BIBLIO) {
1853 os << "\\begin{" << style.latexname() << "}{"
1854 << bibitemWidest(buf)
1856 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1857 os << "\\begin{" << style.latexname() << '}'
1858 << style.latexparam() << '\n';
1860 os << "\\begin{" << style.latexname() << '}'
1861 << style.latexparam() << '\n';
1864 Paragraph * par = this;
1866 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1868 if (par && par->params().depth() > params().depth()) {
1869 if (textclasslist[bparams.textclass][par->layout()].isParagraph()
1871 // How to handle this? (Lgb)
1872 //&& !suffixIs(os, "\n\n")
1874 // There should be at least one '\n' already
1875 // but we need there to be two for Standard
1876 // paragraphs that are depth-increment'ed to be
1877 // output correctly. However, tables can
1878 // also be paragraphs so don't adjust them.
1881 // Will it ever harm to have one '\n' too
1882 // many? i.e. that we sometimes will have
1883 // three in a row. (Lgb)
1887 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1890 && par->layout() == layout()
1891 && par->params().depth() == params().depth());
1893 if (style.isEnvironment()) {
1894 os << "\\end{" << style.latexname() << "}\n";
1898 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1899 return par; // ale970302
1903 bool Paragraph::isHfill(pos_type pos) const
1905 return IsHfillChar(getChar(pos));
1909 bool Paragraph::isInset(pos_type pos) const
1911 return IsInsetChar(getChar(pos));
1915 bool Paragraph::isNewline(pos_type pos) const
1917 return pos >= 0 && IsNewlineChar(getChar(pos));
1921 bool Paragraph::isSeparator(pos_type pos) const
1923 return IsSeparatorChar(getChar(pos));
1927 bool Paragraph::isLineSeparator(pos_type pos) const
1929 value_type const c = getChar(pos);
1930 return IsLineSeparatorChar(c)
1931 || (IsInsetChar(c) && getInset(pos) &&
1932 getInset(pos)->isLineSeparator());
1936 bool Paragraph::isKomma(pos_type pos) const
1938 return IsKommaChar(getChar(pos));
1942 /// Used by the spellchecker
1943 bool Paragraph::isLetter(pos_type pos) const
1945 value_type const c = getChar(pos);
1946 if (IsLetterChar(c))
1949 return getInset(pos)->isLetter();
1950 // We want to pass the ' and escape chars to ispell
1951 string const extra = lyxrc.isp_esc_chars + '\'';
1952 return contains(extra, c);
1956 bool Paragraph::isWord(pos_type pos) const
1958 return IsWordChar(getChar(pos)) ;
1963 Paragraph::getParLanguage(BufferParams const & bparams) const
1966 #ifndef INHERIT_LANGUAGE
1967 return getFirstFontSettings().language();
1969 Language const * lang = getFirstFontSettings().language();
1970 #ifdef WITH_WARNINGS
1971 #warning We should make this somewhat better, any ideas? (Jug)
1973 if (lang == inherit_language || lang == ignore_language)
1974 lang = bparams.language;
1977 } else if (previous_)
1978 return previous_->getParLanguage(bparams);
1980 return bparams.language;
1984 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1986 return lyxrc.rtl_support
1987 && getParLanguage(bparams)->RightToLeft();
1991 void Paragraph::changeLanguage(BufferParams const & bparams,
1992 Language const * from, Language const * to)
1994 for (pos_type i = 0; i < size(); ++i) {
1995 LyXFont font = getFontSettings(bparams, i);
1996 if (font.language() == from) {
1997 font.setLanguage(to);
2004 bool Paragraph::isMultiLingual(BufferParams const & bparams)
2006 Language const * doc_language = bparams.language;
2007 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
2008 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
2010 for (; cit != end; ++cit)
2011 if (cit->font().language() != ignore_language &&
2012 cit->font().language() != latex_language &&
2013 #ifdef INHERIT_LANGUAGE
2014 cit->font().language() != inherit_language &&
2016 cit->font().language() != doc_language)
2022 // Convert the paragraph to a string.
2023 // Used for building the table of contents
2024 string const Paragraph::asString(Buffer const * buffer, bool label)
2026 BufferParams const & bparams = buffer->params;
2028 if (label && !params().labelString().empty())
2029 s += params().labelString() + ' ';
2030 string::size_type const len = s.size();
2032 for (pos_type i = 0; i < size(); ++i) {
2033 value_type c = getChar(i);
2036 else if (c == META_INSET &&
2037 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2039 getInset(i)->ascii(buffer, ost);
2040 s += subst(ost.str().c_str(),'\n',' ');
2044 if (isRightToLeftPar(bparams))
2045 reverse(s.begin() + len,s.end());
2051 string const Paragraph::asString(Buffer const * buffer,
2052 pos_type beg, pos_type end, bool label)
2056 if (beg == 0 && label && !params().labelString().empty())
2057 ost << params().labelString() << ' ';
2059 for (pos_type i = beg; i < end; ++i) {
2060 value_type const c = getUChar(buffer->params, i);
2063 else if (c == META_NEWLINE)
2065 else if (c == META_HFILL)
2067 else if (c == META_INSET) {
2068 getInset(i)->ascii(buffer, ost);
2072 return ost.str().c_str();
2076 void Paragraph::setInsetOwner(Inset * i)
2078 pimpl_->inset_owner = i;
2079 InsetList::const_iterator cit = insetlist.begin();
2080 InsetList::const_iterator end = insetlist.end();
2081 for (; cit != end; ++cit) {
2083 cit->inset->setOwner(i);
2088 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2091 InsetList::const_iterator cit = insetlist.begin();
2092 InsetList::const_iterator end = insetlist.end();
2093 for (; cit != end; ++cit) {
2094 if (cit->inset && cit->inset->isTextInset()) {
2095 static_cast<UpdatableInset *>
2096 (cit->inset)->deleteLyXText(bv, true);
2102 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2105 InsetList::const_iterator cit = insetlist.begin();
2106 InsetList::const_iterator end = insetlist.end();
2107 for (; cit != end; ++cit) {
2109 if (cit->inset->isTextInset()) {
2110 static_cast<UpdatableInset *>
2111 (cit->inset)->resizeLyXText(bv, true);
2118 void Paragraph::setContentsFromPar(Paragraph * par)
2120 pimpl_->setContentsFromPar(par);
2124 lyx::pos_type Paragraph::size() const
2126 return pimpl_->size();
2130 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2132 return pimpl_->getChar(pos);
2136 int Paragraph::id() const
2142 void Paragraph::id(int id_arg)
2144 pimpl_->id_ = id_arg;
2148 string const & Paragraph::layout() const
2154 void Paragraph::layout(string const & new_layout)
2156 lyx::Assert(!new_layout.empty());
2158 layout_ = new_layout;
2162 bool Paragraph::isFirstInSequence() const
2164 Paragraph const * dhook = depthHook(getDepth());
2165 return (dhook == this
2166 || dhook->layout() != layout()
2167 || dhook->getDepth() != getDepth());
2171 Inset * Paragraph::inInset() const
2173 return pimpl_->inset_owner;
2177 void Paragraph::clearContents()
2183 void Paragraph::setCounter(int i, int v)
2185 pimpl_->counter_[i] = v;
2189 int Paragraph::getCounter(int i) const
2191 return pimpl_->counter_[i];
2195 void Paragraph::incCounter(int i)
2197 pimpl_->counter_[i]++;
2201 void Paragraph::setChar(pos_type pos, value_type c)
2203 pimpl_->setChar(pos, c);
2207 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2212 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2214 return inset_iterator(insetlist.begin());
2218 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2220 return inset_iterator(insetlist.end());
2224 ParagraphParameters & Paragraph::params()
2226 return pimpl_->params;
2230 ParagraphParameters const & Paragraph::params() const
2232 return pimpl_->params;
2236 Paragraph * Paragraph::getParFromID(int id) const
2238 return pimpl_->getParFromID(id);
2242 bool Paragraph::isFreeSpacing() const
2244 // for now we just need this, later should we need this in some
2245 // other way we can always add a function to Inset::() too.
2246 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2247 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);