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) {
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 if (size() > pos || !size() || flag == 2) {
888 tmp->layout(layout());
889 tmp->params().align(params().align());
890 tmp->setLabelWidthString(params().labelWidthString());
892 tmp->params().lineBottom(params().lineBottom());
893 params().lineBottom(false);
894 tmp->params().pagebreakBottom(params().pagebreakBottom());
895 params().pagebreakBottom(false);
896 tmp->params().spaceBottom(params().spaceBottom());
897 params().spaceBottom(VSpace(VSpace::NONE));
899 tmp->params().depth(params().depth());
900 tmp->params().noindent(params().noindent());
902 // copy everything behind the break-position
903 // to the new paragraph
904 pos_type pos_end = size() - 1;
907 for (; i <= pos_end; ++i) {
908 cutIntoMinibuffer(bparams, i);
909 if (tmp->insertFromMinibuffer(j - pos))
912 for (i = pos_end; i >= pos; --i) {
917 // just an idea of me
919 tmp->params().lineTop(params().lineTop());
920 tmp->params().pagebreakTop(params().pagebreakTop());
921 tmp->params().spaceTop(params().spaceTop());
922 tmp->bibkey = bibkey;
926 layout(textclasslist[bparams.textclass].defaultLayoutName());
928 // layout stays the same with latex-environments
930 layout(tmp->layout());
931 setLabelWidthString(tmp->params().labelWidthString());
932 params().depth(tmp->params().depth());
938 void Paragraph::makeSameLayout(Paragraph const * par)
940 layout(par->layout());
942 params() = par->params();
946 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
948 if (textclasslist[tclass][layout()].free_spacing ||
954 while (size() && (isNewline(0) || isLineSeparator(0))) {
963 bool Paragraph::hasSameLayout(Paragraph const * par) const
966 par->layout() == layout() &&
967 params().sameLayout(par->params());
971 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
974 // create a new paragraph
975 Paragraph * tmp = new Paragraph(this);
976 tmp->makeSameLayout(this);
978 // When can pos > Last()?
979 // I guess pos == Last() is possible.
981 // copy everything behind the break-position to the new
983 pos_type pos_end = size() - 1;
987 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
988 cutIntoMinibuffer(bparams, i);
989 if (tmp->insertFromMinibuffer(j - pos))
993 for (pos_type k = pos_end; k >= pos; --k) {
1000 // Be carefull, this does not make any check at all.
1001 // This method has wrong name, it combined this par with the next par.
1002 // In that sense it is the reverse of break paragraph. (Lgb)
1003 void Paragraph::pasteParagraph(BufferParams const & bparams)
1005 // copy the next paragraph to this one
1006 Paragraph * the_next = next();
1008 // first the DTP-stuff
1009 params().lineBottom(the_next->params().lineBottom());
1010 params().spaceBottom(the_next->params().spaceBottom());
1011 params().pagebreakBottom(the_next->params().pagebreakBottom());
1013 pos_type pos_end = the_next->pimpl_->size() - 1;
1014 pos_type pos_insert = size();
1016 // ok, now copy the paragraph
1017 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1018 the_next->cutIntoMinibuffer(bparams, i);
1019 if (insertFromMinibuffer(pos_insert + j))
1023 // delete the next paragraph
1024 Paragraph * ppar = the_next->previous_;
1025 Paragraph * npar = the_next->next_;
1031 int Paragraph::getEndLabel(BufferParams const & bparams) const
1033 Paragraph const * par = this;
1034 depth_type par_depth = getDepth();
1036 string const & layout = par->layout();
1037 int const endlabeltype =
1038 textclasslist[bparams.textclass][layout].endlabeltype;
1039 if (endlabeltype != END_LABEL_NO_LABEL) {
1041 return endlabeltype;
1043 depth_type const next_depth = next_->getDepth();
1044 if (par_depth > next_depth ||
1045 (par_depth == next_depth
1046 && layout != next_->layout()))
1047 return endlabeltype;
1052 par = par->outerHook();
1054 par_depth = par->getDepth();
1056 return END_LABEL_NO_LABEL;
1060 Paragraph::depth_type Paragraph::getDepth() const
1062 return params().depth();
1066 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1068 bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
1071 return params().depth() + 1;
1073 return params().depth();
1077 char Paragraph::getAlign() const
1079 return params().align();
1083 string const & Paragraph::getLabelstring() const
1085 return params().labelString();
1089 int Paragraph::getFirstCounter(int i) const
1091 return pimpl_->counter_[i];
1095 // the next two functions are for the manual labels
1096 string const Paragraph::getLabelWidthString() const
1098 if (!params().labelWidthString().empty())
1099 return params().labelWidthString();
1101 return _("Senseless with this layout!");
1105 void Paragraph::setLabelWidthString(string const & s)
1107 params().labelWidthString(s);
1111 void Paragraph::applyLayout(string const & new_layout)
1114 params().labelWidthString(string());
1115 params().align(LYX_ALIGN_LAYOUT);
1116 params().spaceTop(VSpace(VSpace::NONE));
1117 params().spaceBottom(VSpace(VSpace::NONE));
1118 params().spacing(Spacing(Spacing::Default));
1122 // if the layout of a paragraph contains a manual label, the beginning of the
1123 // main body is the beginning of the second word. This is what the par-
1124 // function returns. If the layout does not contain a label, the main
1125 // body always starts with position 0. This differentiation is necessary,
1126 // because there cannot be a newline or a blank <= the beginning of the
1127 // main body in TeX.
1129 int Paragraph::beginningOfMainBody() const
1131 // Unroll the first two cycles of the loop
1132 // and remember the previous character to
1133 // remove unnecessary GetChar() calls
1136 && getChar(i) != Paragraph::META_NEWLINE) {
1138 char previous_char = 0;
1141 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1142 // Yes, this ^ is supposed to be "= " not "=="
1145 && previous_char != ' '
1146 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1148 previous_char = temp;
1157 Paragraph * Paragraph::depthHook(depth_type depth)
1159 Paragraph * newpar = this;
1162 newpar = newpar->previous();
1163 } while (newpar && newpar->getDepth() > depth);
1166 if (previous() || getDepth())
1167 lyxerr << "ERROR (Paragraph::DepthHook): "
1176 Paragraph const * Paragraph::depthHook(depth_type depth) const
1178 Paragraph const * newpar = this;
1181 newpar = newpar->previous();
1182 } while (newpar && newpar->getDepth() > depth);
1185 if (previous() || getDepth())
1186 lyxerr << "ERROR (Paragraph::DepthHook): "
1194 Paragraph * Paragraph::outerHook()
1198 return depthHook(depth_type(getDepth() - 1));
1201 Paragraph const * Paragraph::outerHook() const
1205 return depthHook(depth_type(getDepth() - 1));
1209 Paragraph::inset_iterator
1210 Paragraph::InsetIterator(pos_type pos)
1212 InsetList::iterator it = insetlist.begin();
1213 InsetList::iterator end = insetlist.end();
1214 for (; it != end; ++it) {
1219 return inset_iterator(it);
1223 // returns -1 if inset not found
1224 int Paragraph::getPositionOfInset(Inset const * inset) const
1227 InsetList::const_iterator cit = insetlist.begin();
1228 InsetList::const_iterator end = insetlist.end();
1229 for (; cit != end; ++cit) {
1230 if (cit->inset == inset) {
1234 if (inset == bibkey)
1241 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1242 BufferParams const & bparams,
1243 ostream & os, TexRow & texrow,
1246 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1247 Inset const * in = inInset();
1248 bool further_blank_line = false;
1251 // well we have to check if we are in an inset with unlimited
1252 // lenght (all in one row) if that is true then we don't allow
1253 // any special options in the paragraph and also we don't allow
1254 // any environment other then "Standard" to be valid!
1255 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1256 style = textclasslist[bparams.textclass][layout()];
1258 if (params().startOfAppendix()) {
1259 os << "\\appendix\n";
1263 if (!params().spacing().isDefault()
1264 && (!previous() || !previous()->hasSameLayout(this))) {
1265 os << params().spacing().writeEnvirBegin() << "\n";
1269 if (tex_code_break_column && style.isCommand()) {
1274 if (params().pagebreakTop()) {
1276 further_blank_line = true;
1278 if (params().spaceTop().kind() != VSpace::NONE) {
1279 os << params().spaceTop().asLatexCommand(bparams);
1280 further_blank_line = true;
1283 if (params().lineTop()) {
1284 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1285 << "\\vspace{-1\\parskip}";
1286 further_blank_line = true;
1289 if (further_blank_line) {
1294 style = textclasslist[bparams.textclass].defaultLayout();
1297 Language const * language = getParLanguage(bparams);
1298 Language const * doc_language = bparams.language;
1299 Language const * previous_language = previous()
1300 ? previous()->getParLanguage(bparams) : doc_language;
1302 if (language->babel() != previous_language->babel()
1303 // check if we already put language command in TeXEnvironment()
1304 && !(style.isEnvironment()
1305 && (!previous() || previous()->layout() != layout() ||
1306 previous()->params().depth() != params().depth())))
1308 if (!lyxrc.language_command_end.empty() &&
1309 previous_language->babel() != doc_language->babel())
1311 os << subst(lyxrc.language_command_end, "$$lang",
1312 previous_language->babel())
1317 if (lyxrc.language_command_end.empty() ||
1318 language->babel() != doc_language->babel())
1320 os << subst(lyxrc.language_command_begin, "$$lang",
1327 if (bparams.inputenc == "auto" &&
1328 language->encoding() != previous_language->encoding()) {
1329 os << "\\inputencoding{"
1330 << language->encoding()->LatexName()
1335 switch (style.latextype) {
1338 << style.latexname()
1339 << style.latexparam();
1341 case LATEX_ITEM_ENVIRONMENT:
1343 bibkey->latex(buf, os, false, false);
1347 case LATEX_LIST_ENVIRONMENT:
1354 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1356 // Make sure that \\par is done with the font of the last
1357 // character if this has another size as the default.
1358 // This is necessary because LaTeX (and LyX on the screen)
1359 // calculates the space between the baselines according
1360 // to this font. (Matthias)
1362 // Is this really needed ? (Dekel)
1363 // We do not need to use to change the font for the last paragraph
1364 // or for a command.
1365 LyXFont const font =
1367 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1369 bool is_command = style.isCommand();
1371 if (style.resfont.size() != font.size() && next_ && !is_command) {
1374 os << "\\" << font.latexSize() << " \\par}";
1375 } else if (need_par) {
1377 } else if (is_command)
1380 switch (style.latextype) {
1381 case LATEX_ITEM_ENVIRONMENT:
1382 case LATEX_LIST_ENVIRONMENT:
1383 if (next_ && (params().depth() < next_->params().depth())) {
1388 case LATEX_ENVIRONMENT:
1389 // if its the last paragraph of the current environment
1390 // skip it otherwise fall through
1392 && (next_->layout() != layout()
1393 || next_->params().depth() != params().depth()))
1395 // fall through possible
1397 // we don't need it for the last paragraph!!!
1404 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1405 further_blank_line = false;
1406 if (params().lineBottom()) {
1407 os << "\\lyxline{\\" << font.latexSize() << '}';
1408 further_blank_line = true;
1411 if (params().spaceBottom().kind() != VSpace::NONE) {
1412 os << params().spaceBottom().asLatexCommand(bparams);
1413 further_blank_line = true;
1416 if (params().pagebreakBottom()) {
1418 further_blank_line = true;
1421 if (further_blank_line) {
1426 if (!params().spacing().isDefault()
1427 && (!next_ || !next_->hasSameLayout(this))) {
1428 os << params().spacing().writeEnvirEnd() << "\n";
1433 // we don't need it for the last paragraph!!!
1438 // Since \selectlanguage write the language to the aux file,
1439 // we need to reset the language at the end of footnote or
1442 if (language->babel() != doc_language->babel()) {
1443 if (lyxrc.language_command_end.empty())
1444 os << subst(lyxrc.language_command_begin,
1446 doc_language->babel())
1449 os << subst(lyxrc.language_command_end,
1457 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1461 // This could go to ParagraphParameters if we want to
1462 int Paragraph::startTeXParParams(BufferParams const & bparams,
1467 if (params().noindent()) {
1468 os << "\\noindent ";
1472 switch (params().align()) {
1473 case LYX_ALIGN_NONE:
1474 case LYX_ALIGN_BLOCK:
1475 case LYX_ALIGN_LAYOUT:
1476 case LYX_ALIGN_SPECIAL:
1478 case LYX_ALIGN_LEFT:
1479 if (getParLanguage(bparams)->babel() != "hebrew") {
1480 os << "\\begin{flushleft}";
1483 os << "\\begin{flushright}";
1487 case LYX_ALIGN_RIGHT:
1488 if (getParLanguage(bparams)->babel() != "hebrew") {
1489 os << "\\begin{flushright}";
1492 os << "\\begin{flushleft}";
1496 case LYX_ALIGN_CENTER:
1497 os << "\\begin{center}";
1505 // This could go to ParagraphParameters if we want to
1506 int Paragraph::endTeXParParams(BufferParams const & bparams,
1511 switch (params().align()) {
1512 case LYX_ALIGN_NONE:
1513 case LYX_ALIGN_BLOCK:
1514 case LYX_ALIGN_LAYOUT:
1515 case LYX_ALIGN_SPECIAL:
1517 case LYX_ALIGN_LEFT:
1518 if (getParLanguage(bparams)->babel() != "hebrew") {
1519 os << "\\end{flushleft}";
1522 os << "\\end{flushright}";
1526 case LYX_ALIGN_RIGHT:
1527 if (getParLanguage(bparams)->babel() != "hebrew") {
1528 os << "\\end{flushright}";
1531 os << "\\end{flushleft}";
1535 case LYX_ALIGN_CENTER:
1536 os << "\\end{center}";
1544 // This one spits out the text of the paragraph
1545 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1546 BufferParams const & bparams,
1547 ostream & os, TexRow & texrow,
1550 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1552 bool return_value = false;
1556 // well we have to check if we are in an inset with unlimited
1557 // lenght (all in one row) if that is true then we don't allow
1558 // any special options in the paragraph and also we don't allow
1559 // any environment other then "Standard" to be valid!
1561 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1564 style = textclasslist[bparams.textclass].defaultLayout();
1566 style = textclasslist[bparams.textclass][layout()];
1571 // Maybe we have to create a optional argument.
1573 if (style.labeltype != LABEL_MANUAL)
1576 main_body = beginningOfMainBody();
1580 if (main_body > 0) {
1583 basefont = getLabelFont(bparams);
1585 basefont = getLayoutFont(bparams);
1588 moving_arg |= style.needprotect;
1590 // Which font is currently active?
1591 LyXFont running_font(basefont);
1592 // Do we have an open font change?
1593 bool open_font = false;
1595 texrow.start(this, 0);
1597 // if the paragraph is empty, the loop will not be entered at all
1599 if (style.isCommand()) {
1604 column += startTeXParParams(bparams, os);
1608 for (pos_type i = 0; i < size(); ++i) {
1610 // First char in paragraph or after label?
1611 if (i == main_body) {
1612 if (main_body > 0) {
1614 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1617 basefont = getLayoutFont(bparams);
1618 running_font = basefont;
1622 if (style.isCommand()) {
1628 column += startTeXParParams(bparams, os);
1631 value_type c = getChar(i);
1633 // Fully instantiated font
1634 LyXFont font = getFont(bparams, i);
1636 LyXFont const & last_font = running_font;
1638 // Spaces at end of font change are simulated to be
1639 // outside font change, i.e. we write "\textXX{text} "
1640 // rather than "\textXX{text }". (Asger)
1641 if (open_font && c == ' ' && i <= size() - 2) {
1642 LyXFont const & next_font = getFont(bparams, i + 1);
1643 if (next_font != running_font
1644 && next_font != font) {
1649 // We end font definition before blanks
1650 if (font != running_font && open_font) {
1651 column += running_font.latexWriteEndChanges(os,
1653 (i == main_body-1) ? basefont : font);
1654 running_font = basefont;
1658 // Blanks are printed before start of fontswitch
1660 // Do not print the separation of the optional argument
1661 if (i != main_body - 1) {
1662 pimpl_->simpleTeXBlanks(os, texrow, i,
1663 column, font, style);
1667 // Do we need to change font?
1668 if (font != running_font && i != main_body - 1) {
1669 column += font.latexWriteStartChanges(os, basefont,
1671 running_font = font;
1675 if (c == Paragraph::META_NEWLINE) {
1676 // newlines are handled differently here than
1677 // the default in SimpleTeXSpecialChars().
1678 if (!style.newline_allowed) {
1682 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1685 basefont = getLayoutFont(bparams);
1686 running_font = basefont;
1687 if (font.family() ==
1688 LyXFont::TYPEWRITER_FAMILY) {
1696 texrow.start(this, i + 1);
1699 pimpl_->simpleTeXSpecialChars(buf, bparams,
1700 os, texrow, moving_arg,
1702 basefont, open_font,
1703 style, i, column, c);
1707 // If we have an open font definition, we have to close it
1709 #ifdef FIXED_LANGUAGE_END_DETECTION
1712 .latexWriteEndChanges(os, basefont,
1713 next_->getFont(bparams,
1716 running_font.latexWriteEndChanges(os, basefont,
1720 #ifdef WITH_WARNINGS
1721 //#warning For now we ALWAYS have to close the foreign font settings if they are
1722 //#warning there as we start another \selectlanguage with the next paragraph if
1723 //#warning we are in need of this. This should be fixed sometime (Jug)
1725 running_font.latexWriteEndChanges(os, basefont, basefont);
1729 // Needed if there is an optional argument but no contents.
1730 if (main_body > 0 && main_body == size()) {
1732 return_value = false;
1736 column += endTeXParParams(bparams, os);
1739 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1740 return return_value;
1744 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1746 bool retval = false;
1748 case Paragraph::META_HFILL:
1749 sgml_string.erase();
1751 case Paragraph::META_NEWLINE:
1755 sgml_string = "&";
1758 sgml_string = "<";
1761 sgml_string = ">";
1764 sgml_string = "$";
1767 sgml_string = "#";
1770 sgml_string = "%";
1773 sgml_string = "[";
1776 sgml_string = "]";
1779 sgml_string = "{";
1782 sgml_string = "}";
1785 sgml_string = "˜";
1788 sgml_string = """;
1791 sgml_string = "\";
1797 case '\0': // Ignore :-)
1798 sgml_string.erase();
1808 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1809 BufferParams const & bparams,
1810 ostream & os, TexRow & texrow)
1812 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1814 LyXLayout const & style =
1815 textclasslist[bparams.textclass][layout()];
1817 Language const * language = getParLanguage(bparams);
1818 Language const * doc_language = bparams.language;
1819 Language const * previous_language = previous_
1820 ? previous_->getParLanguage(bparams) : doc_language;
1821 if (language->babel() != previous_language->babel()) {
1823 if (!lyxrc.language_command_end.empty() &&
1824 previous_language->babel() != doc_language->babel()) {
1825 os << subst(lyxrc.language_command_end, "$$lang",
1826 previous_language->babel())
1831 if (lyxrc.language_command_end.empty() ||
1832 language->babel() != doc_language->babel()) {
1833 os << subst(lyxrc.language_command_begin, "$$lang",
1840 if (style.isEnvironment()) {
1841 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1842 os << "\\begin{" << style.latexname() << "}{"
1843 << params().labelWidthString() << "}\n";
1844 } else if (style.labeltype == LABEL_BIBLIO) {
1846 os << "\\begin{" << style.latexname() << "}{"
1847 << bibitemWidest(buf)
1849 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1850 os << "\\begin{" << style.latexname() << '}'
1851 << style.latexparam() << '\n';
1853 os << "\\begin{" << style.latexname() << '}'
1854 << style.latexparam() << '\n';
1857 Paragraph * par = this;
1859 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1861 if (par && par->params().depth() > params().depth()) {
1862 if (textclasslist[bparams.textclass][par->layout()].isParagraph()
1864 // How to handle this? (Lgb)
1865 //&& !suffixIs(os, "\n\n")
1867 // There should be at least one '\n' already
1868 // but we need there to be two for Standard
1869 // paragraphs that are depth-increment'ed to be
1870 // output correctly. However, tables can
1871 // also be paragraphs so don't adjust them.
1874 // Will it ever harm to have one '\n' too
1875 // many? i.e. that we sometimes will have
1876 // three in a row. (Lgb)
1880 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1883 && par->layout() == layout()
1884 && par->params().depth() == params().depth());
1886 if (style.isEnvironment()) {
1887 os << "\\end{" << style.latexname() << "}\n";
1891 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1892 return par; // ale970302
1896 bool Paragraph::isHfill(pos_type pos) const
1898 return IsHfillChar(getChar(pos));
1902 bool Paragraph::isInset(pos_type pos) const
1904 return IsInsetChar(getChar(pos));
1908 bool Paragraph::isNewline(pos_type pos) const
1910 return pos >= 0 && IsNewlineChar(getChar(pos));
1914 bool Paragraph::isSeparator(pos_type pos) const
1916 return IsSeparatorChar(getChar(pos));
1920 bool Paragraph::isLineSeparator(pos_type pos) const
1922 value_type const c = getChar(pos);
1923 return IsLineSeparatorChar(c)
1924 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1928 bool Paragraph::isKomma(pos_type pos) const
1930 return IsKommaChar(getChar(pos));
1934 /// Used by the spellchecker
1935 bool Paragraph::isLetter(pos_type pos) const
1937 value_type const c = getChar(pos);
1938 if (IsLetterChar(c))
1941 return getInset(pos)->isLetter();
1942 // We want to pass the ' and escape chars to ispell
1943 string const extra = lyxrc.isp_esc_chars + '\'';
1944 return contains(extra, c);
1948 bool Paragraph::isWord(pos_type pos) const
1950 return IsWordChar(getChar(pos)) ;
1955 Paragraph::getParLanguage(BufferParams const & bparams) const
1958 #ifndef INHERIT_LANGUAGE
1959 return getFirstFontSettings().language();
1961 Language const * lang = getFirstFontSettings().language();
1962 #ifdef WITH_WARNINGS
1963 #warning We should make this somewhat better, any ideas? (Jug)
1965 if (lang == inherit_language || lang == ignore_language)
1966 lang = bparams.language;
1969 } else if (previous_)
1970 return previous_->getParLanguage(bparams);
1972 return bparams.language;
1976 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1978 return lyxrc.rtl_support
1979 && getParLanguage(bparams)->RightToLeft();
1983 void Paragraph::changeLanguage(BufferParams const & bparams,
1984 Language const * from, Language const * to)
1986 for (pos_type i = 0; i < size(); ++i) {
1987 LyXFont font = getFontSettings(bparams, i);
1988 if (font.language() == from) {
1989 font.setLanguage(to);
1996 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1998 Language const * doc_language = bparams.language;
1999 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
2000 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
2002 for (; cit != end; ++cit)
2003 if (cit->font().language() != ignore_language &&
2004 cit->font().language() != latex_language &&
2005 #ifdef INHERIT_LANGUAGE
2006 cit->font().language() != inherit_language &&
2008 cit->font().language() != doc_language)
2014 // Convert the paragraph to a string.
2015 // Used for building the table of contents
2016 string const Paragraph::asString(Buffer const * buffer, bool label)
2018 BufferParams const & bparams = buffer->params;
2020 if (label && !params().labelString().empty())
2021 s += params().labelString() + ' ';
2022 string::size_type const len = s.size();
2024 for (pos_type i = 0; i < size(); ++i) {
2025 value_type c = getChar(i);
2028 else if (c == META_INSET &&
2029 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2031 getInset(i)->ascii(buffer, ost);
2032 s += subst(ost.str().c_str(),'\n',' ');
2036 if (isRightToLeftPar(bparams))
2037 reverse(s.begin() + len,s.end());
2043 string const Paragraph::asString(Buffer const * buffer,
2044 pos_type beg, pos_type end, bool label)
2048 if (beg == 0 && label && !params().labelString().empty())
2049 ost << params().labelString() << ' ';
2051 for (pos_type i = beg; i < end; ++i) {
2052 value_type const c = getUChar(buffer->params, i);
2055 else if (c == META_NEWLINE)
2057 else if (c == META_HFILL)
2059 else if (c == META_INSET) {
2060 getInset(i)->ascii(buffer, ost);
2064 return ost.str().c_str();
2068 void Paragraph::setInsetOwner(Inset * i)
2070 pimpl_->inset_owner = i;
2071 InsetList::const_iterator cit = insetlist.begin();
2072 InsetList::const_iterator end = insetlist.end();
2073 for (; cit != end; ++cit) {
2075 cit->inset->setOwner(i);
2080 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2083 InsetList::const_iterator cit = insetlist.begin();
2084 InsetList::const_iterator end = insetlist.end();
2085 for (; cit != end; ++cit) {
2086 if (cit->inset && cit->inset->isTextInset()) {
2087 static_cast<UpdatableInset *>
2088 (cit->inset)->deleteLyXText(bv, true);
2094 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2097 InsetList::const_iterator cit = insetlist.begin();
2098 InsetList::const_iterator end = insetlist.end();
2099 for (; cit != end; ++cit) {
2101 if (cit->inset->isTextInset()) {
2102 static_cast<UpdatableInset *>
2103 (cit->inset)->resizeLyXText(bv, true);
2110 void Paragraph::setContentsFromPar(Paragraph * par)
2112 pimpl_->setContentsFromPar(par);
2116 lyx::pos_type Paragraph::size() const
2118 return pimpl_->size();
2122 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2124 return pimpl_->getChar(pos);
2128 int Paragraph::id() const
2134 void Paragraph::id(int id_arg)
2136 pimpl_->id_ = id_arg;
2140 string const & Paragraph::layout() const
2146 void Paragraph::layout(string const & new_layout)
2148 lyx::Assert(!new_layout.empty());
2150 layout_ = new_layout;
2154 bool Paragraph::isFirstInSequence() const
2156 Paragraph const * dhook = depthHook(getDepth());
2157 return (dhook == this
2158 || dhook->layout() != layout()
2159 || dhook->getDepth() != getDepth());
2163 Inset * Paragraph::inInset() const
2165 return pimpl_->inset_owner;
2169 void Paragraph::clearContents()
2175 void Paragraph::setCounter(int i, int v)
2177 pimpl_->counter_[i] = v;
2181 int Paragraph::getCounter(int i) const
2183 return pimpl_->counter_[i];
2187 void Paragraph::incCounter(int i)
2189 pimpl_->counter_[i]++;
2193 void Paragraph::setChar(pos_type pos, value_type c)
2195 pimpl_->setChar(pos, c);
2199 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2204 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2206 return inset_iterator(insetlist.begin());
2210 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2212 return inset_iterator(insetlist.end());
2216 ParagraphParameters & Paragraph::params()
2218 return pimpl_->params;
2222 ParagraphParameters const & Paragraph::params() const
2224 return pimpl_->params;
2228 Paragraph * Paragraph::getParFromID(int id) const
2230 return pimpl_->getParFromID(id);
2234 bool Paragraph::isFreeSpacing() const
2236 // for now we just need this, later should we need this in some
2237 // other way we can always add a function to Inset::() too.
2238 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2239 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);