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"
27 #include "lyx_gui_misc.h"
29 #include "BufferView.h"
31 #include "ParameterStruct.h"
33 #include "lyxtextclasslist.h"
35 #include "insets/insetinclude.h"
36 #include "insets/insetbib.h"
37 #include "insets/insettext.h"
39 #include "support/filetools.h"
40 #include "support/lstrings.h"
41 #include "support/lyxmanip.h"
42 #include "support/FileInfo.h"
43 #include "support/LAssert.h"
44 #include "support/textutils.h"
54 using std::lower_bound;
55 using std::upper_bound;
59 using lyx::layout_type;
61 int tex_code_break_column = 72; // needs non-zero initialization. set later.
62 // this is a bad idea, but how can Paragraph find its buffer to get
63 // parameters? (JMarc)
65 extern string bibitemWidest(Buffer const *);
67 // this is a minibuffer
72 LyXFont minibuffer_font;
73 Inset * minibuffer_inset;
78 extern BufferView * current_view;
81 Paragraph::Paragraph()
82 : layout(0), pimpl_(new Paragraph::Pimpl(this))
84 for (int i = 0; i < 10; ++i)
90 bibkey = 0; // ale970302
95 // This constructor inserts the new paragraph in a list.
96 Paragraph::Paragraph(Paragraph * par)
97 : layout(0), pimpl_(new Paragraph::Pimpl(this))
99 for (int i = 0; i < 10; ++i)
104 // double linked list begin
107 next_->previous_ = this;
109 previous_->next_ = this;
112 bibkey = 0; // ale970302
118 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
119 : layout(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
121 for (int i = 0; i < 10; ++i)
128 // this is because of the dummy layout of the paragraphs that
134 bibkey = static_cast<InsetBibKey *>
135 (lp.bibkey->clone(*current_view->buffer()));
140 // copy everything behind the break-position to the new paragraph
141 insetlist = lp.insetlist;
142 for (InsetList::iterator it = insetlist.begin();
143 it != insetlist.end(); ++it)
145 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
146 // tell the new inset who is the boss now
147 it->inset->parOwner(this);
152 // the destructor removes the new paragraph from the list
153 Paragraph::~Paragraph()
156 previous_->next_ = next_;
158 next_->previous_ = previous_;
160 for (InsetList::iterator it = insetlist.begin();
161 it != insetlist.end(); ++it) {
170 //lyxerr << "Paragraph::paragraph_id = "
171 // << Paragraph::paragraph_id << endl;
175 void Paragraph::writeFile(Buffer const * buf, ostream & os,
176 BufferParams const & bparams,
177 depth_type dth) const
179 // The beginning or end of a deeper (i.e. nested) area?
180 if (dth != params().depth()) {
181 if (params().depth() > dth) {
182 while (params().depth() > dth) {
183 os << "\n\\begin_deeper ";
187 while (params().depth() < dth) {
188 os << "\n\\end_deeper ";
194 // First write the layout
196 << textclasslist.NameOfLayout(bparams.textclass, layout)
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(getLayout());
348 Language const * doc_language = bparams.language;
350 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
351 cit != pimpl_->fontlist.end(); ++cit) {
352 if (cit->font().noun() == LyXFont::ON) {
353 lyxerr[Debug::LATEX] << "font.noun: "
354 << cit->font().noun()
356 features.require("noun");
357 lyxerr[Debug::LATEX] << "Noun enabled. Font: "
358 << cit->font().stateText(0)
361 switch (cit->font().color()) {
363 case LColor::inherit:
365 // probably we should put here all interface colors used for
366 // font displaying! For now I just add this ones I know of (Jug)
371 features.require("color");
372 lyxerr[Debug::LATEX] << "Color enabled. Font: "
373 << cit->font().stateText(0)
377 Language const * language = cit->font().language();
378 if (language->babel() != doc_language->babel() &&
379 language != ignore_language &&
380 #ifdef INHERIT_LANGUAGE
381 language != inherit_language &&
383 language != latex_language)
385 features.useLanguage(language);
386 lyxerr[Debug::LATEX] << "Found language "
387 << language->babel() << endl;
392 LyXLayout const & layout =
393 textclasslist.Style(bparams.textclass, getLayout());
395 for (InsetList::const_iterator cit = insetlist.begin();
396 cit != insetlist.end(); ++cit) {
398 cit->inset->validate(features);
399 if (layout.needprotect &&
400 cit->inset->lyxCode() == Inset::FOOT_CODE)
401 features.require("NeedLyXFootnoteCode");
407 // First few functions needed for cut and paste and paragraph breaking.
408 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
410 BufferParams bparams = buffer.params;
412 minibuffer_char = getChar(pos);
413 minibuffer_font = getFontSettings(bparams, pos);
414 minibuffer_inset = 0;
415 if (minibuffer_char == Paragraph::META_INSET) {
417 minibuffer_inset = getInset(pos)->clone(buffer);
419 minibuffer_inset = 0;
420 minibuffer_char = ' ';
421 // This reflects what GetInset() does (ARRae)
427 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
429 minibuffer_char = getChar(pos);
430 minibuffer_font = getFontSettings(bparams, pos);
431 minibuffer_inset = 0;
432 if (minibuffer_char == Paragraph::META_INSET) {
434 minibuffer_inset = getInset(pos);
435 // This is a little hack since I want exactly
436 // the inset, not just a clone. Otherwise
437 // the inset would be deleted when calling Erase(pos)
439 InsetTable search_elem(pos, 0);
440 InsetList::iterator it =
441 lower_bound(insetlist.begin(),
443 search_elem, Pimpl::matchIT());
444 if (it != insetlist.end() && it->pos == pos)
446 // the inset is not in a paragraph anymore
447 minibuffer_inset->parOwner(0);
449 minibuffer_inset = 0;
450 minibuffer_char = ' ';
451 // This reflects what GetInset() does (ARRae)
456 // Erase(pos); now the caller is responsible for that.
460 bool Paragraph::insertFromMinibuffer(pos_type pos)
462 if (minibuffer_char == Paragraph::META_INSET) {
463 if (!insetAllowed(minibuffer_inset->lyxCode())) {
466 insertInset(pos, minibuffer_inset, minibuffer_font);
468 LyXFont f = minibuffer_font;
469 if (!checkInsertChar(f)) {
472 insertChar(pos, minibuffer_char, f);
481 void Paragraph::clear()
490 void Paragraph::erase(pos_type pos)
496 bool Paragraph::checkInsertChar(LyXFont & font)
498 if (pimpl_->inset_owner)
499 return pimpl_->inset_owner->checkInsertChar(font);
504 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
506 LyXFont const f(LyXFont::ALL_INHERIT);
507 insertChar(pos, c, f);
511 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
512 LyXFont const & font)
514 pimpl_->insertChar(pos, c, font);
518 void Paragraph::insertInset(pos_type pos, Inset * inset)
520 LyXFont const f(LyXFont::ALL_INHERIT);
521 insertInset(pos, inset, f);
525 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
527 pimpl_->insertInset(pos, inset, font);
531 bool Paragraph::insetAllowed(Inset::Code code)
533 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
535 if (pimpl_->inset_owner)
536 return pimpl_->inset_owner->insetAllowed(code);
541 Inset * Paragraph::getInset(pos_type pos)
543 lyx::Assert(pos < size());
546 InsetTable search_inset(pos, 0);
547 InsetList::iterator it = lower_bound(insetlist.begin(),
549 search_inset, Pimpl::matchIT());
550 if (it != insetlist.end() && it->pos == pos)
553 lyxerr << "ERROR (Paragraph::getInset): "
554 "Inset does not exist: " << pos << endl;
557 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
558 // Did this commenting out introduce a bug? So far I have not
559 // see any, please enlighten me. (Lgb)
560 // My guess is that since the inset does not exist, we might
561 // as well replace it with a space to prevent craches. (Asger)
566 Inset const * Paragraph::getInset(pos_type pos) const
568 lyx::Assert(pos < size());
571 InsetTable search_inset(pos, 0);
572 InsetList::const_iterator cit = lower_bound(insetlist.begin(),
574 search_inset, Pimpl::matchIT());
575 if (cit != insetlist.end() && cit->pos == pos)
578 lyxerr << "ERROR (Paragraph::GetInset): "
579 "Inset does not exist: " << pos << endl;
581 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
582 // Did this commenting out introduce a bug? So far I have not
583 // see any, please enlighten me. (Lgb)
584 // My guess is that since the inset does not exist, we might
585 // as well replace it with a space to prevent craches. (Asger)
590 // Gets uninstantiated font setting at position.
591 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
594 lyx::Assert(pos <= size());
596 Pimpl::FontTable search_font(pos, LyXFont());
597 Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
598 pimpl_->fontlist.end(),
599 search_font, Pimpl::matchFT());
601 if (cit != pimpl_->fontlist.end()) {
602 retfont = cit->font();
603 } else if (pos == size() && size()) {
604 retfont = getFontSettings(bparams, pos - 1);
606 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
607 #ifdef INHERIT_LANGUAGE
608 if (retfont.language() == inherit_language)
609 retfont.setLanguage(bparams.language);
616 // Gets uninstantiated font setting at position 0
617 LyXFont const Paragraph::getFirstFontSettings() const
619 if (size() > 0 && !pimpl_->fontlist.empty())
620 return pimpl_->fontlist[0].font();
622 return LyXFont(LyXFont::ALL_INHERIT);
626 // Gets the fully instantiated font at a given position in a paragraph
627 // This is basically the same function as LyXText::GetFont() in text2.C.
628 // The difference is that this one is used for generating the LaTeX file,
629 // and thus cosmetic "improvements" are disallowed: This has to deliver
630 // the true picture of the buffer. (Asger)
631 // If position is -1, we get the layout font of the paragraph.
632 // If position is -2, we get the font of the manual label of the paragraph.
633 LyXFont const Paragraph::getFont(BufferParams const & bparams,
636 lyx::Assert(pos >= 0);
638 LyXLayout const & layout =
639 textclasslist.Style(bparams.textclass,
641 pos_type main_body = 0;
642 if (layout.labeltype == LABEL_MANUAL)
643 main_body = beginningOfMainBody();
647 layoutfont = layout.labelfont;
649 layoutfont = layout.font;
651 LyXFont tmpfont = getFontSettings(bparams, pos);
652 #ifndef INHERIT_LANGUAGE
653 tmpfont.realize(layoutfont);
655 tmpfont.realize(layoutfont, bparams.language);
658 return pimpl_->realizeFont(tmpfont, bparams);
662 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
664 LyXLayout const & layout =
665 textclasslist.Style(bparams.textclass, getLayout());
667 LyXFont tmpfont = layout.labelfont;
668 tmpfont.setLanguage(getParLanguage(bparams));
670 return pimpl_->realizeFont(tmpfont, bparams);
674 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
676 LyXLayout const & layout =
677 textclasslist.Style(bparams.textclass,
680 LyXFont tmpfont = layout.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 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
696 Pimpl::FontTable end_search(endpos, LyXFont());
697 Pimpl::FontList::const_iterator end_it =
698 lower_bound(pimpl_->fontlist.begin(),
699 pimpl_->fontlist.end(),
700 end_search, Pimpl::matchFT());
701 if (end_it != pimpl_->fontlist.end())
704 Pimpl::FontTable start_search(startpos, LyXFont());
705 Pimpl::FontList::const_iterator cit =
706 lower_bound(pimpl_->fontlist.begin(),
707 pimpl_->fontlist.end(),
708 start_search, Pimpl::matchFT());
710 for (; cit != end_it; ++cit) {
711 LyXFont::FONT_SIZE size = cit->font().size();
712 if (size == LyXFont::INHERIT_SIZE)
714 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
721 Paragraph::value_type
722 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
724 value_type c = getChar(pos);
725 if (!lyxrc.rtl_support)
755 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
762 void Paragraph::setFont(pos_type pos, LyXFont const & font)
764 lyx::Assert(pos <= size());
766 // First, reduce font against layout/label font
767 // Update: The SetCharFont() routine in text2.C already
768 // reduces font, so we don't need to do that here. (Asger)
769 // No need to simplify this because it will disappear
770 // in a new kernel. (Asger)
771 // Next search font table
773 Pimpl::FontTable search_font(pos, LyXFont());
774 Pimpl::FontList::iterator it = lower_bound(pimpl_->fontlist.begin(),
775 pimpl_->fontlist.end(),
776 search_font, Pimpl::matchFT());
777 unsigned int i = it - pimpl_->fontlist.begin();
778 bool notfound = it == pimpl_->fontlist.end();
780 if (!notfound && pimpl_->fontlist[i].font() == font)
783 bool begin = pos == 0 || notfound ||
784 (i > 0 && pimpl_->fontlist[i-1].pos() == pos - 1);
785 // Is position pos is a beginning of a font block?
786 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
787 // Is position pos is the end of a font block?
788 if (begin && end) { // A single char block
789 if (i + 1 < pimpl_->fontlist.size() &&
790 pimpl_->fontlist[i + 1].font() == font) {
791 // Merge the singleton block with the next block
792 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
793 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
794 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
795 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
796 // Merge the singleton block with the previous block
797 pimpl_->fontlist[i - 1].pos(pos);
798 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
800 pimpl_->fontlist[i].font(font);
802 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
803 pimpl_->fontlist[i - 1].pos(pos);
805 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
806 Pimpl::FontTable(pos, font));
808 pimpl_->fontlist[i].pos(pos - 1);
809 if (!(i + 1 < pimpl_->fontlist.size() &&
810 pimpl_->fontlist[i + 1].font() == font))
811 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
812 Pimpl::FontTable(pos, font));
813 } else { // The general case. The block is splitted into 3 blocks
814 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
815 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
816 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
817 Pimpl::FontTable(pos, font));
823 void Paragraph::next(Paragraph * p)
829 // This function is able to hide closed footnotes.
830 Paragraph * Paragraph::next()
836 Paragraph const * Paragraph::next() const
842 void Paragraph::previous(Paragraph * p)
848 // This function is able to hide closed footnotes.
849 Paragraph * Paragraph::previous()
855 // This function is able to hide closed footnotes.
856 Paragraph const * Paragraph::previous() const
862 void Paragraph::breakParagraph(BufferParams const & bparams,
866 // create a new paragraph
867 Paragraph * tmp = new Paragraph(this);
868 // remember to set the inset_owner
869 tmp->setInsetOwner(inInset());
871 // this is an idea for a more userfriendly layout handling, I will
872 // see what the users say
874 // layout stays the same with latex-environments
876 tmp->setOnlyLayout(layout);
877 tmp->setLabelWidthString(params().labelWidthString());
880 if (size() > pos || !size() || flag == 2) {
881 tmp->setOnlyLayout(layout);
882 tmp->params().align(params().align());
883 tmp->setLabelWidthString(params().labelWidthString());
885 tmp->params().lineBottom(params().lineBottom());
886 params().lineBottom(false);
887 tmp->params().pagebreakBottom(params().pagebreakBottom());
888 params().pagebreakBottom(false);
889 tmp->params().spaceBottom(params().spaceBottom());
890 params().spaceBottom(VSpace(VSpace::NONE));
892 tmp->params().depth(params().depth());
893 tmp->params().noindent(params().noindent());
895 // copy everything behind the break-position
896 // to the new paragraph
897 pos_type pos_end = size() - 1;
900 for (; i <= pos_end; ++i) {
901 cutIntoMinibuffer(bparams, i);
902 if (tmp->insertFromMinibuffer(j - pos))
905 for (i = pos_end; i >= pos; --i) {
910 // just an idea of me
912 tmp->params().lineTop(params().lineTop());
913 tmp->params().pagebreakTop(params().pagebreakTop());
914 tmp->params().spaceTop(params().spaceTop());
915 tmp->bibkey = bibkey;
917 // layout stays the same with latex-environments
919 setOnlyLayout(tmp->layout);
920 setLabelWidthString(tmp->params().labelWidthString());
921 params().depth(tmp->params().depth());
927 void Paragraph::makeSameLayout(Paragraph const * par)
929 layout = par->layout;
931 params() = par->params();
935 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
937 if (textclasslist.Style(tclass, getLayout()).free_spacing ||
944 while (size() && (isNewline(0) || isLineSeparator(0))) {
953 bool Paragraph::hasSameLayout(Paragraph const * par) const
956 par->layout == layout &&
957 params().sameLayout(par->params());
961 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
964 // create a new paragraph
965 Paragraph * tmp = new Paragraph(this);
966 tmp->makeSameLayout(this);
968 // When can pos > Last()?
969 // I guess pos == Last() is possible.
971 // copy everything behind the break-position to the new
973 pos_type pos_end = size() - 1;
977 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
978 cutIntoMinibuffer(bparams, i);
979 if (tmp->insertFromMinibuffer(j - pos))
983 for (pos_type k = pos_end; k >= pos; --k) {
990 // Be carefull, this does not make any check at all.
991 // This method has wrong name, it combined this par with the next par.
992 // In that sense it is the reverse of break paragraph. (Lgb)
993 void Paragraph::pasteParagraph(BufferParams const & bparams)
995 // copy the next paragraph to this one
996 Paragraph * the_next = next();
998 // first the DTP-stuff
999 params().lineBottom(the_next->params().lineBottom());
1000 params().spaceBottom(the_next->params().spaceBottom());
1001 params().pagebreakBottom(the_next->params().pagebreakBottom());
1003 pos_type pos_end = the_next->pimpl_->size() - 1;
1004 pos_type pos_insert = size();
1006 // ok, now copy the paragraph
1007 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1008 the_next->cutIntoMinibuffer(bparams, i);
1009 if (insertFromMinibuffer(pos_insert + j))
1013 // delete the next paragraph
1014 Paragraph * ppar = the_next->previous_;
1015 Paragraph * npar = the_next->next_;
1021 int Paragraph::getEndLabel(BufferParams const & bparams) const
1023 Paragraph const * par = this;
1024 depth_type par_depth = getDepth();
1026 layout_type layout = par->getLayout();
1027 int const endlabeltype =
1028 textclasslist.Style(bparams.textclass,
1029 layout).endlabeltype;
1030 if (endlabeltype != END_LABEL_NO_LABEL) {
1032 return endlabeltype;
1034 depth_type const next_depth = next_->getDepth();
1035 if (par_depth > next_depth ||
1036 (par_depth == next_depth
1037 && layout != next_->getLayout()))
1038 return endlabeltype;
1043 par = par->outerHook();
1045 par_depth = par->getDepth();
1047 return END_LABEL_NO_LABEL;
1051 Paragraph::depth_type Paragraph::getDepth() const
1053 return params().depth();
1057 char Paragraph::getAlign() const
1059 return params().align();
1063 string const & Paragraph::getLabelstring() const
1065 return params().labelString();
1069 int Paragraph::getFirstCounter(int i) const
1071 return pimpl_->counter_[i];
1075 // the next two functions are for the manual labels
1076 string const Paragraph::getLabelWidthString() const
1078 if (!params().labelWidthString().empty())
1079 return params().labelWidthString();
1081 return _("Senseless with this layout!");
1085 void Paragraph::setLabelWidthString(string const & s)
1087 params().labelWidthString(s);
1091 void Paragraph::setOnlyLayout(layout_type new_layout)
1093 layout = new_layout;
1097 void Paragraph::setLayout(layout_type new_layout)
1099 layout = new_layout;
1100 params().labelWidthString(string());
1101 params().align(LYX_ALIGN_LAYOUT);
1102 params().spaceTop(VSpace(VSpace::NONE));
1103 params().spaceBottom(VSpace(VSpace::NONE));
1104 params().spacing(Spacing(Spacing::Default));
1108 // if the layout of a paragraph contains a manual label, the beginning of the
1109 // main body is the beginning of the second word. This is what the par-
1110 // function returns. If the layout does not contain a label, the main
1111 // body always starts with position 0. This differentiation is necessary,
1112 // because there cannot be a newline or a blank <= the beginning of the
1113 // main body in TeX.
1115 int Paragraph::beginningOfMainBody() const
1117 // Unroll the first two cycles of the loop
1118 // and remember the previous character to
1119 // remove unnecessary GetChar() calls
1122 && getChar(i) != Paragraph::META_NEWLINE) {
1124 char previous_char = 0;
1127 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1128 // Yes, this ^ is supposed to be "= " not "=="
1131 && previous_char != ' '
1132 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1134 previous_char = temp;
1143 Paragraph * Paragraph::depthHook(depth_type depth)
1145 Paragraph * newpar = this;
1148 newpar = newpar->previous();
1149 } while (newpar && newpar->getDepth() > depth);
1152 if (previous() || getDepth())
1153 lyxerr << "ERROR (Paragraph::DepthHook): "
1162 Paragraph const * Paragraph::depthHook(depth_type depth) const
1164 Paragraph const * newpar = this;
1167 newpar = newpar->previous();
1168 } while (newpar && newpar->getDepth() > depth);
1171 if (previous() || getDepth())
1172 lyxerr << "ERROR (Paragraph::DepthHook): "
1180 Paragraph * Paragraph::outerHook()
1184 return depthHook(depth_type(getDepth() - 1));
1187 Paragraph const * Paragraph::outerHook() const
1191 return depthHook(depth_type(getDepth() - 1));
1195 Paragraph::inset_iterator
1196 Paragraph::InsetIterator(pos_type pos)
1198 InsetTable search_inset(pos, 0);
1199 InsetList::iterator it = lower_bound(insetlist.begin(),
1201 search_inset, Pimpl::matchIT());
1202 return inset_iterator(it);
1206 // returns -1 if inset not found
1207 int Paragraph::getPositionOfInset(Inset const * inset) const
1210 for (InsetList::const_iterator cit = insetlist.begin();
1211 cit != insetlist.end(); ++cit) {
1212 if (cit->inset == inset) {
1216 if (inset == bibkey)
1223 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1224 BufferParams const & bparams,
1225 ostream & os, TexRow & texrow,
1228 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1229 Inset const * in = inInset();
1230 bool further_blank_line = false;
1233 // well we have to check if we are in an inset with unlimited
1234 // lenght (all in one row) if that is true then we don't allow
1235 // any special options in the paragraph and also we don't allow
1236 // any environment other then "Standard" to be valid!
1237 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1238 style = textclasslist.Style(bparams.textclass, layout);
1240 if (params().startOfAppendix()) {
1241 os << "\\appendix\n";
1245 if (!params().spacing().isDefault()
1246 && (!previous() || !previous()->hasSameLayout(this))) {
1247 os << params().spacing().writeEnvirBegin() << "\n";
1251 if (tex_code_break_column && style.isCommand()) {
1256 if (params().pagebreakTop()) {
1258 further_blank_line = true;
1260 if (params().spaceTop().kind() != VSpace::NONE) {
1261 os << params().spaceTop().asLatexCommand(bparams);
1262 further_blank_line = true;
1265 if (params().lineTop()) {
1266 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1267 << "\\vspace{-1\\parskip}";
1268 further_blank_line = true;
1271 if (further_blank_line) {
1276 style = textclasslist.Style(bparams.textclass, 0);
1279 Language const * language = getParLanguage(bparams);
1280 Language const * doc_language = bparams.language;
1281 Language const * previous_language = previous()
1282 ? previous()->getParLanguage(bparams) : doc_language;
1284 if (language->babel() != previous_language->babel()
1285 // check if we already put language command in TeXEnvironment()
1286 && !(style.isEnvironment()
1287 && (!previous() || previous()->layout != layout ||
1288 previous()->params().depth() != params().depth())))
1290 if (!lyxrc.language_command_end.empty() &&
1291 previous_language->babel() != doc_language->babel())
1293 os << subst(lyxrc.language_command_end, "$$lang",
1294 previous_language->babel())
1299 if (lyxrc.language_command_end.empty() ||
1300 language->babel() != doc_language->babel())
1302 os << subst(lyxrc.language_command_begin, "$$lang",
1309 if (bparams.inputenc == "auto" &&
1310 language->encoding() != previous_language->encoding()) {
1311 os << "\\inputencoding{"
1312 << language->encoding()->LatexName()
1317 switch (style.latextype) {
1320 << style.latexname()
1321 << style.latexparam();
1323 case LATEX_ITEM_ENVIRONMENT:
1325 bibkey->latex(buf, os, false, false);
1329 case LATEX_LIST_ENVIRONMENT:
1336 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1338 // Make sure that \\par is done with the font of the last
1339 // character if this has another size as the default.
1340 // This is necessary because LaTeX (and LyX on the screen)
1341 // calculates the space between the baselines according
1342 // to this font. (Matthias)
1344 // Is this really needed ? (Dekel)
1345 // We do not need to use to change the font for the last paragraph
1346 // or for a command.
1347 LyXFont const font =
1349 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1351 bool is_command = style.isCommand();
1353 if (style.resfont.size() != font.size() && next_ && !is_command) {
1356 os << "\\" << font.latexSize() << " \\par}";
1357 } else if (need_par) {
1359 } else if (is_command)
1362 switch (style.latextype) {
1363 case LATEX_ITEM_ENVIRONMENT:
1364 case LATEX_LIST_ENVIRONMENT:
1365 if (next_ && (params().depth() < next_->params().depth())) {
1370 case LATEX_ENVIRONMENT:
1371 // if its the last paragraph of the current environment
1372 // skip it otherwise fall through
1374 && (next_->layout != layout
1375 || next_->params().depth() != params().depth()))
1377 // fall through possible
1379 // we don't need it for the last paragraph!!!
1386 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1387 further_blank_line = false;
1388 if (params().lineBottom()) {
1389 os << "\\lyxline{\\" << font.latexSize() << '}';
1390 further_blank_line = true;
1393 if (params().spaceBottom().kind() != VSpace::NONE) {
1394 os << params().spaceBottom().asLatexCommand(bparams);
1395 further_blank_line = true;
1398 if (params().pagebreakBottom()) {
1400 further_blank_line = true;
1403 if (further_blank_line) {
1408 if (!params().spacing().isDefault()
1409 && (!next_ || !next_->hasSameLayout(this))) {
1410 os << params().spacing().writeEnvirEnd() << "\n";
1415 // we don't need it for the last paragraph!!!
1420 // Since \selectlanguage write the language to the aux file,
1421 // we need to reset the language at the end of footnote or
1424 if (language->babel() != doc_language->babel()) {
1425 if (lyxrc.language_command_end.empty())
1426 os << subst(lyxrc.language_command_begin,
1428 doc_language->babel())
1431 os << subst(lyxrc.language_command_end,
1439 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1443 // This could go to ParagraphParameters if we want to
1444 int Paragraph::startTeXParParams(BufferParams const & bparams,
1449 if (params().noindent()) {
1450 os << "\\noindent ";
1454 switch (params().align()) {
1455 case LYX_ALIGN_NONE:
1456 case LYX_ALIGN_BLOCK:
1457 case LYX_ALIGN_LAYOUT:
1458 case LYX_ALIGN_SPECIAL:
1460 case LYX_ALIGN_LEFT:
1461 if (getParLanguage(bparams)->babel() != "hebrew") {
1462 os << "\\begin{flushleft}";
1465 os << "\\begin{flushright}";
1469 case LYX_ALIGN_RIGHT:
1470 if (getParLanguage(bparams)->babel() != "hebrew") {
1471 os << "\\begin{flushright}";
1474 os << "\\begin{flushleft}";
1478 case LYX_ALIGN_CENTER:
1479 os << "\\begin{center}";
1487 // This could go to ParagraphParameters if we want to
1488 int Paragraph::endTeXParParams(BufferParams const & bparams,
1493 switch (params().align()) {
1494 case LYX_ALIGN_NONE:
1495 case LYX_ALIGN_BLOCK:
1496 case LYX_ALIGN_LAYOUT:
1497 case LYX_ALIGN_SPECIAL:
1499 case LYX_ALIGN_LEFT:
1500 if (getParLanguage(bparams)->babel() != "hebrew") {
1501 os << "\\end{flushleft}";
1504 os << "\\end{flushright}";
1508 case LYX_ALIGN_RIGHT:
1509 if (getParLanguage(bparams)->babel() != "hebrew") {
1510 os << "\\end{flushright}";
1513 os << "\\end{flushleft}";
1517 case LYX_ALIGN_CENTER:
1518 os << "\\end{center}";
1526 // This one spits out the text of the paragraph
1527 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1528 BufferParams const & bparams,
1529 ostream & os, TexRow & texrow,
1532 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1534 bool return_value = false;
1538 // well we have to check if we are in an inset with unlimited
1539 // lenght (all in one row) if that is true then we don't allow
1540 // any special options in the paragraph and also we don't allow
1541 // any environment other then "Standard" to be valid!
1543 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1546 style = textclasslist.Style(bparams.textclass, 0);
1548 style = textclasslist.Style(bparams.textclass, layout);
1553 // Maybe we have to create a optional argument.
1555 if (style.labeltype != LABEL_MANUAL)
1558 main_body = beginningOfMainBody();
1562 if (main_body > 0) {
1565 basefont = getLabelFont(bparams);
1567 basefont = getLayoutFont(bparams);
1570 moving_arg |= style.needprotect;
1572 // Which font is currently active?
1573 LyXFont running_font(basefont);
1574 // Do we have an open font change?
1575 bool open_font = false;
1577 texrow.start(this, 0);
1579 // if the paragraph is empty, the loop will not be entered at all
1581 if (style.isCommand()) {
1586 column += startTeXParParams(bparams, os);
1590 for (pos_type i = 0; i < size(); ++i) {
1592 // First char in paragraph or after label?
1593 if (i == main_body) {
1594 if (main_body > 0) {
1596 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1599 basefont = getLayoutFont(bparams);
1600 running_font = basefont;
1604 if (style.isCommand()) {
1610 column += startTeXParParams(bparams, os);
1613 value_type c = getChar(i);
1615 // Fully instantiated font
1616 LyXFont font = getFont(bparams, i);
1618 LyXFont const last_font = running_font;
1620 // Spaces at end of font change are simulated to be
1621 // outside font change, i.e. we write "\textXX{text} "
1622 // rather than "\textXX{text }". (Asger)
1623 if (open_font && c == ' ' && i <= size() - 2) {
1624 LyXFont const next_font = getFont(bparams, i + 1);
1625 if (next_font != running_font
1626 && next_font != font) {
1631 // We end font definition before blanks
1632 if (font != running_font && open_font) {
1633 column += running_font.latexWriteEndChanges(os,
1635 (i == main_body-1) ? basefont : font);
1636 running_font = basefont;
1640 // Blanks are printed before start of fontswitch
1642 // Do not print the separation of the optional argument
1643 if (i != main_body - 1) {
1644 pimpl_->simpleTeXBlanks(os, texrow, i,
1645 column, font, style);
1649 // Do we need to change font?
1650 if (font != running_font && i != main_body - 1) {
1651 column += font.latexWriteStartChanges(os, basefont,
1653 running_font = font;
1657 if (c == Paragraph::META_NEWLINE) {
1658 // newlines are handled differently here than
1659 // the default in SimpleTeXSpecialChars().
1660 if (!style.newline_allowed) {
1664 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1667 basefont = getLayoutFont(bparams);
1668 running_font = basefont;
1669 if (font.family() ==
1670 LyXFont::TYPEWRITER_FAMILY) {
1678 texrow.start(this, i + 1);
1681 pimpl_->simpleTeXSpecialChars(buf, bparams,
1682 os, texrow, moving_arg,
1684 basefont, open_font,
1685 style, i, column, c);
1689 // If we have an open font definition, we have to close it
1691 #ifdef FIXED_LANGUAGE_END_DETECTION
1694 .latexWriteEndChanges(os, basefont,
1695 next_->getFont(bparams,
1698 running_font.latexWriteEndChanges(os, basefont,
1702 #ifdef WITH_WARNINGS
1703 //#warning For now we ALWAYS have to close the foreign font settings if they are
1704 //#warning there as we start another \selectlanguage with the next paragraph if
1705 //#warning we are in need of this. This should be fixed sometime (Jug)
1707 running_font.latexWriteEndChanges(os, basefont, basefont);
1711 // Needed if there is an optional argument but no contents.
1712 if (main_body > 0 && main_body == size()) {
1714 return_value = false;
1718 column += endTeXParParams(bparams, os);
1721 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1722 return return_value;
1726 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1728 bool retval = false;
1730 case Paragraph::META_HFILL:
1731 sgml_string.erase();
1733 case Paragraph::META_NEWLINE:
1737 sgml_string = "&";
1740 sgml_string = "<";
1743 sgml_string = ">";
1746 sgml_string = "$";
1749 sgml_string = "#";
1752 sgml_string = "%";
1755 sgml_string = "[";
1758 sgml_string = "]";
1761 sgml_string = "{";
1764 sgml_string = "}";
1767 sgml_string = "˜";
1770 sgml_string = """;
1773 sgml_string = "\";
1779 case '\0': // Ignore :-)
1780 sgml_string.erase();
1790 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1791 BufferParams const & bparams,
1792 ostream & os, TexRow & texrow)
1794 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1796 LyXLayout const & style =
1797 textclasslist.Style(bparams.textclass,
1800 Language const * language = getParLanguage(bparams);
1801 Language const * doc_language = bparams.language;
1802 Language const * previous_language = previous_
1803 ? previous_->getParLanguage(bparams) : doc_language;
1804 if (language->babel() != previous_language->babel()) {
1806 if (!lyxrc.language_command_end.empty() &&
1807 previous_language->babel() != doc_language->babel()) {
1808 os << subst(lyxrc.language_command_end, "$$lang",
1809 previous_language->babel())
1814 if (lyxrc.language_command_end.empty() ||
1815 language->babel() != doc_language->babel()) {
1816 os << subst(lyxrc.language_command_begin, "$$lang",
1823 if (style.isEnvironment()) {
1824 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1825 os << "\\begin{" << style.latexname() << "}{"
1826 << params().labelWidthString() << "}\n";
1827 } else if (style.labeltype == LABEL_BIBLIO) {
1829 os << "\\begin{" << style.latexname() << "}{"
1830 << bibitemWidest(buf)
1832 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1833 os << "\\begin{" << style.latexname() << '}'
1834 << style.latexparam() << '\n';
1836 os << "\\begin{" << style.latexname() << '}'
1837 << style.latexparam() << '\n';
1840 Paragraph * par = this;
1842 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1844 if (par && par->params().depth() > params().depth()) {
1845 if (textclasslist.Style(bparams.textclass,
1846 par->layout).isParagraph()
1848 // How to handle this? (Lgb)
1849 //&& !suffixIs(os, "\n\n")
1851 // There should be at least one '\n' already
1852 // but we need there to be two for Standard
1853 // paragraphs that are depth-increment'ed to be
1854 // output correctly. However, tables can
1855 // also be paragraphs so don't adjust them.
1858 // Will it ever harm to have one '\n' too
1859 // many? i.e. that we sometimes will have
1860 // three in a row. (Lgb)
1864 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1867 && par->layout == layout
1868 && par->params().depth() == params().depth());
1870 if (style.isEnvironment()) {
1871 os << "\\end{" << style.latexname() << "}\n";
1875 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1876 return par; // ale970302
1880 bool Paragraph::isHfill(pos_type pos) const
1882 return IsHfillChar(getChar(pos));
1886 bool Paragraph::isInset(pos_type pos) const
1888 return IsInsetChar(getChar(pos));
1892 bool Paragraph::isNewline(pos_type pos) const
1894 return pos >= 0 && IsNewlineChar(getChar(pos));
1898 bool Paragraph::isSeparator(pos_type pos) const
1900 return IsSeparatorChar(getChar(pos));
1904 bool Paragraph::isLineSeparator(pos_type pos) const
1906 value_type const c = getChar(pos);
1907 return IsLineSeparatorChar(c)
1908 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1912 bool Paragraph::isKomma(pos_type pos) const
1914 return IsKommaChar(getChar(pos));
1918 /// Used by the spellchecker
1919 bool Paragraph::isLetter(pos_type pos) const
1921 value_type const c = getChar(pos);
1922 if (IsLetterChar(c))
1925 return getInset(pos)->isLetter();
1926 // We want to pass the ' and escape chars to ispell
1927 string const extra = lyxrc.isp_esc_chars + '\'';
1928 return contains(extra, c);
1932 bool Paragraph::isWord(pos_type pos) const
1934 return IsWordChar(getChar(pos)) ;
1939 Paragraph::getParLanguage(BufferParams const & bparams) const
1942 #ifndef INHERIT_LANGUAGE
1943 return getFirstFontSettings().language();
1945 Language const * lang = getFirstFontSettings().language();
1946 #warning We should make this somewhat better, any ideas? (Jug)
1947 if (lang == inherit_language || lang == ignore_language)
1948 lang = bparams.language;
1951 } else if (previous_)
1952 return previous_->getParLanguage(bparams);
1954 return bparams.language;
1958 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1960 return lyxrc.rtl_support
1961 && getParLanguage(bparams)->RightToLeft();
1965 void Paragraph::changeLanguage(BufferParams const & bparams,
1966 Language const * from, Language const * to)
1968 for (pos_type i = 0; i < size(); ++i) {
1969 LyXFont font = getFontSettings(bparams, i);
1970 if (font.language() == from) {
1971 font.setLanguage(to);
1978 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1980 Language const * doc_language = bparams.language;
1981 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1982 cit != pimpl_->fontlist.end(); ++cit)
1983 if (cit->font().language() != ignore_language &&
1984 cit->font().language() != latex_language &&
1985 #ifdef INHERIT_LANGUAGE
1986 cit->font().language() != inherit_language &&
1988 cit->font().language() != doc_language)
1994 // Convert the paragraph to a string.
1995 // Used for building the table of contents
1996 string const Paragraph::asString(Buffer const * buffer, bool label)
1998 BufferParams const & bparams = buffer->params;
2000 if (label && !params().labelString().empty())
2001 s += params().labelString() + ' ';
2002 string::size_type const len = s.size();
2004 for (pos_type i = 0; i < size(); ++i) {
2005 value_type c = getChar(i);
2008 else if (c == META_INSET &&
2009 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2011 getInset(i)->ascii(buffer, ost);
2012 s += subst(ost.str().c_str(),'\n',' ');
2016 if (isRightToLeftPar(bparams))
2017 reverse(s.begin() + len,s.end());
2023 string const Paragraph::asString(Buffer const * buffer,
2024 pos_type beg, pos_type end, bool label)
2028 if (beg == 0 && label && !params().labelString().empty())
2029 ost << params().labelString() << ' ';
2031 for (pos_type i = beg; i < end; ++i) {
2032 value_type const c = getUChar(buffer->params, i);
2035 else if (c == META_NEWLINE)
2037 else if (c == META_HFILL)
2039 else if (c == META_INSET) {
2040 getInset(i)->ascii(buffer, ost);
2044 return ost.str().c_str();
2048 void Paragraph::setInsetOwner(Inset * i)
2050 pimpl_->inset_owner = i;
2051 for (InsetList::const_iterator cit = insetlist.begin();
2052 cit != insetlist.end(); ++cit) {
2054 cit->inset->setOwner(i);
2059 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2062 for (InsetList::const_iterator cit = insetlist.begin();
2063 cit != insetlist.end(); ++cit) {
2065 if (cit->inset->isTextInset()) {
2066 static_cast<UpdatableInset *>
2067 (cit->inset)->deleteLyXText(bv, true);
2074 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2077 for (InsetList::const_iterator cit = insetlist.begin();
2078 cit != insetlist.end(); ++cit)
2081 if (cit->inset->isTextInset()) {
2082 static_cast<UpdatableInset *>
2083 (cit->inset)->resizeLyXText(bv, true);
2090 void Paragraph::setContentsFromPar(Paragraph * par)
2092 pimpl_->setContentsFromPar(par);
2096 lyx::pos_type Paragraph::size() const
2098 return pimpl_->size();
2102 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2104 return pimpl_->getChar(pos);
2108 int Paragraph::id() const
2114 void Paragraph::id(int id_arg)
2116 pimpl_->id_ = id_arg;
2120 layout_type Paragraph::getLayout() const
2126 bool Paragraph::isFirstInSequence() const
2128 Paragraph const * dhook = depthHook(getDepth());
2129 return (dhook == this
2130 || dhook->getLayout() != getLayout()
2131 || dhook->getDepth() != getDepth());
2135 Inset * Paragraph::inInset() const
2137 return pimpl_->inset_owner;
2141 void Paragraph::clearContents()
2147 void Paragraph::setCounter(int i, int v)
2149 pimpl_->counter_[i] = v;
2153 int Paragraph::getCounter(int i) const
2155 return pimpl_->counter_[i];
2159 void Paragraph::incCounter(int i)
2161 pimpl_->counter_[i]++;
2165 void Paragraph::setChar(pos_type pos, value_type c)
2167 pimpl_->setChar(pos, c);
2171 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2176 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2178 return inset_iterator(insetlist.begin());
2182 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2184 return inset_iterator(insetlist.end());
2188 ParagraphParameters & Paragraph::params()
2190 return pimpl_->params;
2194 ParagraphParameters const & Paragraph::params() const
2196 return pimpl_->params;
2200 Paragraph * Paragraph::getParFromID(int id) const
2202 return pimpl_->getParFromID(id);
2206 bool Paragraph::isFreeSpacing() const
2208 // for now we just need this, later should we need this in some
2209 // other way we can always add a function to Inset::() too.
2210 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2211 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);