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"
27 #include "BufferView.h"
29 #include "ParameterStruct.h"
31 #include "lyxtextclasslist.h"
33 #include "insets/insetinclude.h"
34 #include "insets/insetbib.h"
35 #include "insets/insettext.h"
37 #include "support/filetools.h"
38 #include "support/lstrings.h"
39 #include "support/lyxmanip.h"
40 #include "support/FileInfo.h"
41 #include "support/LAssert.h"
42 #include "support/textutils.h"
52 using std::lower_bound;
53 using std::upper_bound;
58 int tex_code_break_column = 72; // needs non-zero initialization. set later.
59 // this is a bad idea, but how can Paragraph find its buffer to get
60 // parameters? (JMarc)
62 extern string bibitemWidest(Buffer const *);
64 // this is a minibuffer
69 LyXFont minibuffer_font;
70 Inset * minibuffer_inset;
75 extern BufferView * current_view;
78 Paragraph::Paragraph()
79 : pimpl_(new Paragraph::Pimpl(this))
81 for (int i = 0; i < 10; ++i)
87 bibkey = 0; // ale970302
92 // This constructor inserts the new paragraph in a list.
93 Paragraph::Paragraph(Paragraph * par)
94 : pimpl_(new Paragraph::Pimpl(this))
96 for (int i = 0; i < 10; ++i)
101 // double linked list begin
104 next_->previous_ = this;
106 previous_->next_ = this;
109 bibkey = 0; // ale970302
114 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
115 : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
117 for (int i = 0; i < 10; ++i)
124 // this is because of the dummy layout of the paragraphs that
126 layout_ = lp.layout();
130 bibkey = static_cast<InsetBibKey *>
131 (lp.bibkey->clone(*current_view->buffer()));
136 // copy everything behind the break-position to the new paragraph
137 insetlist = lp.insetlist;
138 for (InsetList::iterator it = insetlist.begin();
139 it != insetlist.end(); ++it)
141 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
142 // tell the new inset who is the boss now
143 it->inset->parOwner(this);
148 // the destructor removes the new paragraph from the list
149 Paragraph::~Paragraph()
152 previous_->next_ = next_;
154 next_->previous_ = previous_;
156 for (InsetList::iterator it = insetlist.begin();
157 it != insetlist.end(); ++it) {
166 //lyxerr << "Paragraph::paragraph_id = "
167 // << Paragraph::paragraph_id << endl;
171 void Paragraph::writeFile(Buffer const * buf, ostream & os,
172 BufferParams const & bparams,
173 depth_type dth) const
175 // The beginning or end of a deeper (i.e. nested) area?
176 if (dth != params().depth()) {
177 if (params().depth() > dth) {
178 while (params().depth() > dth) {
179 os << "\n\\begin_deeper ";
183 while (params().depth() < dth) {
184 os << "\n\\end_deeper ";
190 // First write the layout
191 os << "\n\\layout " << layout()->name() << "\n";
193 // Maybe some vertical spaces.
194 if (params().spaceTop().kind() != VSpace::NONE)
195 os << "\\added_space_top "
196 << params().spaceTop().asLyXCommand() << " ";
197 if (params().spaceBottom().kind() != VSpace::NONE)
198 os << "\\added_space_bottom "
199 << params().spaceBottom().asLyXCommand() << " ";
201 // Maybe the paragraph has special spacing
202 params().spacing().writeFile(os, true);
204 // The labelwidth string used in lists.
205 if (!params().labelWidthString().empty())
206 os << "\\labelwidthstring "
207 << params().labelWidthString() << '\n';
209 // Lines above or below?
210 if (params().lineTop())
212 if (params().lineBottom())
213 os << "\\line_bottom ";
215 // Pagebreaks above or below?
216 if (params().pagebreakTop())
217 os << "\\pagebreak_top ";
218 if (params().pagebreakBottom())
219 os << "\\pagebreak_bottom ";
221 // Start of appendix?
222 if (params().startOfAppendix())
223 os << "\\start_of_appendix ";
226 if (params().noindent())
229 // Do we have a manual left indent?
230 if (!params().leftIndent().zero())
231 os << "\\leftindent " << params().leftIndent().asString() << " ";
234 if (params().align() != LYX_ALIGN_LAYOUT) {
236 switch (params().align()) {
237 case LYX_ALIGN_LEFT: h = 1; break;
238 case LYX_ALIGN_RIGHT: h = 2; break;
239 case LYX_ALIGN_CENTER: h = 3; break;
240 default: h = 0; break;
242 os << "\\align " << string_align[h] << " ";
247 bibkey->write(buf, os);
249 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
252 for (pos_type i = 0; i < size(); ++i) {
258 // Write font changes
259 LyXFont font2 = getFontSettings(bparams, i);
260 if (font2 != font1) {
261 #ifndef INHERIT_LANGUAGE
262 font2.lyxWriteChanges(font1, os);
264 font2.lyxWriteChanges(font1, bparams.language, os);
270 value_type const c = getChar(i);
274 Inset const * inset = getInset(i);
276 if (inset->directWrite()) {
277 // international char, let it write
278 // code directly so it's shorter in
280 inset->write(buf, os);
282 os << "\n\\begin_inset ";
283 inset->write(buf, os);
284 os << "\n\\end_inset \n\n";
290 os << "\n\\newline \n";
294 os << "\n\\hfill \n";
298 os << "\n\\backslash \n";
302 if (i + 1 < size() && getChar(i + 1) == ' ') {
309 if ((column > 70 && c == ' ')
314 // this check is to amend a bug. LyX sometimes
315 // inserts '\0' this could cause problems.
319 lyxerr << "ERROR (Paragraph::writeFile):"
320 " NULL char in structure." << endl;
326 // now write the next paragraph
328 next_->writeFile(buf, os, bparams, dth);
332 void Paragraph::validate(LaTeXFeatures & features) const
334 pimpl_->validate(features, *layout());
338 // First few functions needed for cut and paste and paragraph breaking.
339 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
341 BufferParams bparams = buffer.params;
343 minibuffer_char = getChar(pos);
344 minibuffer_font = getFontSettings(bparams, pos);
345 minibuffer_inset = 0;
346 if (minibuffer_char == Paragraph::META_INSET) {
348 minibuffer_inset = getInset(pos)->clone(buffer);
350 minibuffer_inset = 0;
351 minibuffer_char = ' ';
352 // This reflects what GetInset() does (ARRae)
358 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
360 minibuffer_char = getChar(pos);
361 minibuffer_font = getFontSettings(bparams, pos);
362 minibuffer_inset = 0;
363 if (minibuffer_char == Paragraph::META_INSET) {
365 minibuffer_inset = getInset(pos);
366 // This is a little hack since I want exactly
367 // the inset, not just a clone. Otherwise
368 // the inset would be deleted when calling Erase(pos)
370 InsetList::iterator it = insetlist.begin();
371 InsetList::iterator end = insetlist.end();
372 for (; it != end; ++it) {
377 if (it != end && it->pos == pos)
379 // the inset is not in a paragraph anymore
380 minibuffer_inset->parOwner(0);
382 minibuffer_inset = 0;
383 minibuffer_char = ' ';
384 // This reflects what GetInset() does (ARRae)
389 // Erase(pos); now the caller is responsible for that.
393 bool Paragraph::insertFromMinibuffer(pos_type pos)
395 if (minibuffer_char == Paragraph::META_INSET) {
396 if (!insetAllowed(minibuffer_inset->lyxCode())) {
399 insertInset(pos, minibuffer_inset, minibuffer_font);
401 LyXFont f = minibuffer_font;
402 if (!checkInsertChar(f)) {
405 insertChar(pos, minibuffer_char, f);
413 void Paragraph::erase(pos_type pos)
419 bool Paragraph::checkInsertChar(LyXFont & font)
421 if (pimpl_->inset_owner)
422 return pimpl_->inset_owner->checkInsertChar(font);
427 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
429 LyXFont const f(LyXFont::ALL_INHERIT);
430 insertChar(pos, c, f);
434 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
435 LyXFont const & font)
437 pimpl_->insertChar(pos, c, font);
441 void Paragraph::insertInset(pos_type pos, Inset * inset)
443 LyXFont const f(LyXFont::ALL_INHERIT);
444 insertInset(pos, inset, f);
448 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
450 pimpl_->insertInset(pos, inset, font);
454 bool Paragraph::insetAllowed(Inset::Code code)
456 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
458 if (pimpl_->inset_owner)
459 return pimpl_->inset_owner->insetAllowed(code);
464 Inset * Paragraph::getInset(pos_type pos)
466 lyx::Assert(pos < size());
469 InsetList::iterator it = insetlist.begin();
470 InsetList::iterator end = insetlist.end();
471 for (; it != end; ++it) {
476 if (it != end && it->pos == pos)
479 lyxerr << "ERROR (Paragraph::getInset): "
480 << "Inset does not exist: " << pos << endl;
483 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
484 // Did this commenting out introduce a bug? So far I have not
485 // see any, please enlighten me. (Lgb)
486 // My guess is that since the inset does not exist, we might
487 // as well replace it with a space to prevent craches. (Asger)
492 Inset const * Paragraph::getInset(pos_type pos) const
494 lyx::Assert(pos < size());
497 InsetList::const_iterator cit = insetlist.begin();
498 InsetList::const_iterator end = insetlist.end();
499 for (; cit != end; ++cit) {
504 if (cit != end && cit->pos == pos)
507 lyxerr << "ERROR (Paragraph::getInset): "
508 << "Inset does not exist: " << pos << endl;
510 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
511 // Did this commenting out introduce a bug? So far I have not
512 // see any, please enlighten me. (Lgb)
513 // My guess is that since the inset does not exist, we might
514 // as well replace it with a space to prevent craches. (Asger)
519 // Gets uninstantiated font setting at position.
520 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
523 lyx::Assert(pos <= size());
525 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
526 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
527 for (; cit != end; ++cit) {
528 if (cit->pos() >= pos)
534 retfont = cit->font();
535 } else if (pos == size() && size()) {
536 retfont = getFontSettings(bparams, pos - 1);
538 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
539 #ifdef INHERIT_LANGUAGE
540 if (retfont.language() == inherit_language)
541 retfont.setLanguage(bparams.language);
548 // Gets uninstantiated font setting at position 0
549 LyXFont const Paragraph::getFirstFontSettings() const
551 if (size() > 0 && !pimpl_->fontlist.empty())
552 return pimpl_->fontlist[0].font();
554 return LyXFont(LyXFont::ALL_INHERIT);
558 // Gets the fully instantiated font at a given position in a paragraph
559 // This is basically the same function as LyXText::GetFont() in text2.C.
560 // The difference is that this one is used for generating the LaTeX file,
561 // and thus cosmetic "improvements" are disallowed: This has to deliver
562 // the true picture of the buffer. (Asger)
563 // If position is -1, we get the layout font of the paragraph.
564 // If position is -2, we get the font of the manual label of the paragraph.
565 LyXFont const Paragraph::getFont(BufferParams const & bparams,
568 lyx::Assert(pos >= 0);
570 LyXLayout_ptr const & lout = layout();
572 pos_type main_body = 0;
573 if (lout->labeltype == LABEL_MANUAL)
574 main_body = beginningOfMainBody();
578 layoutfont = lout->labelfont;
580 layoutfont = lout->font;
582 LyXFont tmpfont = getFontSettings(bparams, pos);
583 #ifndef INHERIT_LANGUAGE
584 tmpfont.realize(layoutfont);
586 tmpfont.realize(layoutfont, bparams.language);
589 return pimpl_->realizeFont(tmpfont, bparams);
593 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
595 LyXLayout_ptr const & lout = layout();
597 LyXFont tmpfont = lout->labelfont;
598 tmpfont.setLanguage(getParLanguage(bparams));
600 return pimpl_->realizeFont(tmpfont, bparams);
604 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
606 LyXLayout_ptr const & lout = layout();
608 LyXFont tmpfont = lout->font;
609 tmpfont.setLanguage(getParLanguage(bparams));
611 return pimpl_->realizeFont(tmpfont, bparams);
615 /// Returns the height of the highest font in range
617 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
618 LyXFont::FONT_SIZE const def_size) const
620 if (pimpl_->fontlist.empty())
623 Pimpl::FontList::const_iterator end_it = pimpl_->fontlist.begin();
624 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
625 for (; end_it != end; ++end_it) {
626 if (end_it->pos() >= endpos)
633 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
634 for (; cit != end; ++cit) {
635 if (cit->pos() >= startpos)
639 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
640 for (; cit != end_it; ++cit) {
641 LyXFont::FONT_SIZE size = cit->font().size();
642 if (size == LyXFont::INHERIT_SIZE)
644 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
651 Paragraph::value_type
652 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
654 value_type c = getChar(pos);
655 if (!lyxrc.rtl_support)
685 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
692 void Paragraph::setFont(pos_type pos, LyXFont const & font)
694 lyx::Assert(pos <= size());
696 // First, reduce font against layout/label font
697 // Update: The SetCharFont() routine in text2.C already
698 // reduces font, so we don't need to do that here. (Asger)
699 // No need to simplify this because it will disappear
700 // in a new kernel. (Asger)
701 // Next search font table
703 Pimpl::FontList::iterator beg = pimpl_->fontlist.begin();
704 Pimpl::FontList::iterator it = beg;
705 Pimpl::FontList::iterator endit = pimpl_->fontlist.end();
706 for (; it != endit; ++it) {
707 if (it->pos() >= pos)
710 unsigned int i = std::distance(beg, it);
711 bool notfound = (it == endit);
713 if (!notfound && pimpl_->fontlist[i].font() == font)
716 bool begin = pos == 0 || notfound ||
717 (i > 0 && pimpl_->fontlist[i - 1].pos() == pos - 1);
718 // Is position pos is a beginning of a font block?
719 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
720 // Is position pos is the end of a font block?
721 if (begin && end) { // A single char block
722 if (i + 1 < pimpl_->fontlist.size() &&
723 pimpl_->fontlist[i + 1].font() == font) {
724 // Merge the singleton block with the next block
725 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
726 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
727 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
728 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
729 // Merge the singleton block with the previous block
730 pimpl_->fontlist[i - 1].pos(pos);
731 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
733 pimpl_->fontlist[i].font(font);
735 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
736 pimpl_->fontlist[i - 1].pos(pos);
738 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
739 Pimpl::FontTable(pos, font));
741 pimpl_->fontlist[i].pos(pos - 1);
742 if (!(i + 1 < pimpl_->fontlist.size() &&
743 pimpl_->fontlist[i + 1].font() == font))
744 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
745 Pimpl::FontTable(pos, font));
746 } else { // The general case. The block is splitted into 3 blocks
747 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
748 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
749 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
750 Pimpl::FontTable(pos, font));
756 void Paragraph::next(Paragraph * p)
762 // This function is able to hide closed footnotes.
763 Paragraph * Paragraph::next()
769 Paragraph const * Paragraph::next() const
775 void Paragraph::previous(Paragraph * p)
781 // This function is able to hide closed footnotes.
782 Paragraph * Paragraph::previous()
788 // This function is able to hide closed footnotes.
789 Paragraph const * Paragraph::previous() const
795 void Paragraph::breakParagraph(BufferParams const & bparams,
799 // create a new paragraph
800 Paragraph * tmp = new Paragraph(this);
801 tmp->layout(textclasslist[bparams.textclass].defaultLayout());
802 // remember to set the inset_owner
803 tmp->setInsetOwner(inInset());
805 // this is an idea for a more userfriendly layout handling, I will
806 // see what the users say
808 // layout stays the same with latex-environments
810 tmp->layout(layout());
811 tmp->setLabelWidthString(params().labelWidthString());
814 bool isempty = (layout()->keepempty && !size());
816 if (!isempty && (size() > pos || !size() || flag == 2)) {
817 tmp->layout(layout());
818 tmp->params().align(params().align());
819 tmp->setLabelWidthString(params().labelWidthString());
821 tmp->params().lineBottom(params().lineBottom());
822 params().lineBottom(false);
823 tmp->params().pagebreakBottom(params().pagebreakBottom());
824 params().pagebreakBottom(false);
825 tmp->params().spaceBottom(params().spaceBottom());
826 params().spaceBottom(VSpace(VSpace::NONE));
828 tmp->params().depth(params().depth());
829 tmp->params().noindent(params().noindent());
831 // copy everything behind the break-position
832 // to the new paragraph
833 pos_type pos_end = size() - 1;
836 for (; i <= pos_end; ++i) {
837 cutIntoMinibuffer(bparams, i);
838 if (tmp->insertFromMinibuffer(j - pos))
841 for (i = pos_end; i >= pos; --i) {
846 // just an idea of me
847 if (!isempty && !pos) {
848 tmp->params().lineTop(params().lineTop());
849 tmp->params().pagebreakTop(params().pagebreakTop());
850 tmp->params().spaceTop(params().spaceTop());
851 tmp->bibkey = bibkey;
856 layout(textclasslist[bparams.textclass].defaultLayout());
858 // layout stays the same with latex-environments
860 layout(tmp->layout());
861 setLabelWidthString(tmp->params().labelWidthString());
862 params().depth(tmp->params().depth());
868 void Paragraph::makeSameLayout(Paragraph const * par)
870 layout(par->layout());
872 params() = par->params();
876 int Paragraph::stripLeadingSpaces()
878 if (layout()->free_spacing ||
884 while (size() && (isNewline(0) || isLineSeparator(0))) {
893 bool Paragraph::hasSameLayout(Paragraph const * par) const
896 par->layout() == layout() &&
897 params().sameLayout(par->params());
901 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
904 // create a new paragraph
905 Paragraph * tmp = new Paragraph(this);
906 tmp->makeSameLayout(this);
908 // When can pos > Last()?
909 // I guess pos == Last() is possible.
911 // copy everything behind the break-position to the new
913 pos_type pos_end = size() - 1;
917 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
918 cutIntoMinibuffer(bparams, i);
919 if (tmp->insertFromMinibuffer(j - pos))
923 for (pos_type k = pos_end; k >= pos; --k) {
930 // Be carefull, this does not make any check at all.
931 // This method has wrong name, it combined this par with the next par.
932 // In that sense it is the reverse of break paragraph. (Lgb)
933 void Paragraph::pasteParagraph(BufferParams const & bparams)
935 // copy the next paragraph to this one
936 Paragraph * the_next = next();
938 // first the DTP-stuff
939 params().lineBottom(the_next->params().lineBottom());
940 params().spaceBottom(the_next->params().spaceBottom());
941 params().pagebreakBottom(the_next->params().pagebreakBottom());
943 pos_type pos_end = the_next->pimpl_->size() - 1;
944 pos_type pos_insert = size();
946 // ok, now copy the paragraph
947 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
948 the_next->cutIntoMinibuffer(bparams, i);
949 if (insertFromMinibuffer(pos_insert + j))
953 // delete the next paragraph
954 Paragraph * ppar = the_next->previous_;
955 Paragraph * npar = the_next->next_;
961 int Paragraph::getEndLabel() const
963 Paragraph const * par = this;
964 depth_type par_depth = getDepth();
966 LyXLayout_ptr const & layout = par->layout();
967 int const endlabeltype = layout->endlabeltype;
969 if (endlabeltype != END_LABEL_NO_LABEL) {
973 depth_type const next_depth = next_->getDepth();
974 if (par_depth > next_depth ||
975 (par_depth == next_depth
976 && layout != next_->layout()))
982 par = par->outerHook();
984 par_depth = par->getDepth();
986 return END_LABEL_NO_LABEL;
990 Paragraph::depth_type Paragraph::getDepth() const
992 return params().depth();
996 Paragraph::depth_type Paragraph::getMaxDepthAfter() const
998 bool const isenv = layout()->isEnvironment();
1001 return params().depth() + 1;
1003 return params().depth();
1007 char Paragraph::getAlign() const
1009 return params().align();
1013 string const & Paragraph::getLabelstring() const
1015 return params().labelString();
1019 int Paragraph::getFirstCounter(int i) const
1021 return pimpl_->counter_[i];
1025 // the next two functions are for the manual labels
1026 string const Paragraph::getLabelWidthString() const
1028 if (!params().labelWidthString().empty())
1029 return params().labelWidthString();
1031 return _("Senseless with this layout!");
1035 void Paragraph::setLabelWidthString(string const & s)
1037 params().labelWidthString(s);
1041 void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
1044 params().labelWidthString(string());
1045 params().align(LYX_ALIGN_LAYOUT);
1046 params().spaceTop(VSpace(VSpace::NONE));
1047 params().spaceBottom(VSpace(VSpace::NONE));
1048 params().spacing(Spacing(Spacing::Default));
1052 // if the layout of a paragraph contains a manual label, the beginning of the
1053 // main body is the beginning of the second word. This is what the par-
1054 // function returns. If the layout does not contain a label, the main
1055 // body always starts with position 0. This differentiation is necessary,
1056 // because there cannot be a newline or a blank <= the beginning of the
1057 // main body in TeX.
1059 int Paragraph::beginningOfMainBody() const
1061 // Unroll the first two cycles of the loop
1062 // and remember the previous character to
1063 // remove unnecessary GetChar() calls
1065 if (i < size() && getChar(i) != Paragraph::META_NEWLINE) {
1067 char previous_char = 0;
1070 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1071 // Yes, this ^ is supposed to be "= " not "=="
1074 && previous_char != ' '
1075 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1077 previous_char = temp;
1086 Paragraph * Paragraph::depthHook(depth_type depth)
1088 Paragraph * newpar = this;
1091 newpar = newpar->previous();
1092 } while (newpar && newpar->getDepth() > depth);
1095 if (previous() || getDepth())
1096 lyxerr << "ERROR (Paragraph::DepthHook): "
1105 Paragraph const * Paragraph::depthHook(depth_type depth) const
1107 Paragraph const * newpar = this;
1110 newpar = newpar->previous();
1111 } while (newpar && newpar->getDepth() > depth);
1114 if (previous() || getDepth())
1115 lyxerr << "ERROR (Paragraph::DepthHook): "
1123 Paragraph * Paragraph::outerHook()
1127 return depthHook(depth_type(getDepth() - 1));
1130 Paragraph const * Paragraph::outerHook() const
1134 return depthHook(depth_type(getDepth() - 1));
1138 Paragraph::inset_iterator
1139 Paragraph::InsetIterator(pos_type pos)
1141 InsetList::iterator it = insetlist.begin();
1142 InsetList::iterator end = insetlist.end();
1143 for (; it != end; ++it) {
1148 return inset_iterator(it);
1152 // returns -1 if inset not found
1153 int Paragraph::getPositionOfInset(Inset const * inset) const
1156 InsetList::const_iterator cit = insetlist.begin();
1157 InsetList::const_iterator end = insetlist.end();
1158 for (; cit != end; ++cit) {
1159 if (cit->inset == inset) {
1163 if (inset == bibkey)
1170 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1171 BufferParams const & bparams,
1172 ostream & os, TexRow & texrow,
1175 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1176 Inset const * in = inInset();
1177 bool further_blank_line = false;
1178 LyXLayout_ptr style;
1180 // well we have to check if we are in an inset with unlimited
1181 // lenght (all in one row) if that is true then we don't allow
1182 // any special options in the paragraph and also we don't allow
1183 // any environment other then "Standard" to be valid!
1184 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1187 if (params().startOfAppendix()) {
1188 os << "\\appendix\n";
1192 if (!params().spacing().isDefault()
1193 && (!previous() || !previous()->hasSameLayout(this))) {
1194 os << params().spacing().writeEnvirBegin() << "\n";
1198 if (tex_code_break_column && style->isCommand()) {
1203 if (params().pagebreakTop()) {
1205 further_blank_line = true;
1207 if (params().spaceTop().kind() != VSpace::NONE) {
1208 os << params().spaceTop().asLatexCommand(bparams);
1209 further_blank_line = true;
1212 if (params().lineTop()) {
1213 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1214 << "\\vspace{-1\\parskip}";
1215 further_blank_line = true;
1218 if (further_blank_line) {
1223 style = textclasslist[bparams.textclass].defaultLayout();
1226 Language const * language = getParLanguage(bparams);
1227 Language const * doc_language = bparams.language;
1228 Language const * previous_language = previous()
1229 ? previous()->getParLanguage(bparams) : doc_language;
1231 if (language->babel() != previous_language->babel()
1232 // check if we already put language command in TeXEnvironment()
1233 && !(style->isEnvironment()
1234 && (!previous() || previous()->layout() != layout() ||
1235 previous()->params().depth() != params().depth())))
1237 if (!lyxrc.language_command_end.empty() &&
1238 previous_language->babel() != doc_language->babel())
1240 os << subst(lyxrc.language_command_end, "$$lang",
1241 previous_language->babel())
1246 if (lyxrc.language_command_end.empty() ||
1247 language->babel() != doc_language->babel())
1249 os << subst(lyxrc.language_command_begin, "$$lang",
1256 if (bparams.inputenc == "auto" &&
1257 language->encoding() != previous_language->encoding()) {
1258 os << "\\inputencoding{"
1259 << language->encoding()->LatexName()
1264 switch (style->latextype) {
1267 << style->latexname()
1268 << style->latexparam();
1270 case LATEX_ITEM_ENVIRONMENT:
1272 bibkey->latex(buf, os, false, false);
1276 case LATEX_LIST_ENVIRONMENT:
1283 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1285 // Make sure that \\par is done with the font of the last
1286 // character if this has another size as the default.
1287 // This is necessary because LaTeX (and LyX on the screen)
1288 // calculates the space between the baselines according
1289 // to this font. (Matthias)
1291 // Is this really needed ? (Dekel)
1292 // We do not need to use to change the font for the last paragraph
1293 // or for a command.
1294 LyXFont const font =
1296 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1298 bool is_command = style->isCommand();
1300 if (style->resfont.size() != font.size() && next_ && !is_command) {
1303 os << "\\" << font.latexSize() << " \\par}";
1304 } else if (need_par) {
1306 } else if (is_command)
1309 switch (style->latextype) {
1310 case LATEX_ITEM_ENVIRONMENT:
1311 case LATEX_LIST_ENVIRONMENT:
1312 if (next_ && (params().depth() < next_->params().depth())) {
1317 case LATEX_ENVIRONMENT:
1318 // if its the last paragraph of the current environment
1319 // skip it otherwise fall through
1321 && (next_->layout() != layout()
1322 || next_->params().depth() != params().depth()))
1324 // fall through possible
1326 // we don't need it for the last paragraph!!!
1333 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1334 further_blank_line = false;
1335 if (params().lineBottom()) {
1336 os << "\\lyxline{\\" << font.latexSize() << '}';
1337 further_blank_line = true;
1340 if (params().spaceBottom().kind() != VSpace::NONE) {
1341 os << params().spaceBottom().asLatexCommand(bparams);
1342 further_blank_line = true;
1345 if (params().pagebreakBottom()) {
1347 further_blank_line = true;
1350 if (further_blank_line) {
1355 if (!params().spacing().isDefault()
1356 && (!next_ || !next_->hasSameLayout(this))) {
1357 os << params().spacing().writeEnvirEnd() << "\n";
1362 // we don't need it for the last paragraph!!!
1367 // Since \selectlanguage write the language to the aux file,
1368 // we need to reset the language at the end of footnote or
1371 if (language->babel() != doc_language->babel()) {
1372 if (lyxrc.language_command_end.empty())
1373 os << subst(lyxrc.language_command_begin,
1375 doc_language->babel())
1378 os << subst(lyxrc.language_command_end,
1386 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1390 // This could go to ParagraphParameters if we want to
1391 int Paragraph::startTeXParParams(BufferParams const & bparams,
1392 ostream & os, bool moving_arg) const
1396 if (params().noindent()) {
1397 os << "\\noindent ";
1401 switch (params().align()) {
1402 case LYX_ALIGN_NONE:
1403 case LYX_ALIGN_BLOCK:
1404 case LYX_ALIGN_LAYOUT:
1405 case LYX_ALIGN_SPECIAL:
1407 case LYX_ALIGN_LEFT:
1408 case LYX_ALIGN_RIGHT:
1409 case LYX_ALIGN_CENTER:
1417 switch (params().align()) {
1418 case LYX_ALIGN_NONE:
1419 case LYX_ALIGN_BLOCK:
1420 case LYX_ALIGN_LAYOUT:
1421 case LYX_ALIGN_SPECIAL:
1423 case LYX_ALIGN_LEFT:
1424 if (getParLanguage(bparams)->babel() != "hebrew") {
1425 os << "\\begin{flushleft}";
1428 os << "\\begin{flushright}";
1432 case LYX_ALIGN_RIGHT:
1433 if (getParLanguage(bparams)->babel() != "hebrew") {
1434 os << "\\begin{flushright}";
1437 os << "\\begin{flushleft}";
1441 case LYX_ALIGN_CENTER:
1442 os << "\\begin{center}";
1450 // This could go to ParagraphParameters if we want to
1451 int Paragraph::endTeXParParams(BufferParams const & bparams,
1452 ostream & os, bool moving_arg) const
1456 switch (params().align()) {
1457 case LYX_ALIGN_NONE:
1458 case LYX_ALIGN_BLOCK:
1459 case LYX_ALIGN_LAYOUT:
1460 case LYX_ALIGN_SPECIAL:
1462 case LYX_ALIGN_LEFT:
1463 case LYX_ALIGN_RIGHT:
1464 case LYX_ALIGN_CENTER:
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 << "\\end{flushleft}";
1483 os << "\\end{flushright}";
1487 case LYX_ALIGN_RIGHT:
1488 if (getParLanguage(bparams)->babel() != "hebrew") {
1489 os << "\\end{flushright}";
1492 os << "\\end{flushleft}";
1496 case LYX_ALIGN_CENTER:
1497 os << "\\end{center}";
1505 // This one spits out the text of the paragraph
1506 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1507 BufferParams const & bparams,
1508 ostream & os, TexRow & texrow,
1511 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1513 bool return_value = false;
1515 LyXLayout_ptr style;
1517 // well we have to check if we are in an inset with unlimited
1518 // lenght (all in one row) if that is true then we don't allow
1519 // any special options in the paragraph and also we don't allow
1520 // any environment other then "Standard" to be valid!
1522 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1525 style = textclasslist[bparams.textclass].defaultLayout();
1532 // Maybe we have to create a optional argument.
1534 if (style->labeltype != LABEL_MANUAL)
1537 main_body = beginningOfMainBody();
1541 if (main_body > 0) {
1544 basefont = getLabelFont(bparams);
1546 basefont = getLayoutFont(bparams);
1549 moving_arg |= style->needprotect;
1551 // Which font is currently active?
1552 LyXFont running_font(basefont);
1553 // Do we have an open font change?
1554 bool open_font = false;
1556 texrow.start(this, 0);
1558 // if the paragraph is empty, the loop will not be entered at all
1560 if (style->isCommand()) {
1565 column += startTeXParParams(bparams, os, moving_arg);
1569 for (pos_type i = 0; i < size(); ++i) {
1571 // First char in paragraph or after label?
1572 if (i == main_body) {
1573 if (main_body > 0) {
1575 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1578 basefont = getLayoutFont(bparams);
1579 running_font = basefont;
1583 if (style->isCommand()) {
1589 column += startTeXParParams(bparams, os,
1593 value_type c = getChar(i);
1595 // Fully instantiated font
1596 LyXFont font = getFont(bparams, i);
1598 LyXFont const last_font = running_font;
1600 // Spaces at end of font change are simulated to be
1601 // outside font change, i.e. we write "\textXX{text} "
1602 // rather than "\textXX{text }". (Asger)
1603 if (open_font && c == ' ' && i <= size() - 2) {
1604 LyXFont const & next_font = getFont(bparams, i + 1);
1605 if (next_font != running_font
1606 && next_font != font) {
1611 // We end font definition before blanks
1613 (font != running_font ||
1614 font.language() != running_font.language()))
1616 column += running_font.latexWriteEndChanges(os,
1618 (i == main_body-1) ? basefont : font);
1619 running_font = basefont;
1623 // Blanks are printed before start of fontswitch
1625 // Do not print the separation of the optional argument
1626 if (i != main_body - 1) {
1627 pimpl_->simpleTeXBlanks(os, texrow, i,
1628 column, font, *style);
1632 // Do we need to change font?
1633 if ((font != running_font ||
1634 font.language() != running_font.language()) &&
1637 column += font.latexWriteStartChanges(os, basefont,
1639 running_font = font;
1643 if (c == Paragraph::META_NEWLINE) {
1644 // newlines are handled differently here than
1645 // the default in SimpleTeXSpecialChars().
1646 if (!style->newline_allowed) {
1650 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1653 basefont = getLayoutFont(bparams);
1654 running_font = basefont;
1655 if (font.family() ==
1656 LyXFont::TYPEWRITER_FAMILY) {
1665 texrow.start(this, i + 1);
1668 pimpl_->simpleTeXSpecialChars(buf, bparams,
1669 os, texrow, moving_arg,
1671 basefont, open_font,
1672 *style, i, column, c);
1676 // If we have an open font definition, we have to close it
1678 #ifdef FIXED_LANGUAGE_END_DETECTION
1681 .latexWriteEndChanges(os, basefont,
1682 next_->getFont(bparams,
1685 running_font.latexWriteEndChanges(os, basefont,
1689 #ifdef WITH_WARNINGS
1690 //#warning For now we ALWAYS have to close the foreign font settings if they are
1691 //#warning there as we start another \selectlanguage with the next paragraph if
1692 //#warning we are in need of this. This should be fixed sometime (Jug)
1694 running_font.latexWriteEndChanges(os, basefont, basefont);
1698 // Needed if there is an optional argument but no contents.
1699 if (main_body > 0 && main_body == size()) {
1701 return_value = false;
1705 column += endTeXParParams(bparams, os, moving_arg);
1708 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1709 return return_value;
1713 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1715 bool retval = false;
1717 case Paragraph::META_HFILL:
1718 sgml_string.erase();
1720 case Paragraph::META_NEWLINE:
1724 sgml_string = "&";
1727 sgml_string = "<";
1730 sgml_string = ">";
1733 sgml_string = "$";
1736 sgml_string = "#";
1739 sgml_string = "%";
1742 sgml_string = "[";
1745 sgml_string = "]";
1748 sgml_string = "{";
1751 sgml_string = "}";
1754 sgml_string = "˜";
1757 sgml_string = """;
1760 sgml_string = "\";
1766 case '\0': // Ignore :-)
1767 sgml_string.erase();
1777 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1778 BufferParams const & bparams,
1779 ostream & os, TexRow & texrow)
1781 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1783 LyXLayout_ptr const & style = layout();
1785 Language const * language = getParLanguage(bparams);
1786 Language const * doc_language = bparams.language;
1787 Language const * previous_language = previous_
1788 ? previous_->getParLanguage(bparams) : doc_language;
1789 if (language->babel() != previous_language->babel()) {
1791 if (!lyxrc.language_command_end.empty() &&
1792 previous_language->babel() != doc_language->babel()) {
1793 os << subst(lyxrc.language_command_end, "$$lang",
1794 previous_language->babel())
1799 if (lyxrc.language_command_end.empty() ||
1800 language->babel() != doc_language->babel()) {
1801 os << subst(lyxrc.language_command_begin, "$$lang",
1808 bool leftindent_open = false;
1809 if (!params().leftIndent().zero()) {
1810 os << "\\begin{LyXParagraphLeftIndent}{" <<
1811 params().leftIndent().asLatexString() << "}\n";
1813 leftindent_open = true;
1816 if (style->isEnvironment()) {
1817 if (style->latextype == LATEX_LIST_ENVIRONMENT) {
1818 os << "\\begin{" << style->latexname() << "}{"
1819 << params().labelWidthString() << "}\n";
1820 } else if (style->labeltype == LABEL_BIBLIO) {
1822 os << "\\begin{" << style->latexname() << "}{"
1823 << bibitemWidest(buf)
1825 } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
1826 os << "\\begin{" << style->latexname() << '}'
1827 << style->latexparam() << '\n';
1829 os << "\\begin{" << style->latexname() << '}'
1830 << style->latexparam() << '\n';
1833 Paragraph * par = this;
1835 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1837 if (par && par->params().depth() > params().depth()) {
1838 if (par->layout()->isParagraph()) {
1841 // How to handle this? (Lgb)
1842 //&& !suffixIs(os, "\n\n")
1844 // There should be at least one '\n' already
1845 // but we need there to be two for Standard
1846 // paragraphs that are depth-increment'ed to be
1847 // output correctly. However, tables can
1848 // also be paragraphs so don't adjust them.
1851 // Will it ever harm to have one '\n' too
1852 // many? i.e. that we sometimes will have
1853 // three in a row. (Lgb)
1857 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1860 && par->layout() == layout()
1861 && par->params().depth() == params().depth()
1862 && par->params().leftIndent() == params().leftIndent());
1864 if (style->isEnvironment()) {
1865 os << "\\end{" << style->latexname() << "}\n";
1869 if (leftindent_open) {
1870 os << "\\end{LyXParagraphLeftIndent}\n";
1874 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1875 return par; // ale970302
1879 bool Paragraph::isHfill(pos_type pos) const
1881 return IsHfillChar(getChar(pos));
1885 bool Paragraph::isInset(pos_type pos) const
1887 return IsInsetChar(getChar(pos));
1891 bool Paragraph::isNewline(pos_type pos) const
1893 return pos >= 0 && IsNewlineChar(getChar(pos));
1897 bool Paragraph::isSeparator(pos_type pos) const
1899 return IsSeparatorChar(getChar(pos));
1903 bool Paragraph::isLineSeparator(pos_type pos) const
1905 value_type const c = getChar(pos);
1906 return IsLineSeparatorChar(c)
1907 || (IsInsetChar(c) && getInset(pos) &&
1908 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 #ifdef WITH_WARNINGS
1947 #warning We should make this somewhat better, any ideas? (Jug)
1949 if (lang == inherit_language || lang == ignore_language)
1950 lang = bparams.language;
1953 } else if (previous_)
1954 return previous_->getParLanguage(bparams);
1956 return bparams.language;
1960 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1962 return lyxrc.rtl_support
1963 && getParLanguage(bparams)->RightToLeft()
1964 && !(inInset() && inInset()->owner() &&
1965 inInset()->owner()->lyxCode() == Inset::ERT_CODE);
1969 void Paragraph::changeLanguage(BufferParams const & bparams,
1970 Language const * from, Language const * to)
1972 for (pos_type i = 0; i < size(); ++i) {
1973 LyXFont font = getFontSettings(bparams, i);
1974 if (font.language() == from) {
1975 font.setLanguage(to);
1982 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1984 Language const * doc_language = bparams.language;
1985 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1986 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
1988 for (; cit != end; ++cit)
1989 if (cit->font().language() != ignore_language &&
1990 cit->font().language() != latex_language &&
1991 #ifdef INHERIT_LANGUAGE
1992 cit->font().language() != inherit_language &&
1994 cit->font().language() != doc_language)
2000 // Convert the paragraph to a string.
2001 // Used for building the table of contents
2002 string const Paragraph::asString(Buffer const * buffer, bool label)
2004 BufferParams const & bparams = buffer->params;
2006 if (label && !params().labelString().empty())
2007 s += params().labelString() + ' ';
2008 string::size_type const len = s.size();
2010 for (pos_type i = 0; i < size(); ++i) {
2011 value_type c = getChar(i);
2014 else if (c == META_INSET &&
2015 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2017 getInset(i)->ascii(buffer, ost);
2018 s += subst(ost.str().c_str(),'\n',' ');
2022 if (isRightToLeftPar(bparams))
2023 reverse(s.begin() + len,s.end());
2029 string const Paragraph::asString(Buffer const * buffer,
2030 pos_type beg, pos_type end, bool label)
2034 if (beg == 0 && label && !params().labelString().empty())
2035 ost << params().labelString() << ' ';
2037 for (pos_type i = beg; i < end; ++i) {
2038 value_type const c = getUChar(buffer->params, i);
2041 else if (c == META_NEWLINE)
2043 else if (c == META_HFILL)
2045 else if (c == META_INSET) {
2046 getInset(i)->ascii(buffer, ost);
2050 return ost.str().c_str();
2054 void Paragraph::setInsetOwner(Inset * i)
2056 pimpl_->inset_owner = i;
2057 InsetList::const_iterator cit = insetlist.begin();
2058 InsetList::const_iterator end = insetlist.end();
2059 for (; cit != end; ++cit) {
2061 cit->inset->setOwner(i);
2066 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2069 InsetList::const_iterator cit = insetlist.begin();
2070 InsetList::const_iterator end = insetlist.end();
2071 for (; cit != end; ++cit) {
2072 if (cit->inset && cit->inset->isTextInset()) {
2073 static_cast<UpdatableInset *>
2074 (cit->inset)->deleteLyXText(bv, true);
2080 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2083 InsetList::const_iterator cit = insetlist.begin();
2084 InsetList::const_iterator end = insetlist.end();
2085 for (; cit != end; ++cit) {
2087 if (cit->inset->isTextInset()) {
2088 static_cast<UpdatableInset *>
2089 (cit->inset)->resizeLyXText(bv, true);
2096 void Paragraph::setContentsFromPar(Paragraph * par)
2098 pimpl_->setContentsFromPar(par);
2102 lyx::pos_type Paragraph::size() const
2104 return pimpl_->size();
2108 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2110 return pimpl_->getChar(pos);
2114 int Paragraph::id() const
2120 void Paragraph::id(int id_arg)
2122 pimpl_->id_ = id_arg;
2126 LyXLayout_ptr const & Paragraph::layout() const
2132 void Paragraph::layout(LyXLayout_ptr const & new_layout)
2134 layout_ = new_layout;
2138 bool Paragraph::isFirstInSequence() const
2140 Paragraph const * dhook = depthHook(getDepth());
2141 return (dhook == this
2142 || dhook->layout() != layout()
2143 || dhook->getDepth() != getDepth());
2147 Inset * Paragraph::inInset() const
2149 return pimpl_->inset_owner;
2153 void Paragraph::clearContents()
2159 void Paragraph::setCounter(int i, int v)
2161 pimpl_->counter_[i] = v;
2165 int Paragraph::getCounter(int i) const
2167 return pimpl_->counter_[i];
2171 void Paragraph::incCounter(int i)
2173 pimpl_->counter_[i]++;
2177 void Paragraph::setChar(pos_type pos, value_type c)
2179 pimpl_->setChar(pos, c);
2183 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2188 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2190 return inset_iterator(insetlist.begin());
2194 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2196 return inset_iterator(insetlist.end());
2200 ParagraphParameters & Paragraph::params()
2202 return pimpl_->params;
2206 ParagraphParameters const & Paragraph::params() const
2208 return pimpl_->params;
2212 Paragraph * Paragraph::getParFromID(int id) const
2214 return pimpl_->getParFromID(id);
2218 bool Paragraph::isFreeSpacing() const
2220 // for now we just need this, later should we need this in some
2221 // other way we can always add a function to Inset::() too.
2222 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2223 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);