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"
32 #include "insets/insetinclude.h"
33 #include "insets/insetbib.h"
34 #include "insets/insettext.h"
36 #include "support/filetools.h"
37 #include "support/lstrings.h"
38 #include "support/lyxmanip.h"
39 #include "support/FileInfo.h"
40 #include "support/LAssert.h"
41 #include "support/textutils.h"
51 using std::lower_bound;
52 using std::upper_bound;
57 int tex_code_break_column = 72; // needs non-zero initialization. set later.
58 // this is a bad idea, but how can Paragraph find its buffer to get
59 // parameters? (JMarc)
61 extern string bibitemWidest(Buffer const *);
63 // this is a minibuffer
68 LyXFont minibuffer_font;
69 Inset * minibuffer_inset;
74 extern BufferView * current_view;
77 Paragraph::Paragraph()
78 : pimpl_(new Paragraph::Pimpl(this))
80 for (int i = 0; i < 10; ++i)
86 bibkey = 0; // ale970302
91 // This constructor inserts the new paragraph in a list.
92 Paragraph::Paragraph(Paragraph * par)
93 : pimpl_(new Paragraph::Pimpl(this))
95 for (int i = 0; i < 10; ++i)
100 // double linked list begin
103 next_->previous_ = this;
105 previous_->next_ = this;
108 bibkey = 0; // ale970302
113 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
114 : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
116 for (int i = 0; i < 10; ++i)
123 // this is because of the dummy layout of the paragraphs that
125 layout_ = lp.layout();
129 bibkey = static_cast<InsetBibKey *>
130 (lp.bibkey->clone(*current_view->buffer()));
135 // copy everything behind the break-position to the new paragraph
136 insetlist = lp.insetlist;
137 for (InsetList::iterator it = insetlist.begin();
138 it != insetlist.end(); ++it)
140 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
141 // tell the new inset who is the boss now
142 it->inset->parOwner(this);
147 // the destructor removes the new paragraph from the list
148 Paragraph::~Paragraph()
151 previous_->next_ = next_;
153 next_->previous_ = previous_;
155 for (InsetList::iterator it = insetlist.begin();
156 it != insetlist.end(); ++it) {
165 //lyxerr << "Paragraph::paragraph_id = "
166 // << Paragraph::paragraph_id << endl;
170 void Paragraph::writeFile(Buffer const * buf, ostream & os,
171 BufferParams const & bparams,
172 depth_type dth) const
174 // The beginning or end of a deeper (i.e. nested) area?
175 if (dth != params().depth()) {
176 if (params().depth() > dth) {
177 while (params().depth() > dth) {
178 os << "\n\\begin_deeper ";
182 while (params().depth() < dth) {
183 os << "\n\\end_deeper ";
189 // First write the layout
190 os << "\n\\layout " << layout()->name() << "\n";
192 // Maybe some vertical spaces.
193 if (params().spaceTop().kind() != VSpace::NONE)
194 os << "\\added_space_top "
195 << params().spaceTop().asLyXCommand() << " ";
196 if (params().spaceBottom().kind() != VSpace::NONE)
197 os << "\\added_space_bottom "
198 << params().spaceBottom().asLyXCommand() << " ";
200 // Maybe the paragraph has special spacing
201 params().spacing().writeFile(os, true);
203 // The labelwidth string used in lists.
204 if (!params().labelWidthString().empty())
205 os << "\\labelwidthstring "
206 << params().labelWidthString() << '\n';
208 // Lines above or below?
209 if (params().lineTop())
211 if (params().lineBottom())
212 os << "\\line_bottom ";
214 // Pagebreaks above or below?
215 if (params().pagebreakTop())
216 os << "\\pagebreak_top ";
217 if (params().pagebreakBottom())
218 os << "\\pagebreak_bottom ";
220 // Start of appendix?
221 if (params().startOfAppendix())
222 os << "\\start_of_appendix ";
225 if (params().noindent())
228 // Do we have a manual left indent?
229 if (!params().leftIndent().zero())
230 os << "\\leftindent " << params().leftIndent().asString() << " ";
233 if (params().align() != LYX_ALIGN_LAYOUT) {
235 switch (params().align()) {
236 case LYX_ALIGN_LEFT: h = 1; break;
237 case LYX_ALIGN_RIGHT: h = 2; break;
238 case LYX_ALIGN_CENTER: h = 3; break;
239 default: h = 0; break;
241 os << "\\align " << string_align[h] << " ";
246 bibkey->write(buf, os);
248 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
251 for (pos_type i = 0; i < size(); ++i) {
257 // Write font changes
258 LyXFont font2 = getFontSettings(bparams, i);
259 if (font2 != font1) {
260 #ifndef INHERIT_LANGUAGE
261 font2.lyxWriteChanges(font1, os);
263 font2.lyxWriteChanges(font1, bparams.language, os);
269 value_type const c = getChar(i);
273 Inset const * inset = getInset(i);
275 if (inset->directWrite()) {
276 // international char, let it write
277 // code directly so it's shorter in
279 inset->write(buf, os);
281 os << "\n\\begin_inset ";
282 inset->write(buf, os);
283 os << "\n\\end_inset \n\n";
289 os << "\n\\newline \n";
293 os << "\n\\hfill \n";
297 os << "\n\\backslash \n";
301 if (i + 1 < size() && getChar(i + 1) == ' ') {
308 if ((column > 70 && c == ' ')
313 // this check is to amend a bug. LyX sometimes
314 // inserts '\0' this could cause problems.
318 lyxerr << "ERROR (Paragraph::writeFile):"
319 " NULL char in structure." << endl;
325 // now write the next paragraph
327 next_->writeFile(buf, os, bparams, dth);
331 void Paragraph::validate(LaTeXFeatures & features) const
333 pimpl_->validate(features, *layout());
337 // First few functions needed for cut and paste and paragraph breaking.
338 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
340 BufferParams bparams = buffer.params;
342 minibuffer_char = getChar(pos);
343 minibuffer_font = getFontSettings(bparams, pos);
344 minibuffer_inset = 0;
345 if (minibuffer_char == Paragraph::META_INSET) {
347 minibuffer_inset = getInset(pos)->clone(buffer);
349 minibuffer_inset = 0;
350 minibuffer_char = ' ';
351 // This reflects what GetInset() does (ARRae)
357 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
359 minibuffer_char = getChar(pos);
360 minibuffer_font = getFontSettings(bparams, pos);
361 minibuffer_inset = 0;
362 if (minibuffer_char == Paragraph::META_INSET) {
364 minibuffer_inset = getInset(pos);
365 // This is a little hack since I want exactly
366 // the inset, not just a clone. Otherwise
367 // the inset would be deleted when calling Erase(pos)
369 InsetList::iterator it = insetlist.begin();
370 InsetList::iterator end = insetlist.end();
371 for (; it != end; ++it) {
376 if (it != end && it->pos == pos)
378 // the inset is not in a paragraph anymore
379 minibuffer_inset->parOwner(0);
381 minibuffer_inset = 0;
382 minibuffer_char = ' ';
383 // This reflects what GetInset() does (ARRae)
388 // Erase(pos); now the caller is responsible for that.
392 bool Paragraph::insertFromMinibuffer(pos_type pos)
394 if (minibuffer_char == Paragraph::META_INSET) {
395 if (!insetAllowed(minibuffer_inset->lyxCode())) {
398 insertInset(pos, minibuffer_inset, minibuffer_font);
400 LyXFont f = minibuffer_font;
401 if (!checkInsertChar(f)) {
404 insertChar(pos, minibuffer_char, f);
412 void Paragraph::erase(pos_type pos)
418 bool Paragraph::checkInsertChar(LyXFont & font)
420 if (pimpl_->inset_owner)
421 return pimpl_->inset_owner->checkInsertChar(font);
426 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
428 LyXFont const f(LyXFont::ALL_INHERIT);
429 insertChar(pos, c, f);
433 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
434 LyXFont const & font)
436 pimpl_->insertChar(pos, c, font);
440 void Paragraph::insertInset(pos_type pos, Inset * inset)
442 LyXFont const f(LyXFont::ALL_INHERIT);
443 insertInset(pos, inset, f);
447 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
449 pimpl_->insertInset(pos, inset, font);
453 bool Paragraph::insetAllowed(Inset::Code code)
455 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
457 if (pimpl_->inset_owner)
458 return pimpl_->inset_owner->insetAllowed(code);
463 Inset * Paragraph::getInset(pos_type pos)
465 lyx::Assert(pos < size());
468 InsetList::iterator it = insetlist.begin();
469 InsetList::iterator end = insetlist.end();
470 for (; it != end; ++it) {
475 if (it != end && it->pos == pos)
478 lyxerr << "ERROR (Paragraph::getInset): "
479 << "Inset does not exist: " << pos << endl;
482 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
483 // Did this commenting out introduce a bug? So far I have not
484 // see any, please enlighten me. (Lgb)
485 // My guess is that since the inset does not exist, we might
486 // as well replace it with a space to prevent craches. (Asger)
491 Inset const * Paragraph::getInset(pos_type pos) const
493 lyx::Assert(pos < size());
496 InsetList::const_iterator cit = insetlist.begin();
497 InsetList::const_iterator end = insetlist.end();
498 for (; cit != end; ++cit) {
503 if (cit != end && cit->pos == pos)
506 lyxerr << "ERROR (Paragraph::getInset): "
507 << "Inset does not exist: " << pos << endl;
509 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
510 // Did this commenting out introduce a bug? So far I have not
511 // see any, please enlighten me. (Lgb)
512 // My guess is that since the inset does not exist, we might
513 // as well replace it with a space to prevent craches. (Asger)
518 // Gets uninstantiated font setting at position.
519 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
522 lyx::Assert(pos <= size());
524 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
525 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
526 for (; cit != end; ++cit) {
527 if (cit->pos() >= pos)
533 retfont = cit->font();
534 } else if (pos == size() && size()) {
535 retfont = getFontSettings(bparams, pos - 1);
537 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
538 #ifdef INHERIT_LANGUAGE
539 if (retfont.language() == inherit_language)
540 retfont.setLanguage(bparams.language);
547 // Gets uninstantiated font setting at position 0
548 LyXFont const Paragraph::getFirstFontSettings() const
550 if (size() > 0 && !pimpl_->fontlist.empty())
551 return pimpl_->fontlist[0].font();
553 return LyXFont(LyXFont::ALL_INHERIT);
557 // Gets the fully instantiated font at a given position in a paragraph
558 // This is basically the same function as LyXText::GetFont() in text2.C.
559 // The difference is that this one is used for generating the LaTeX file,
560 // and thus cosmetic "improvements" are disallowed: This has to deliver
561 // the true picture of the buffer. (Asger)
562 // If position is -1, we get the layout font of the paragraph.
563 // If position is -2, we get the font of the manual label of the paragraph.
564 LyXFont const Paragraph::getFont(BufferParams const & bparams,
567 lyx::Assert(pos >= 0);
569 LyXLayout_ptr const & lout = layout();
571 pos_type main_body = 0;
572 if (lout->labeltype == LABEL_MANUAL)
573 main_body = beginningOfMainBody();
577 layoutfont = lout->labelfont;
579 layoutfont = lout->font;
581 LyXFont tmpfont = getFontSettings(bparams, pos);
582 #ifndef INHERIT_LANGUAGE
583 tmpfont.realize(layoutfont);
585 tmpfont.realize(layoutfont, bparams.language);
588 return pimpl_->realizeFont(tmpfont, bparams);
592 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
594 LyXLayout_ptr const & lout = layout();
596 LyXFont tmpfont = lout->labelfont;
597 tmpfont.setLanguage(getParLanguage(bparams));
599 return pimpl_->realizeFont(tmpfont, bparams);
603 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
605 LyXLayout_ptr const & lout = layout();
607 LyXFont tmpfont = lout->font;
608 tmpfont.setLanguage(getParLanguage(bparams));
610 return pimpl_->realizeFont(tmpfont, bparams);
614 /// Returns the height of the highest font in range
616 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
617 LyXFont::FONT_SIZE const def_size) const
619 if (pimpl_->fontlist.empty())
622 Pimpl::FontList::const_iterator end_it = pimpl_->fontlist.begin();
623 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
624 for (; end_it != end; ++end_it) {
625 if (end_it->pos() >= endpos)
632 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
633 for (; cit != end; ++cit) {
634 if (cit->pos() >= startpos)
638 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
639 for (; cit != end_it; ++cit) {
640 LyXFont::FONT_SIZE size = cit->font().size();
641 if (size == LyXFont::INHERIT_SIZE)
643 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
650 Paragraph::value_type
651 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
653 value_type c = getChar(pos);
654 if (!lyxrc.rtl_support)
684 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
691 void Paragraph::setFont(pos_type pos, LyXFont const & font)
693 lyx::Assert(pos <= size());
695 // First, reduce font against layout/label font
696 // Update: The SetCharFont() routine in text2.C already
697 // reduces font, so we don't need to do that here. (Asger)
698 // No need to simplify this because it will disappear
699 // in a new kernel. (Asger)
700 // Next search font table
702 Pimpl::FontList::iterator beg = pimpl_->fontlist.begin();
703 Pimpl::FontList::iterator it = beg;
704 Pimpl::FontList::iterator endit = pimpl_->fontlist.end();
705 for (; it != endit; ++it) {
706 if (it->pos() >= pos)
709 unsigned int i = std::distance(beg, it);
710 bool notfound = (it == endit);
712 if (!notfound && pimpl_->fontlist[i].font() == font)
715 bool begin = pos == 0 || notfound ||
716 (i > 0 && pimpl_->fontlist[i - 1].pos() == pos - 1);
717 // Is position pos is a beginning of a font block?
718 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
719 // Is position pos is the end of a font block?
720 if (begin && end) { // A single char block
721 if (i + 1 < pimpl_->fontlist.size() &&
722 pimpl_->fontlist[i + 1].font() == font) {
723 // Merge the singleton block with the next block
724 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
725 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
726 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
727 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
728 // Merge the singleton block with the previous block
729 pimpl_->fontlist[i - 1].pos(pos);
730 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
732 pimpl_->fontlist[i].font(font);
734 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
735 pimpl_->fontlist[i - 1].pos(pos);
737 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
738 Pimpl::FontTable(pos, font));
740 pimpl_->fontlist[i].pos(pos - 1);
741 if (!(i + 1 < pimpl_->fontlist.size() &&
742 pimpl_->fontlist[i + 1].font() == font))
743 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
744 Pimpl::FontTable(pos, font));
745 } else { // The general case. The block is splitted into 3 blocks
746 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
747 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
748 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
749 Pimpl::FontTable(pos, font));
755 void Paragraph::next(Paragraph * p)
761 // This function is able to hide closed footnotes.
762 Paragraph * Paragraph::next()
768 Paragraph const * Paragraph::next() const
774 void Paragraph::previous(Paragraph * p)
780 // This function is able to hide closed footnotes.
781 Paragraph * Paragraph::previous()
787 // This function is able to hide closed footnotes.
788 Paragraph const * Paragraph::previous() const
794 void Paragraph::breakParagraph(BufferParams const & bparams,
798 // create a new paragraph
799 Paragraph * tmp = new Paragraph(this);
800 tmp->layout(bparams.getLyXTextClass().defaultLayout());
801 // remember to set the inset_owner
802 tmp->setInsetOwner(inInset());
804 // this is an idea for a more userfriendly layout handling, I will
805 // see what the users say
807 // layout stays the same with latex-environments
809 tmp->layout(layout());
810 tmp->setLabelWidthString(params().labelWidthString());
813 bool isempty = (layout()->keepempty && !size());
815 if (!isempty && (size() > pos || !size() || flag == 2)) {
816 tmp->layout(layout());
817 tmp->params().align(params().align());
818 tmp->setLabelWidthString(params().labelWidthString());
820 tmp->params().lineBottom(params().lineBottom());
821 params().lineBottom(false);
822 tmp->params().pagebreakBottom(params().pagebreakBottom());
823 params().pagebreakBottom(false);
824 tmp->params().spaceBottom(params().spaceBottom());
825 params().spaceBottom(VSpace(VSpace::NONE));
827 tmp->params().depth(params().depth());
828 tmp->params().noindent(params().noindent());
830 // copy everything behind the break-position
831 // to the new paragraph
832 pos_type pos_end = size() - 1;
835 for (; i <= pos_end; ++i) {
836 cutIntoMinibuffer(bparams, i);
837 if (tmp->insertFromMinibuffer(j - pos))
840 for (i = pos_end; i >= pos; --i) {
845 // just an idea of me
846 if (!isempty && !pos) {
847 tmp->params().lineTop(params().lineTop());
848 tmp->params().pagebreakTop(params().pagebreakTop());
849 tmp->params().spaceTop(params().spaceTop());
850 tmp->bibkey = bibkey;
855 layout(bparams.getLyXTextClass().defaultLayout());
857 // layout stays the same with latex-environments
859 layout(tmp->layout());
860 setLabelWidthString(tmp->params().labelWidthString());
861 params().depth(tmp->params().depth());
867 void Paragraph::makeSameLayout(Paragraph const * par)
869 layout(par->layout());
871 params() = par->params();
875 int Paragraph::stripLeadingSpaces()
877 if (layout()->free_spacing ||
883 while (size() && (isNewline(0) || isLineSeparator(0))) {
892 bool Paragraph::hasSameLayout(Paragraph const * par) const
895 par->layout() == layout() &&
896 params().sameLayout(par->params());
900 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
903 // create a new paragraph
904 Paragraph * tmp = new Paragraph(this);
905 tmp->makeSameLayout(this);
907 // When can pos > Last()?
908 // I guess pos == Last() is possible.
910 // copy everything behind the break-position to the new
912 pos_type pos_end = size() - 1;
916 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
917 cutIntoMinibuffer(bparams, i);
918 if (tmp->insertFromMinibuffer(j - pos))
922 for (pos_type k = pos_end; k >= pos; --k) {
929 // Be carefull, this does not make any check at all.
930 // This method has wrong name, it combined this par with the next par.
931 // In that sense it is the reverse of break paragraph. (Lgb)
932 void Paragraph::pasteParagraph(BufferParams const & bparams)
934 // copy the next paragraph to this one
935 Paragraph * the_next = next();
937 // first the DTP-stuff
938 params().lineBottom(the_next->params().lineBottom());
939 params().spaceBottom(the_next->params().spaceBottom());
940 params().pagebreakBottom(the_next->params().pagebreakBottom());
942 pos_type pos_end = the_next->pimpl_->size() - 1;
943 pos_type pos_insert = size();
945 // ok, now copy the paragraph
946 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
947 the_next->cutIntoMinibuffer(bparams, i);
948 if (insertFromMinibuffer(pos_insert + j))
952 // delete the next paragraph
953 Paragraph * ppar = the_next->previous_;
954 Paragraph * npar = the_next->next_;
960 int Paragraph::getEndLabel() const
962 Paragraph const * par = this;
963 depth_type par_depth = getDepth();
965 LyXLayout_ptr const & layout = par->layout();
966 int const endlabeltype = layout->endlabeltype;
968 if (endlabeltype != END_LABEL_NO_LABEL) {
972 depth_type const next_depth = next_->getDepth();
973 if (par_depth > next_depth ||
974 (par_depth == next_depth
975 && layout != next_->layout()))
981 par = par->outerHook();
983 par_depth = par->getDepth();
985 return END_LABEL_NO_LABEL;
989 Paragraph::depth_type Paragraph::getDepth() const
991 return params().depth();
995 Paragraph::depth_type Paragraph::getMaxDepthAfter() const
997 bool const isenv = layout()->isEnvironment();
1000 return params().depth() + 1;
1002 return params().depth();
1006 char Paragraph::getAlign() const
1008 return params().align();
1012 string const & Paragraph::getLabelstring() const
1014 return params().labelString();
1018 int Paragraph::getFirstCounter(int i) const
1020 return pimpl_->counter_[i];
1024 // the next two functions are for the manual labels
1025 string const Paragraph::getLabelWidthString() const
1027 if (!params().labelWidthString().empty())
1028 return params().labelWidthString();
1030 return _("Senseless with this layout!");
1034 void Paragraph::setLabelWidthString(string const & s)
1036 params().labelWidthString(s);
1040 void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
1043 params().labelWidthString(string());
1044 params().align(LYX_ALIGN_LAYOUT);
1045 params().spaceTop(VSpace(VSpace::NONE));
1046 params().spaceBottom(VSpace(VSpace::NONE));
1047 params().spacing(Spacing(Spacing::Default));
1051 // if the layout of a paragraph contains a manual label, the beginning of the
1052 // main body is the beginning of the second word. This is what the par-
1053 // function returns. If the layout does not contain a label, the main
1054 // body always starts with position 0. This differentiation is necessary,
1055 // because there cannot be a newline or a blank <= the beginning of the
1056 // main body in TeX.
1058 int Paragraph::beginningOfMainBody() const
1060 // Unroll the first two cycles of the loop
1061 // and remember the previous character to
1062 // remove unnecessary GetChar() calls
1064 if (i < size() && getChar(i) != Paragraph::META_NEWLINE) {
1066 char previous_char = 0;
1069 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1070 // Yes, this ^ is supposed to be "= " not "=="
1073 && previous_char != ' '
1074 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1076 previous_char = temp;
1085 Paragraph * Paragraph::depthHook(depth_type depth)
1087 Paragraph * newpar = this;
1090 newpar = newpar->previous();
1091 } while (newpar && newpar->getDepth() > depth);
1094 if (previous() || getDepth())
1095 lyxerr << "ERROR (Paragraph::DepthHook): "
1104 Paragraph const * Paragraph::depthHook(depth_type depth) const
1106 Paragraph const * newpar = this;
1109 newpar = newpar->previous();
1110 } while (newpar && newpar->getDepth() > depth);
1113 if (previous() || getDepth())
1114 lyxerr << "ERROR (Paragraph::DepthHook): "
1122 Paragraph * Paragraph::outerHook()
1126 return depthHook(depth_type(getDepth() - 1));
1129 Paragraph const * Paragraph::outerHook() const
1133 return depthHook(depth_type(getDepth() - 1));
1137 Paragraph::inset_iterator
1138 Paragraph::InsetIterator(pos_type pos)
1140 InsetList::iterator it = insetlist.begin();
1141 InsetList::iterator end = insetlist.end();
1142 for (; it != end; ++it) {
1147 return inset_iterator(it);
1151 // returns -1 if inset not found
1152 int Paragraph::getPositionOfInset(Inset const * inset) const
1155 InsetList::const_iterator cit = insetlist.begin();
1156 InsetList::const_iterator end = insetlist.end();
1157 for (; cit != end; ++cit) {
1158 if (cit->inset == inset) {
1162 if (inset == bibkey)
1169 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1170 BufferParams const & bparams,
1171 ostream & os, TexRow & texrow,
1174 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1175 Inset const * in = inInset();
1176 bool further_blank_line = false;
1177 LyXLayout_ptr style;
1179 // well we have to check if we are in an inset with unlimited
1180 // lenght (all in one row) if that is true then we don't allow
1181 // any special options in the paragraph and also we don't allow
1182 // any environment other then "Standard" to be valid!
1183 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1186 if (params().startOfAppendix()) {
1187 os << "\\appendix\n";
1191 if (!params().spacing().isDefault()
1192 && (!previous() || !previous()->hasSameLayout(this))) {
1193 os << params().spacing().writeEnvirBegin() << "\n";
1197 if (tex_code_break_column && style->isCommand()) {
1202 if (params().pagebreakTop()) {
1204 further_blank_line = true;
1206 if (params().spaceTop().kind() != VSpace::NONE) {
1207 os << params().spaceTop().asLatexCommand(bparams);
1208 further_blank_line = true;
1211 if (params().lineTop()) {
1212 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1213 << "\\vspace{-1\\parskip}";
1214 further_blank_line = true;
1217 if (further_blank_line) {
1222 style = bparams.getLyXTextClass().defaultLayout();
1225 Language const * language = getParLanguage(bparams);
1226 Language const * doc_language = bparams.language;
1227 Language const * previous_language = previous()
1228 ? previous()->getParLanguage(bparams) : doc_language;
1230 if (language->babel() != previous_language->babel()
1231 // check if we already put language command in TeXEnvironment()
1232 && !(style->isEnvironment()
1233 && (!previous() || previous()->layout() != layout() ||
1234 previous()->params().depth() != params().depth())))
1236 if (!lyxrc.language_command_end.empty() &&
1237 previous_language->babel() != doc_language->babel())
1239 os << subst(lyxrc.language_command_end, "$$lang",
1240 previous_language->babel())
1245 if (lyxrc.language_command_end.empty() ||
1246 language->babel() != doc_language->babel())
1248 os << subst(lyxrc.language_command_begin, "$$lang",
1255 if (bparams.inputenc == "auto" &&
1256 language->encoding() != previous_language->encoding()) {
1257 os << "\\inputencoding{"
1258 << language->encoding()->LatexName()
1263 switch (style->latextype) {
1266 << style->latexname()
1267 << style->latexparam();
1269 case LATEX_ITEM_ENVIRONMENT:
1271 bibkey->latex(buf, os, false, false);
1275 case LATEX_LIST_ENVIRONMENT:
1282 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1284 // Make sure that \\par is done with the font of the last
1285 // character if this has another size as the default.
1286 // This is necessary because LaTeX (and LyX on the screen)
1287 // calculates the space between the baselines according
1288 // to this font. (Matthias)
1290 // Is this really needed ? (Dekel)
1291 // We do not need to use to change the font for the last paragraph
1292 // or for a command.
1293 LyXFont const font =
1295 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1297 bool is_command = style->isCommand();
1299 if (style->resfont.size() != font.size() && next_ && !is_command) {
1302 os << "\\" << font.latexSize() << " \\par}";
1303 } else if (need_par) {
1305 } else if (is_command)
1308 switch (style->latextype) {
1309 case LATEX_ITEM_ENVIRONMENT:
1310 case LATEX_LIST_ENVIRONMENT:
1311 if (next_ && (params().depth() < next_->params().depth())) {
1316 case LATEX_ENVIRONMENT:
1317 // if its the last paragraph of the current environment
1318 // skip it otherwise fall through
1320 && (next_->layout() != layout()
1321 || next_->params().depth() != params().depth()))
1323 // fall through possible
1325 // we don't need it for the last paragraph!!!
1332 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1333 further_blank_line = false;
1334 if (params().lineBottom()) {
1335 os << "\\lyxline{\\" << font.latexSize() << '}';
1336 further_blank_line = true;
1339 if (params().spaceBottom().kind() != VSpace::NONE) {
1340 os << params().spaceBottom().asLatexCommand(bparams);
1341 further_blank_line = true;
1344 if (params().pagebreakBottom()) {
1346 further_blank_line = true;
1349 if (further_blank_line) {
1354 if (!params().spacing().isDefault()
1355 && (!next_ || !next_->hasSameLayout(this))) {
1356 os << params().spacing().writeEnvirEnd() << "\n";
1361 // we don't need it for the last paragraph!!!
1366 // Since \selectlanguage write the language to the aux file,
1367 // we need to reset the language at the end of footnote or
1370 if (language->babel() != doc_language->babel()) {
1371 if (lyxrc.language_command_end.empty())
1372 os << subst(lyxrc.language_command_begin,
1374 doc_language->babel())
1377 os << subst(lyxrc.language_command_end,
1385 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1389 // This could go to ParagraphParameters if we want to
1390 int Paragraph::startTeXParParams(BufferParams const & bparams,
1391 ostream & os, bool moving_arg) const
1395 if (params().noindent()) {
1396 os << "\\noindent ";
1400 switch (params().align()) {
1401 case LYX_ALIGN_NONE:
1402 case LYX_ALIGN_BLOCK:
1403 case LYX_ALIGN_LAYOUT:
1404 case LYX_ALIGN_SPECIAL:
1406 case LYX_ALIGN_LEFT:
1407 case LYX_ALIGN_RIGHT:
1408 case LYX_ALIGN_CENTER:
1416 switch (params().align()) {
1417 case LYX_ALIGN_NONE:
1418 case LYX_ALIGN_BLOCK:
1419 case LYX_ALIGN_LAYOUT:
1420 case LYX_ALIGN_SPECIAL:
1422 case LYX_ALIGN_LEFT:
1423 if (getParLanguage(bparams)->babel() != "hebrew") {
1424 os << "\\begin{flushleft}";
1427 os << "\\begin{flushright}";
1431 case LYX_ALIGN_RIGHT:
1432 if (getParLanguage(bparams)->babel() != "hebrew") {
1433 os << "\\begin{flushright}";
1436 os << "\\begin{flushleft}";
1440 case LYX_ALIGN_CENTER:
1441 os << "\\begin{center}";
1449 // This could go to ParagraphParameters if we want to
1450 int Paragraph::endTeXParParams(BufferParams const & bparams,
1451 ostream & os, bool moving_arg) const
1455 switch (params().align()) {
1456 case LYX_ALIGN_NONE:
1457 case LYX_ALIGN_BLOCK:
1458 case LYX_ALIGN_LAYOUT:
1459 case LYX_ALIGN_SPECIAL:
1461 case LYX_ALIGN_LEFT:
1462 case LYX_ALIGN_RIGHT:
1463 case LYX_ALIGN_CENTER:
1471 switch (params().align()) {
1472 case LYX_ALIGN_NONE:
1473 case LYX_ALIGN_BLOCK:
1474 case LYX_ALIGN_LAYOUT:
1475 case LYX_ALIGN_SPECIAL:
1477 case LYX_ALIGN_LEFT:
1478 if (getParLanguage(bparams)->babel() != "hebrew") {
1479 os << "\\end{flushleft}";
1482 os << "\\end{flushright}";
1486 case LYX_ALIGN_RIGHT:
1487 if (getParLanguage(bparams)->babel() != "hebrew") {
1488 os << "\\end{flushright}";
1491 os << "\\end{flushleft}";
1495 case LYX_ALIGN_CENTER:
1496 os << "\\end{center}";
1504 // This one spits out the text of the paragraph
1505 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1506 BufferParams const & bparams,
1507 ostream & os, TexRow & texrow,
1510 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1512 bool return_value = false;
1514 LyXLayout_ptr style;
1516 // well we have to check if we are in an inset with unlimited
1517 // lenght (all in one row) if that is true then we don't allow
1518 // any special options in the paragraph and also we don't allow
1519 // any environment other then "Standard" to be valid!
1521 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1524 style = bparams.getLyXTextClass().defaultLayout();
1531 // Maybe we have to create a optional argument.
1533 if (style->labeltype != LABEL_MANUAL)
1536 main_body = beginningOfMainBody();
1540 if (main_body > 0) {
1543 basefont = getLabelFont(bparams);
1545 basefont = getLayoutFont(bparams);
1548 moving_arg |= style->needprotect;
1550 // Which font is currently active?
1551 LyXFont running_font(basefont);
1552 // Do we have an open font change?
1553 bool open_font = false;
1555 texrow.start(this, 0);
1557 // if the paragraph is empty, the loop will not be entered at all
1559 if (style->isCommand()) {
1564 column += startTeXParParams(bparams, os, moving_arg);
1568 for (pos_type i = 0; i < size(); ++i) {
1570 // First char in paragraph or after label?
1571 if (i == main_body) {
1572 if (main_body > 0) {
1574 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1577 basefont = getLayoutFont(bparams);
1578 running_font = basefont;
1582 if (style->isCommand()) {
1588 column += startTeXParParams(bparams, os,
1592 value_type c = getChar(i);
1594 // Fully instantiated font
1595 LyXFont font = getFont(bparams, i);
1597 LyXFont const last_font = running_font;
1599 // Spaces at end of font change are simulated to be
1600 // outside font change, i.e. we write "\textXX{text} "
1601 // rather than "\textXX{text }". (Asger)
1602 if (open_font && c == ' ' && i <= size() - 2) {
1603 LyXFont const & next_font = getFont(bparams, i + 1);
1604 if (next_font != running_font
1605 && next_font != font) {
1610 // We end font definition before blanks
1612 (font != running_font ||
1613 font.language() != running_font.language()))
1615 column += running_font.latexWriteEndChanges(os,
1617 (i == main_body-1) ? basefont : font);
1618 running_font = basefont;
1622 // Blanks are printed before start of fontswitch
1624 // Do not print the separation of the optional argument
1625 if (i != main_body - 1) {
1626 pimpl_->simpleTeXBlanks(os, texrow, i,
1627 column, font, *style);
1631 // Do we need to change font?
1632 if ((font != running_font ||
1633 font.language() != running_font.language()) &&
1636 column += font.latexWriteStartChanges(os, basefont,
1638 running_font = font;
1642 if (c == Paragraph::META_NEWLINE) {
1643 // newlines are handled differently here than
1644 // the default in SimpleTeXSpecialChars().
1645 if (!style->newline_allowed) {
1649 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1652 basefont = getLayoutFont(bparams);
1653 running_font = basefont;
1654 if (font.family() ==
1655 LyXFont::TYPEWRITER_FAMILY) {
1664 texrow.start(this, i + 1);
1667 pimpl_->simpleTeXSpecialChars(buf, bparams,
1668 os, texrow, moving_arg,
1670 basefont, open_font,
1671 *style, i, column, c);
1675 // If we have an open font definition, we have to close it
1677 #ifdef FIXED_LANGUAGE_END_DETECTION
1680 .latexWriteEndChanges(os, basefont,
1681 next_->getFont(bparams,
1684 running_font.latexWriteEndChanges(os, basefont,
1688 #ifdef WITH_WARNINGS
1689 //#warning For now we ALWAYS have to close the foreign font settings if they are
1690 //#warning there as we start another \selectlanguage with the next paragraph if
1691 //#warning we are in need of this. This should be fixed sometime (Jug)
1693 running_font.latexWriteEndChanges(os, basefont, basefont);
1697 // Needed if there is an optional argument but no contents.
1698 if (main_body > 0 && main_body == size()) {
1700 return_value = false;
1704 column += endTeXParParams(bparams, os, moving_arg);
1707 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1708 return return_value;
1712 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1714 bool retval = false;
1716 case Paragraph::META_HFILL:
1717 sgml_string.erase();
1719 case Paragraph::META_NEWLINE:
1723 sgml_string = "&";
1726 sgml_string = "<";
1729 sgml_string = ">";
1732 sgml_string = "$";
1735 sgml_string = "#";
1738 sgml_string = "%";
1741 sgml_string = "[";
1744 sgml_string = "]";
1747 sgml_string = "{";
1750 sgml_string = "}";
1753 sgml_string = "˜";
1756 sgml_string = """;
1759 sgml_string = "\";
1765 case '\0': // Ignore :-)
1766 sgml_string.erase();
1776 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1777 BufferParams const & bparams,
1778 ostream & os, TexRow & texrow)
1780 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1782 LyXLayout_ptr const & style = layout();
1784 Language const * language = getParLanguage(bparams);
1785 Language const * doc_language = bparams.language;
1786 Language const * previous_language = previous_
1787 ? previous_->getParLanguage(bparams) : doc_language;
1788 if (language->babel() != previous_language->babel()) {
1790 if (!lyxrc.language_command_end.empty() &&
1791 previous_language->babel() != doc_language->babel()) {
1792 os << subst(lyxrc.language_command_end, "$$lang",
1793 previous_language->babel())
1798 if (lyxrc.language_command_end.empty() ||
1799 language->babel() != doc_language->babel()) {
1800 os << subst(lyxrc.language_command_begin, "$$lang",
1807 bool leftindent_open = false;
1808 if (!params().leftIndent().zero()) {
1809 os << "\\begin{LyXParagraphLeftIndent}{" <<
1810 params().leftIndent().asLatexString() << "}\n";
1812 leftindent_open = true;
1815 if (style->isEnvironment()) {
1816 if (style->latextype == LATEX_LIST_ENVIRONMENT) {
1817 os << "\\begin{" << style->latexname() << "}{"
1818 << params().labelWidthString() << "}\n";
1819 } else if (style->labeltype == LABEL_BIBLIO) {
1821 os << "\\begin{" << style->latexname() << "}{"
1822 << bibitemWidest(buf)
1824 } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
1825 os << "\\begin{" << style->latexname() << '}'
1826 << style->latexparam() << '\n';
1828 os << "\\begin{" << style->latexname() << '}'
1829 << style->latexparam() << '\n';
1832 Paragraph * par = this;
1834 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1836 if (par && par->params().depth() > params().depth()) {
1837 if (par->layout()->isParagraph()) {
1840 // How to handle this? (Lgb)
1841 //&& !suffixIs(os, "\n\n")
1843 // There should be at least one '\n' already
1844 // but we need there to be two for Standard
1845 // paragraphs that are depth-increment'ed to be
1846 // output correctly. However, tables can
1847 // also be paragraphs so don't adjust them.
1850 // Will it ever harm to have one '\n' too
1851 // many? i.e. that we sometimes will have
1852 // three in a row. (Lgb)
1856 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1859 && par->layout() == layout()
1860 && par->params().depth() == params().depth()
1861 && par->params().leftIndent() == params().leftIndent());
1863 if (style->isEnvironment()) {
1864 os << "\\end{" << style->latexname() << "}\n";
1868 if (leftindent_open) {
1869 os << "\\end{LyXParagraphLeftIndent}\n";
1873 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1874 return par; // ale970302
1878 bool Paragraph::isHfill(pos_type pos) const
1880 return IsHfillChar(getChar(pos));
1884 bool Paragraph::isInset(pos_type pos) const
1886 return IsInsetChar(getChar(pos));
1890 bool Paragraph::isNewline(pos_type pos) const
1892 return pos >= 0 && IsNewlineChar(getChar(pos));
1896 bool Paragraph::isSeparator(pos_type pos) const
1898 return IsSeparatorChar(getChar(pos));
1902 bool Paragraph::isLineSeparator(pos_type pos) const
1904 value_type const c = getChar(pos);
1905 return IsLineSeparatorChar(c)
1906 || (IsInsetChar(c) && getInset(pos) &&
1907 getInset(pos)->isLineSeparator());
1911 bool Paragraph::isKomma(pos_type pos) const
1913 return IsKommaChar(getChar(pos));
1917 /// Used by the spellchecker
1918 bool Paragraph::isLetter(pos_type pos) const
1920 value_type const c = getChar(pos);
1921 if (IsLetterChar(c))
1924 return getInset(pos)->isLetter();
1925 // We want to pass the ' and escape chars to ispell
1926 string const extra = lyxrc.isp_esc_chars + '\'';
1927 return contains(extra, c);
1931 bool Paragraph::isWord(pos_type pos) const
1933 return IsWordChar(getChar(pos)) ;
1938 Paragraph::getParLanguage(BufferParams const & bparams) const
1941 #ifndef INHERIT_LANGUAGE
1942 return getFirstFontSettings().language();
1944 Language const * lang = getFirstFontSettings().language();
1945 #ifdef WITH_WARNINGS
1946 #warning We should make this somewhat better, any ideas? (Jug)
1948 if (lang == inherit_language || lang == ignore_language)
1949 lang = bparams.language;
1952 } else if (previous_)
1953 return previous_->getParLanguage(bparams);
1955 return bparams.language;
1959 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1961 return lyxrc.rtl_support
1962 && getParLanguage(bparams)->RightToLeft()
1963 && !(inInset() && inInset()->owner() &&
1964 inInset()->owner()->lyxCode() == Inset::ERT_CODE);
1968 void Paragraph::changeLanguage(BufferParams const & bparams,
1969 Language const * from, Language const * to)
1971 for (pos_type i = 0; i < size(); ++i) {
1972 LyXFont font = getFontSettings(bparams, i);
1973 if (font.language() == from) {
1974 font.setLanguage(to);
1981 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1983 Language const * doc_language = bparams.language;
1984 Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1985 Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
1987 for (; cit != end; ++cit)
1988 if (cit->font().language() != ignore_language &&
1989 cit->font().language() != latex_language &&
1990 #ifdef INHERIT_LANGUAGE
1991 cit->font().language() != inherit_language &&
1993 cit->font().language() != doc_language)
1999 // Convert the paragraph to a string.
2000 // Used for building the table of contents
2001 string const Paragraph::asString(Buffer const * buffer, bool label)
2003 BufferParams const & bparams = buffer->params;
2005 if (label && !params().labelString().empty())
2006 s += params().labelString() + ' ';
2007 string::size_type const len = s.size();
2009 for (pos_type i = 0; i < size(); ++i) {
2010 value_type c = getChar(i);
2013 else if (c == META_INSET &&
2014 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2016 getInset(i)->ascii(buffer, ost);
2017 s += subst(ost.str().c_str(),'\n',' ');
2021 if (isRightToLeftPar(bparams))
2022 reverse(s.begin() + len,s.end());
2028 string const Paragraph::asString(Buffer const * buffer,
2029 pos_type beg, pos_type end, bool label)
2033 if (beg == 0 && label && !params().labelString().empty())
2034 ost << params().labelString() << ' ';
2036 for (pos_type i = beg; i < end; ++i) {
2037 value_type const c = getUChar(buffer->params, i);
2040 else if (c == META_NEWLINE)
2042 else if (c == META_HFILL)
2044 else if (c == META_INSET) {
2045 getInset(i)->ascii(buffer, ost);
2049 return ost.str().c_str();
2053 void Paragraph::setInsetOwner(Inset * i)
2055 pimpl_->inset_owner = i;
2056 InsetList::const_iterator cit = insetlist.begin();
2057 InsetList::const_iterator end = insetlist.end();
2058 for (; cit != end; ++cit) {
2060 cit->inset->setOwner(i);
2065 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2068 InsetList::const_iterator cit = insetlist.begin();
2069 InsetList::const_iterator end = insetlist.end();
2070 for (; cit != end; ++cit) {
2071 if (cit->inset && cit->inset->isTextInset()) {
2072 static_cast<UpdatableInset *>
2073 (cit->inset)->deleteLyXText(bv, true);
2079 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2082 InsetList::const_iterator cit = insetlist.begin();
2083 InsetList::const_iterator end = insetlist.end();
2084 for (; cit != end; ++cit) {
2086 if (cit->inset->isTextInset()) {
2087 static_cast<UpdatableInset *>
2088 (cit->inset)->resizeLyXText(bv, true);
2095 void Paragraph::setContentsFromPar(Paragraph * par)
2097 pimpl_->setContentsFromPar(par);
2101 lyx::pos_type Paragraph::size() const
2103 return pimpl_->size();
2107 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2109 return pimpl_->getChar(pos);
2113 int Paragraph::id() const
2119 void Paragraph::id(int id_arg)
2121 pimpl_->id_ = id_arg;
2125 LyXLayout_ptr const & Paragraph::layout() const
2131 void Paragraph::layout(LyXLayout_ptr const & new_layout)
2133 layout_ = new_layout;
2137 bool Paragraph::isFirstInSequence() const
2139 Paragraph const * dhook = depthHook(getDepth());
2140 return (dhook == this
2141 || dhook->layout() != layout()
2142 || dhook->getDepth() != getDepth());
2146 Inset * Paragraph::inInset() const
2148 return pimpl_->inset_owner;
2152 void Paragraph::clearContents()
2158 void Paragraph::setCounter(int i, int v)
2160 pimpl_->counter_[i] = v;
2164 int Paragraph::getCounter(int i) const
2166 return pimpl_->counter_[i];
2170 void Paragraph::incCounter(int i)
2172 pimpl_->counter_[i]++;
2176 void Paragraph::setChar(pos_type pos, value_type c)
2178 pimpl_->setChar(pos, c);
2182 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2187 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2189 return inset_iterator(insetlist.begin());
2193 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2195 return inset_iterator(insetlist.end());
2199 ParagraphParameters & Paragraph::params()
2201 return pimpl_->params;
2205 ParagraphParameters const & Paragraph::params() const
2207 return pimpl_->params;
2211 Paragraph * Paragraph::getParFromID(int id) const
2213 return pimpl_->getParFromID(id);
2217 bool Paragraph::isFreeSpacing() const
2219 // for now we just need this, later should we need this in some
2220 // other way we can always add a function to Inset::() too.
2221 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2222 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);