1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "paragraph.h"
18 #include "paragraph_pimpl.h"
22 #include "tex-strings.h"
24 #include "bufferparams.h"
26 #include "LaTeXFeatures.h"
28 #include "BufferView.h"
30 #include "ParameterStruct.h"
32 #include "lyxtextclasslist.h"
34 #include "insets/insetinclude.h"
35 #include "insets/insetbib.h"
36 #include "insets/insettext.h"
38 #include "support/filetools.h"
39 #include "support/lstrings.h"
40 #include "support/lyxmanip.h"
41 #include "support/FileInfo.h"
42 #include "support/LAssert.h"
43 #include "support/textutils.h"
53 using std::lower_bound;
54 using std::upper_bound;
59 int tex_code_break_column = 72; // needs non-zero initialization. set later.
60 // this is a bad idea, but how can Paragraph find its buffer to get
61 // parameters? (JMarc)
63 extern string bibitemWidest(Buffer const *);
65 // this is a minibuffer
70 LyXFont minibuffer_font;
71 Inset * minibuffer_inset;
76 extern BufferView * current_view;
79 Paragraph::Paragraph()
80 : pimpl_(new Paragraph::Pimpl(this))
82 for (int i = 0; i < 10; ++i)
88 bibkey = 0; // ale970302
93 // This constructor inserts the new paragraph in a list.
94 Paragraph::Paragraph(Paragraph * par)
95 : pimpl_(new Paragraph::Pimpl(this))
97 for (int i = 0; i < 10; ++i)
102 // double linked list begin
105 next_->previous_ = this;
107 previous_->next_ = this;
110 bibkey = 0; // ale970302
116 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
117 : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
119 for (int i = 0; i < 10; ++i)
126 // this is because of the dummy layout of the paragraphs that
128 layout_ = lp.layout();
132 bibkey = static_cast<InsetBibKey *>
133 (lp.bibkey->clone(*current_view->buffer()));
138 // copy everything behind the break-position to the new paragraph
139 insetlist = lp.insetlist;
140 for (InsetList::iterator it = insetlist.begin();
141 it != insetlist.end(); ++it)
143 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
144 // tell the new inset who is the boss now
145 it->inset->parOwner(this);
150 // the destructor removes the new paragraph from the list
151 Paragraph::~Paragraph()
154 previous_->next_ = next_;
156 next_->previous_ = previous_;
158 for (InsetList::iterator it = insetlist.begin();
159 it != insetlist.end(); ++it) {
168 //lyxerr << "Paragraph::paragraph_id = "
169 // << Paragraph::paragraph_id << endl;
173 void Paragraph::writeFile(Buffer const * buf, ostream & os,
174 BufferParams const & bparams,
175 depth_type dth) const
177 // The beginning or end of a deeper (i.e. nested) area?
178 if (dth != params().depth()) {
179 if (params().depth() > dth) {
180 while (params().depth() > dth) {
181 os << "\n\\begin_deeper ";
185 while (params().depth() < dth) {
186 os << "\n\\end_deeper ";
192 // First write the layout
193 os << "\n\\layout " << layout() << "\n";
195 // Maybe some vertical spaces.
196 if (params().spaceTop().kind() != VSpace::NONE)
197 os << "\\added_space_top "
198 << params().spaceTop().asLyXCommand() << " ";
199 if (params().spaceBottom().kind() != VSpace::NONE)
200 os << "\\added_space_bottom "
201 << params().spaceBottom().asLyXCommand() << " ";
203 // Maybe the paragraph has special spacing
204 params().spacing().writeFile(os, true);
206 // The labelwidth string used in lists.
207 if (!params().labelWidthString().empty())
208 os << "\\labelwidthstring "
209 << params().labelWidthString() << '\n';
211 // Lines above or below?
212 if (params().lineTop())
214 if (params().lineBottom())
215 os << "\\line_bottom ";
217 // Pagebreaks above or below?
218 if (params().pagebreakTop())
219 os << "\\pagebreak_top ";
220 if (params().pagebreakBottom())
221 os << "\\pagebreak_bottom ";
223 // Start of appendix?
224 if (params().startOfAppendix())
225 os << "\\start_of_appendix ";
228 if (params().noindent())
232 if (params().align() != LYX_ALIGN_LAYOUT) {
234 switch (params().align()) {
235 case LYX_ALIGN_LEFT: h = 1; break;
236 case LYX_ALIGN_RIGHT: h = 2; break;
237 case LYX_ALIGN_CENTER: h = 3; break;
238 default: h = 0; break;
240 os << "\\align " << string_align[h] << " ";
245 bibkey->write(buf, os);
247 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
250 for (pos_type i = 0; i < size(); ++i) {
256 // Write font changes
257 LyXFont font2 = getFontSettings(bparams, i);
258 if (font2 != font1) {
259 #ifndef INHERIT_LANGUAGE
260 font2.lyxWriteChanges(font1, os);
262 font2.lyxWriteChanges(font1, bparams.language, os);
268 value_type const c = getChar(i);
272 Inset const * inset = getInset(i);
274 if (inset->directWrite()) {
275 // international char, let it write
276 // code directly so it's shorter in
278 inset->write(buf, os);
280 os << "\n\\begin_inset ";
281 inset->write(buf, os);
282 os << "\n\\end_inset \n\n";
288 os << "\n\\newline \n";
292 os << "\n\\hfill \n";
296 os << "\n\\backslash \n";
300 if (i + 1 < size() && getChar(i + 1) == ' ') {
307 if ((column > 70 && c == ' ')
312 // this check is to amend a bug. LyX sometimes
313 // inserts '\0' this could cause problems.
317 lyxerr << "ERROR (Paragraph::writeFile):"
318 " NULL char in structure." << endl;
324 // now write the next paragraph
326 next_->writeFile(buf, os, bparams, dth);
330 void Paragraph::validate(LaTeXFeatures & features) const
332 BufferParams const & bparams = features.bufferParams();
335 if (params().lineTop() || params().lineBottom())
336 features.require("lyxline");
337 if (!params().spacing().isDefault())
338 features.require("setspace");
341 features.useLayout(layout());
344 Language const * doc_language = bparams.language;
346 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
347 cit != pimpl_->fontlist.end(); ++cit) {
348 if (cit->font().noun() == LyXFont::ON) {
349 lyxerr[Debug::LATEX] << "font.noun: "
350 << cit->font().noun()
352 features.require("noun");
353 lyxerr[Debug::LATEX] << "Noun enabled. Font: "
354 << cit->font().stateText(0)
357 switch (cit->font().color()) {
359 case LColor::inherit:
361 // probably we should put here all interface colors used for
362 // font displaying! For now I just add this ones I know of (Jug)
367 features.require("color");
368 lyxerr[Debug::LATEX] << "Color enabled. Font: "
369 << cit->font().stateText(0)
373 Language const * language = cit->font().language();
374 if (language->babel() != doc_language->babel() &&
375 language != ignore_language &&
376 #ifdef INHERIT_LANGUAGE
377 language != inherit_language &&
379 language != latex_language)
381 features.useLanguage(language);
382 lyxerr[Debug::LATEX] << "Found language "
383 << language->babel() << endl;
388 LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
390 for (InsetList::const_iterator cit = insetlist.begin();
391 cit != insetlist.end(); ++cit) {
393 cit->inset->validate(features);
394 if (lout.needprotect &&
395 cit->inset->lyxCode() == Inset::FOOT_CODE)
396 features.require("NeedLyXFootnoteCode");
402 // First few functions needed for cut and paste and paragraph breaking.
403 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
405 BufferParams bparams = buffer.params;
407 minibuffer_char = getChar(pos);
408 minibuffer_font = getFontSettings(bparams, pos);
409 minibuffer_inset = 0;
410 if (minibuffer_char == Paragraph::META_INSET) {
412 minibuffer_inset = getInset(pos)->clone(buffer);
414 minibuffer_inset = 0;
415 minibuffer_char = ' ';
416 // This reflects what GetInset() does (ARRae)
422 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
424 minibuffer_char = getChar(pos);
425 minibuffer_font = getFontSettings(bparams, pos);
426 minibuffer_inset = 0;
427 if (minibuffer_char == Paragraph::META_INSET) {
429 minibuffer_inset = getInset(pos);
430 // This is a little hack since I want exactly
431 // the inset, not just a clone. Otherwise
432 // the inset would be deleted when calling Erase(pos)
434 InsetTable search_elem(pos, 0);
435 InsetList::iterator it =
436 lower_bound(insetlist.begin(),
438 search_elem, Pimpl::matchIT());
439 if (it != insetlist.end() && it->pos == pos)
441 // the inset is not in a paragraph anymore
442 minibuffer_inset->parOwner(0);
444 minibuffer_inset = 0;
445 minibuffer_char = ' ';
446 // This reflects what GetInset() does (ARRae)
451 // Erase(pos); now the caller is responsible for that.
455 bool Paragraph::insertFromMinibuffer(pos_type pos)
457 if (minibuffer_char == Paragraph::META_INSET) {
458 if (!insetAllowed(minibuffer_inset->lyxCode())) {
461 insertInset(pos, minibuffer_inset, minibuffer_font);
463 LyXFont f = minibuffer_font;
464 if (!checkInsertChar(f)) {
467 insertChar(pos, minibuffer_char, f);
476 void Paragraph::clear()
486 void Paragraph::erase(pos_type pos)
492 bool Paragraph::checkInsertChar(LyXFont & font)
494 if (pimpl_->inset_owner)
495 return pimpl_->inset_owner->checkInsertChar(font);
500 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
502 LyXFont const f(LyXFont::ALL_INHERIT);
503 insertChar(pos, c, f);
507 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
508 LyXFont const & font)
510 pimpl_->insertChar(pos, c, font);
514 void Paragraph::insertInset(pos_type pos, Inset * inset)
516 LyXFont const f(LyXFont::ALL_INHERIT);
517 insertInset(pos, inset, f);
521 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
523 pimpl_->insertInset(pos, inset, font);
527 bool Paragraph::insetAllowed(Inset::Code code)
529 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
531 if (pimpl_->inset_owner)
532 return pimpl_->inset_owner->insetAllowed(code);
537 Inset * Paragraph::getInset(pos_type pos)
539 lyx::Assert(pos < size());
542 InsetTable search_inset(pos, 0);
543 InsetList::iterator it = lower_bound(insetlist.begin(),
545 search_inset, Pimpl::matchIT());
546 if (it != insetlist.end() && it->pos == pos)
549 lyxerr << "ERROR (Paragraph::getInset): "
550 "Inset does not exist: " << pos << endl;
553 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
554 // Did this commenting out introduce a bug? So far I have not
555 // see any, please enlighten me. (Lgb)
556 // My guess is that since the inset does not exist, we might
557 // as well replace it with a space to prevent craches. (Asger)
562 Inset const * Paragraph::getInset(pos_type pos) const
564 lyx::Assert(pos < size());
567 InsetTable search_inset(pos, 0);
568 InsetList::const_iterator cit = lower_bound(insetlist.begin(),
570 search_inset, Pimpl::matchIT());
571 if (cit != insetlist.end() && cit->pos == pos)
574 lyxerr << "ERROR (Paragraph::GetInset): "
575 "Inset does not exist: " << pos << endl;
577 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
578 // Did this commenting out introduce a bug? So far I have not
579 // see any, please enlighten me. (Lgb)
580 // My guess is that since the inset does not exist, we might
581 // as well replace it with a space to prevent craches. (Asger)
586 // Gets uninstantiated font setting at position.
587 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
590 lyx::Assert(pos <= size());
592 Pimpl::FontTable search_font(pos, LyXFont());
593 Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
594 pimpl_->fontlist.end(),
595 search_font, Pimpl::matchFT());
597 if (cit != pimpl_->fontlist.end()) {
598 retfont = cit->font();
599 } else if (pos == size() && size()) {
600 retfont = getFontSettings(bparams, pos - 1);
602 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
603 #ifdef INHERIT_LANGUAGE
604 if (retfont.language() == inherit_language)
605 retfont.setLanguage(bparams.language);
612 // Gets uninstantiated font setting at position 0
613 LyXFont const Paragraph::getFirstFontSettings() const
615 if (size() > 0 && !pimpl_->fontlist.empty())
616 return pimpl_->fontlist[0].font();
618 return LyXFont(LyXFont::ALL_INHERIT);
622 // Gets the fully instantiated font at a given position in a paragraph
623 // This is basically the same function as LyXText::GetFont() in text2.C.
624 // The difference is that this one is used for generating the LaTeX file,
625 // and thus cosmetic "improvements" are disallowed: This has to deliver
626 // the true picture of the buffer. (Asger)
627 // If position is -1, we get the layout font of the paragraph.
628 // If position is -2, we get the font of the manual label of the paragraph.
629 LyXFont const Paragraph::getFont(BufferParams const & bparams,
632 lyx::Assert(pos >= 0);
634 LyXLayout const & lout =
635 textclasslist[bparams.textclass][layout()];
636 pos_type main_body = 0;
637 if (lout.labeltype == LABEL_MANUAL)
638 main_body = beginningOfMainBody();
642 layoutfont = lout.labelfont;
644 layoutfont = lout.font;
646 LyXFont tmpfont = getFontSettings(bparams, pos);
647 #ifndef INHERIT_LANGUAGE
648 tmpfont.realize(layoutfont);
650 tmpfont.realize(layoutfont, bparams.language);
653 return pimpl_->realizeFont(tmpfont, bparams);
657 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
659 LyXLayout const & lout =
660 textclasslist[bparams.textclass][layout()];
662 LyXFont tmpfont = lout.labelfont;
663 tmpfont.setLanguage(getParLanguage(bparams));
665 return pimpl_->realizeFont(tmpfont, bparams);
669 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
671 LyXLayout const & lout =
672 textclasslist[bparams.textclass][layout()];
674 LyXFont tmpfont = lout.font;
675 tmpfont.setLanguage(getParLanguage(bparams));
677 return pimpl_->realizeFont(tmpfont, bparams);
681 /// Returns the height of the highest font in range
683 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
684 LyXFont::FONT_SIZE const def_size) const
686 if (pimpl_->fontlist.empty())
689 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
690 Pimpl::FontTable end_search(endpos, LyXFont());
691 Pimpl::FontList::const_iterator end_it =
692 lower_bound(pimpl_->fontlist.begin(),
693 pimpl_->fontlist.end(),
694 end_search, Pimpl::matchFT());
695 if (end_it != pimpl_->fontlist.end())
698 Pimpl::FontTable start_search(startpos, LyXFont());
699 Pimpl::FontList::const_iterator cit =
700 lower_bound(pimpl_->fontlist.begin(),
701 pimpl_->fontlist.end(),
702 start_search, Pimpl::matchFT());
704 for (; cit != end_it; ++cit) {
705 LyXFont::FONT_SIZE size = cit->font().size();
706 if (size == LyXFont::INHERIT_SIZE)
708 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
715 Paragraph::value_type
716 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
718 value_type c = getChar(pos);
719 if (!lyxrc.rtl_support)
749 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
756 void Paragraph::setFont(pos_type pos, LyXFont const & font)
758 lyx::Assert(pos <= size());
760 // First, reduce font against layout/label font
761 // Update: The SetCharFont() routine in text2.C already
762 // reduces font, so we don't need to do that here. (Asger)
763 // No need to simplify this because it will disappear
764 // in a new kernel. (Asger)
765 // Next search font table
767 Pimpl::FontTable search_font(pos, LyXFont());
768 Pimpl::FontList::iterator it = lower_bound(pimpl_->fontlist.begin(),
769 pimpl_->fontlist.end(),
770 search_font, Pimpl::matchFT());
771 unsigned int i = it - pimpl_->fontlist.begin();
772 bool notfound = it == pimpl_->fontlist.end();
774 if (!notfound && pimpl_->fontlist[i].font() == font)
777 bool begin = pos == 0 || notfound ||
778 (i > 0 && pimpl_->fontlist[i-1].pos() == pos - 1);
779 // Is position pos is a beginning of a font block?
780 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
781 // Is position pos is the end of a font block?
782 if (begin && end) { // A single char block
783 if (i + 1 < pimpl_->fontlist.size() &&
784 pimpl_->fontlist[i + 1].font() == font) {
785 // Merge the singleton block with the next block
786 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
787 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
788 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
789 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
790 // Merge the singleton block with the previous block
791 pimpl_->fontlist[i - 1].pos(pos);
792 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
794 pimpl_->fontlist[i].font(font);
796 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
797 pimpl_->fontlist[i - 1].pos(pos);
799 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
800 Pimpl::FontTable(pos, font));
802 pimpl_->fontlist[i].pos(pos - 1);
803 if (!(i + 1 < pimpl_->fontlist.size() &&
804 pimpl_->fontlist[i + 1].font() == font))
805 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
806 Pimpl::FontTable(pos, font));
807 } else { // The general case. The block is splitted into 3 blocks
808 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
809 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
810 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
811 Pimpl::FontTable(pos, font));
817 void Paragraph::next(Paragraph * p)
823 // This function is able to hide closed footnotes.
824 Paragraph * Paragraph::next()
830 Paragraph const * Paragraph::next() const
836 void Paragraph::previous(Paragraph * p)
842 // This function is able to hide closed footnotes.
843 Paragraph * Paragraph::previous()
849 // This function is able to hide closed footnotes.
850 Paragraph const * Paragraph::previous() const
856 void Paragraph::breakParagraph(BufferParams const & bparams,
860 // create a new paragraph
861 Paragraph * tmp = new Paragraph(this);
862 // remember to set the inset_owner
863 tmp->setInsetOwner(inInset());
865 // this is an idea for a more userfriendly layout handling, I will
866 // see what the users say
868 // layout stays the same with latex-environments
870 tmp->layout(layout());
871 tmp->setLabelWidthString(params().labelWidthString());
874 if (size() > pos || !size() || flag == 2) {
875 tmp->layout(layout());
876 tmp->params().align(params().align());
877 tmp->setLabelWidthString(params().labelWidthString());
879 tmp->params().lineBottom(params().lineBottom());
880 params().lineBottom(false);
881 tmp->params().pagebreakBottom(params().pagebreakBottom());
882 params().pagebreakBottom(false);
883 tmp->params().spaceBottom(params().spaceBottom());
884 params().spaceBottom(VSpace(VSpace::NONE));
886 tmp->params().depth(params().depth());
887 tmp->params().noindent(params().noindent());
889 // copy everything behind the break-position
890 // to the new paragraph
891 pos_type pos_end = size() - 1;
894 for (; i <= pos_end; ++i) {
895 cutIntoMinibuffer(bparams, i);
896 if (tmp->insertFromMinibuffer(j - pos))
899 for (i = pos_end; i >= pos; --i) {
904 // just an idea of me
906 tmp->params().lineTop(params().lineTop());
907 tmp->params().pagebreakTop(params().pagebreakTop());
908 tmp->params().spaceTop(params().spaceTop());
909 tmp->bibkey = bibkey;
911 // layout stays the same with latex-environments
913 layout(tmp->layout());
914 setLabelWidthString(tmp->params().labelWidthString());
915 params().depth(tmp->params().depth());
921 void Paragraph::makeSameLayout(Paragraph const * par)
923 layout(par->layout());
925 params() = par->params();
929 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
931 if (textclasslist[tclass][layout()].free_spacing ||
937 while (size() && (isNewline(0) || isLineSeparator(0))) {
946 bool Paragraph::hasSameLayout(Paragraph const * par) const
949 par->layout() == layout() &&
950 params().sameLayout(par->params());
954 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
957 // create a new paragraph
958 Paragraph * tmp = new Paragraph(this);
959 tmp->makeSameLayout(this);
961 // When can pos > Last()?
962 // I guess pos == Last() is possible.
964 // copy everything behind the break-position to the new
966 pos_type pos_end = size() - 1;
970 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
971 cutIntoMinibuffer(bparams, i);
972 if (tmp->insertFromMinibuffer(j - pos))
976 for (pos_type k = pos_end; k >= pos; --k) {
983 // Be carefull, this does not make any check at all.
984 // This method has wrong name, it combined this par with the next par.
985 // In that sense it is the reverse of break paragraph. (Lgb)
986 void Paragraph::pasteParagraph(BufferParams const & bparams)
988 // copy the next paragraph to this one
989 Paragraph * the_next = next();
991 // first the DTP-stuff
992 params().lineBottom(the_next->params().lineBottom());
993 params().spaceBottom(the_next->params().spaceBottom());
994 params().pagebreakBottom(the_next->params().pagebreakBottom());
996 pos_type pos_end = the_next->pimpl_->size() - 1;
997 pos_type pos_insert = size();
999 // ok, now copy the paragraph
1000 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1001 the_next->cutIntoMinibuffer(bparams, i);
1002 if (insertFromMinibuffer(pos_insert + j))
1006 // delete the next paragraph
1007 Paragraph * ppar = the_next->previous_;
1008 Paragraph * npar = the_next->next_;
1014 int Paragraph::getEndLabel(BufferParams const & bparams) const
1016 Paragraph const * par = this;
1017 depth_type par_depth = getDepth();
1019 string const & layout = par->layout();
1020 int const endlabeltype =
1021 textclasslist[bparams.textclass][layout].endlabeltype;
1022 if (endlabeltype != END_LABEL_NO_LABEL) {
1024 return endlabeltype;
1026 depth_type const next_depth = next_->getDepth();
1027 if (par_depth > next_depth ||
1028 (par_depth == next_depth
1029 && layout != next_->layout()))
1030 return endlabeltype;
1035 par = par->outerHook();
1037 par_depth = par->getDepth();
1039 return END_LABEL_NO_LABEL;
1043 Paragraph::depth_type Paragraph::getDepth() const
1045 return params().depth();
1049 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1051 bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
1054 return params().depth() + 1;
1056 return params().depth();
1060 char Paragraph::getAlign() const
1062 return params().align();
1066 string const & Paragraph::getLabelstring() const
1068 return params().labelString();
1072 int Paragraph::getFirstCounter(int i) const
1074 return pimpl_->counter_[i];
1078 // the next two functions are for the manual labels
1079 string const Paragraph::getLabelWidthString() const
1081 if (!params().labelWidthString().empty())
1082 return params().labelWidthString();
1084 return _("Senseless with this layout!");
1088 void Paragraph::setLabelWidthString(string const & s)
1090 params().labelWidthString(s);
1094 void Paragraph::applyLayout(string const & new_layout)
1097 params().labelWidthString(string());
1098 params().align(LYX_ALIGN_LAYOUT);
1099 params().spaceTop(VSpace(VSpace::NONE));
1100 params().spaceBottom(VSpace(VSpace::NONE));
1101 params().spacing(Spacing(Spacing::Default));
1105 // if the layout of a paragraph contains a manual label, the beginning of the
1106 // main body is the beginning of the second word. This is what the par-
1107 // function returns. If the layout does not contain a label, the main
1108 // body always starts with position 0. This differentiation is necessary,
1109 // because there cannot be a newline or a blank <= the beginning of the
1110 // main body in TeX.
1112 int Paragraph::beginningOfMainBody() const
1114 // Unroll the first two cycles of the loop
1115 // and remember the previous character to
1116 // remove unnecessary GetChar() calls
1119 && getChar(i) != Paragraph::META_NEWLINE) {
1121 char previous_char = 0;
1124 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1125 // Yes, this ^ is supposed to be "= " not "=="
1128 && previous_char != ' '
1129 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1131 previous_char = temp;
1140 Paragraph * Paragraph::depthHook(depth_type depth)
1142 Paragraph * newpar = this;
1145 newpar = newpar->previous();
1146 } while (newpar && newpar->getDepth() > depth);
1149 if (previous() || getDepth())
1150 lyxerr << "ERROR (Paragraph::DepthHook): "
1159 Paragraph const * Paragraph::depthHook(depth_type depth) const
1161 Paragraph const * newpar = this;
1164 newpar = newpar->previous();
1165 } while (newpar && newpar->getDepth() > depth);
1168 if (previous() || getDepth())
1169 lyxerr << "ERROR (Paragraph::DepthHook): "
1177 Paragraph * Paragraph::outerHook()
1181 return depthHook(depth_type(getDepth() - 1));
1184 Paragraph const * Paragraph::outerHook() const
1188 return depthHook(depth_type(getDepth() - 1));
1192 Paragraph::inset_iterator
1193 Paragraph::InsetIterator(pos_type pos)
1195 InsetTable search_inset(pos, 0);
1196 InsetList::iterator it = lower_bound(insetlist.begin(),
1198 search_inset, Pimpl::matchIT());
1199 return inset_iterator(it);
1203 // returns -1 if inset not found
1204 int Paragraph::getPositionOfInset(Inset const * inset) const
1207 for (InsetList::const_iterator cit = insetlist.begin();
1208 cit != insetlist.end(); ++cit) {
1209 if (cit->inset == inset) {
1213 if (inset == bibkey)
1220 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1221 BufferParams const & bparams,
1222 ostream & os, TexRow & texrow,
1225 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1226 Inset const * in = inInset();
1227 bool further_blank_line = false;
1230 // well we have to check if we are in an inset with unlimited
1231 // lenght (all in one row) if that is true then we don't allow
1232 // any special options in the paragraph and also we don't allow
1233 // any environment other then "Standard" to be valid!
1234 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1235 style = textclasslist[bparams.textclass][layout()];
1237 if (params().startOfAppendix()) {
1238 os << "\\appendix\n";
1242 if (!params().spacing().isDefault()
1243 && (!previous() || !previous()->hasSameLayout(this))) {
1244 os << params().spacing().writeEnvirBegin() << "\n";
1248 if (tex_code_break_column && style.isCommand()) {
1253 if (params().pagebreakTop()) {
1255 further_blank_line = true;
1257 if (params().spaceTop().kind() != VSpace::NONE) {
1258 os << params().spaceTop().asLatexCommand(bparams);
1259 further_blank_line = true;
1262 if (params().lineTop()) {
1263 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1264 << "\\vspace{-1\\parskip}";
1265 further_blank_line = true;
1268 if (further_blank_line) {
1273 style = textclasslist[bparams.textclass].defaultLayout();
1276 Language const * language = getParLanguage(bparams);
1277 Language const * doc_language = bparams.language;
1278 Language const * previous_language = previous()
1279 ? previous()->getParLanguage(bparams) : doc_language;
1281 if (language->babel() != previous_language->babel()
1282 // check if we already put language command in TeXEnvironment()
1283 && !(style.isEnvironment()
1284 && (!previous() || previous()->layout() != layout() ||
1285 previous()->params().depth() != params().depth())))
1287 if (!lyxrc.language_command_end.empty() &&
1288 previous_language->babel() != doc_language->babel())
1290 os << subst(lyxrc.language_command_end, "$$lang",
1291 previous_language->babel())
1296 if (lyxrc.language_command_end.empty() ||
1297 language->babel() != doc_language->babel())
1299 os << subst(lyxrc.language_command_begin, "$$lang",
1306 if (bparams.inputenc == "auto" &&
1307 language->encoding() != previous_language->encoding()) {
1308 os << "\\inputencoding{"
1309 << language->encoding()->LatexName()
1314 switch (style.latextype) {
1317 << style.latexname()
1318 << style.latexparam();
1320 case LATEX_ITEM_ENVIRONMENT:
1322 bibkey->latex(buf, os, false, false);
1326 case LATEX_LIST_ENVIRONMENT:
1333 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1335 // Make sure that \\par is done with the font of the last
1336 // character if this has another size as the default.
1337 // This is necessary because LaTeX (and LyX on the screen)
1338 // calculates the space between the baselines according
1339 // to this font. (Matthias)
1341 // Is this really needed ? (Dekel)
1342 // We do not need to use to change the font for the last paragraph
1343 // or for a command.
1344 LyXFont const font =
1346 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1348 bool is_command = style.isCommand();
1350 if (style.resfont.size() != font.size() && next_ && !is_command) {
1353 os << "\\" << font.latexSize() << " \\par}";
1354 } else if (need_par) {
1356 } else if (is_command)
1359 switch (style.latextype) {
1360 case LATEX_ITEM_ENVIRONMENT:
1361 case LATEX_LIST_ENVIRONMENT:
1362 if (next_ && (params().depth() < next_->params().depth())) {
1367 case LATEX_ENVIRONMENT:
1368 // if its the last paragraph of the current environment
1369 // skip it otherwise fall through
1371 && (next_->layout() != layout()
1372 || next_->params().depth() != params().depth()))
1374 // fall through possible
1376 // we don't need it for the last paragraph!!!
1383 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1384 further_blank_line = false;
1385 if (params().lineBottom()) {
1386 os << "\\lyxline{\\" << font.latexSize() << '}';
1387 further_blank_line = true;
1390 if (params().spaceBottom().kind() != VSpace::NONE) {
1391 os << params().spaceBottom().asLatexCommand(bparams);
1392 further_blank_line = true;
1395 if (params().pagebreakBottom()) {
1397 further_blank_line = true;
1400 if (further_blank_line) {
1405 if (!params().spacing().isDefault()
1406 && (!next_ || !next_->hasSameLayout(this))) {
1407 os << params().spacing().writeEnvirEnd() << "\n";
1412 // we don't need it for the last paragraph!!!
1417 // Since \selectlanguage write the language to the aux file,
1418 // we need to reset the language at the end of footnote or
1421 if (language->babel() != doc_language->babel()) {
1422 if (lyxrc.language_command_end.empty())
1423 os << subst(lyxrc.language_command_begin,
1425 doc_language->babel())
1428 os << subst(lyxrc.language_command_end,
1436 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1440 // This could go to ParagraphParameters if we want to
1441 int Paragraph::startTeXParParams(BufferParams const & bparams,
1446 if (params().noindent()) {
1447 os << "\\noindent ";
1451 switch (params().align()) {
1452 case LYX_ALIGN_NONE:
1453 case LYX_ALIGN_BLOCK:
1454 case LYX_ALIGN_LAYOUT:
1455 case LYX_ALIGN_SPECIAL:
1457 case LYX_ALIGN_LEFT:
1458 if (getParLanguage(bparams)->babel() != "hebrew") {
1459 os << "\\begin{flushleft}";
1462 os << "\\begin{flushright}";
1466 case LYX_ALIGN_RIGHT:
1467 if (getParLanguage(bparams)->babel() != "hebrew") {
1468 os << "\\begin{flushright}";
1471 os << "\\begin{flushleft}";
1475 case LYX_ALIGN_CENTER:
1476 os << "\\begin{center}";
1484 // This could go to ParagraphParameters if we want to
1485 int Paragraph::endTeXParParams(BufferParams const & bparams,
1490 switch (params().align()) {
1491 case LYX_ALIGN_NONE:
1492 case LYX_ALIGN_BLOCK:
1493 case LYX_ALIGN_LAYOUT:
1494 case LYX_ALIGN_SPECIAL:
1496 case LYX_ALIGN_LEFT:
1497 if (getParLanguage(bparams)->babel() != "hebrew") {
1498 os << "\\end{flushleft}";
1501 os << "\\end{flushright}";
1505 case LYX_ALIGN_RIGHT:
1506 if (getParLanguage(bparams)->babel() != "hebrew") {
1507 os << "\\end{flushright}";
1510 os << "\\end{flushleft}";
1514 case LYX_ALIGN_CENTER:
1515 os << "\\end{center}";
1523 // This one spits out the text of the paragraph
1524 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1525 BufferParams const & bparams,
1526 ostream & os, TexRow & texrow,
1529 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1531 bool return_value = false;
1535 // well we have to check if we are in an inset with unlimited
1536 // lenght (all in one row) if that is true then we don't allow
1537 // any special options in the paragraph and also we don't allow
1538 // any environment other then "Standard" to be valid!
1540 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1543 style = textclasslist[bparams.textclass].defaultLayout();
1545 style = textclasslist[bparams.textclass][layout()];
1550 // Maybe we have to create a optional argument.
1552 if (style.labeltype != LABEL_MANUAL)
1555 main_body = beginningOfMainBody();
1559 if (main_body > 0) {
1562 basefont = getLabelFont(bparams);
1564 basefont = getLayoutFont(bparams);
1567 moving_arg |= style.needprotect;
1569 // Which font is currently active?
1570 LyXFont running_font(basefont);
1571 // Do we have an open font change?
1572 bool open_font = false;
1574 texrow.start(this, 0);
1576 // if the paragraph is empty, the loop will not be entered at all
1578 if (style.isCommand()) {
1583 column += startTeXParParams(bparams, os);
1587 for (pos_type i = 0; i < size(); ++i) {
1589 // First char in paragraph or after label?
1590 if (i == main_body) {
1591 if (main_body > 0) {
1593 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1596 basefont = getLayoutFont(bparams);
1597 running_font = basefont;
1601 if (style.isCommand()) {
1607 column += startTeXParParams(bparams, os);
1610 value_type c = getChar(i);
1612 // Fully instantiated font
1613 LyXFont font = getFont(bparams, i);
1615 LyXFont const & last_font = running_font;
1617 // Spaces at end of font change are simulated to be
1618 // outside font change, i.e. we write "\textXX{text} "
1619 // rather than "\textXX{text }". (Asger)
1620 if (open_font && c == ' ' && i <= size() - 2) {
1621 LyXFont const & next_font = getFont(bparams, i + 1);
1622 if (next_font != running_font
1623 && next_font != font) {
1628 // We end font definition before blanks
1629 if (font != running_font && open_font) {
1630 column += running_font.latexWriteEndChanges(os,
1632 (i == main_body-1) ? basefont : font);
1633 running_font = basefont;
1637 // Blanks are printed before start of fontswitch
1639 // Do not print the separation of the optional argument
1640 if (i != main_body - 1) {
1641 pimpl_->simpleTeXBlanks(os, texrow, i,
1642 column, font, style);
1646 // Do we need to change font?
1647 if (font != running_font && i != main_body - 1) {
1648 column += font.latexWriteStartChanges(os, basefont,
1650 running_font = font;
1654 if (c == Paragraph::META_NEWLINE) {
1655 // newlines are handled differently here than
1656 // the default in SimpleTeXSpecialChars().
1657 if (!style.newline_allowed) {
1661 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1664 basefont = getLayoutFont(bparams);
1665 running_font = basefont;
1666 if (font.family() ==
1667 LyXFont::TYPEWRITER_FAMILY) {
1675 texrow.start(this, i + 1);
1678 pimpl_->simpleTeXSpecialChars(buf, bparams,
1679 os, texrow, moving_arg,
1681 basefont, open_font,
1682 style, i, column, c);
1686 // If we have an open font definition, we have to close it
1688 #ifdef FIXED_LANGUAGE_END_DETECTION
1691 .latexWriteEndChanges(os, basefont,
1692 next_->getFont(bparams,
1695 running_font.latexWriteEndChanges(os, basefont,
1699 #ifdef WITH_WARNINGS
1700 //#warning For now we ALWAYS have to close the foreign font settings if they are
1701 //#warning there as we start another \selectlanguage with the next paragraph if
1702 //#warning we are in need of this. This should be fixed sometime (Jug)
1704 running_font.latexWriteEndChanges(os, basefont, basefont);
1708 // Needed if there is an optional argument but no contents.
1709 if (main_body > 0 && main_body == size()) {
1711 return_value = false;
1715 column += endTeXParParams(bparams, os);
1718 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1719 return return_value;
1723 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1725 bool retval = false;
1727 case Paragraph::META_HFILL:
1728 sgml_string.erase();
1730 case Paragraph::META_NEWLINE:
1734 sgml_string = "&";
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 = "\";
1776 case '\0': // Ignore :-)
1777 sgml_string.erase();
1787 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1788 BufferParams const & bparams,
1789 ostream & os, TexRow & texrow)
1791 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1793 LyXLayout const & style =
1794 textclasslist[bparams.textclass][layout()];
1796 Language const * language = getParLanguage(bparams);
1797 Language const * doc_language = bparams.language;
1798 Language const * previous_language = previous_
1799 ? previous_->getParLanguage(bparams) : doc_language;
1800 if (language->babel() != previous_language->babel()) {
1802 if (!lyxrc.language_command_end.empty() &&
1803 previous_language->babel() != doc_language->babel()) {
1804 os << subst(lyxrc.language_command_end, "$$lang",
1805 previous_language->babel())
1810 if (lyxrc.language_command_end.empty() ||
1811 language->babel() != doc_language->babel()) {
1812 os << subst(lyxrc.language_command_begin, "$$lang",
1819 if (style.isEnvironment()) {
1820 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1821 os << "\\begin{" << style.latexname() << "}{"
1822 << params().labelWidthString() << "}\n";
1823 } else if (style.labeltype == LABEL_BIBLIO) {
1825 os << "\\begin{" << style.latexname() << "}{"
1826 << bibitemWidest(buf)
1828 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1829 os << "\\begin{" << style.latexname() << '}'
1830 << style.latexparam() << '\n';
1832 os << "\\begin{" << style.latexname() << '}'
1833 << style.latexparam() << '\n';
1836 Paragraph * par = this;
1838 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1840 if (par && par->params().depth() > params().depth()) {
1841 if (textclasslist[bparams.textclass][par->layout()].isParagraph()
1843 // How to handle this? (Lgb)
1844 //&& !suffixIs(os, "\n\n")
1846 // There should be at least one '\n' already
1847 // but we need there to be two for Standard
1848 // paragraphs that are depth-increment'ed to be
1849 // output correctly. However, tables can
1850 // also be paragraphs so don't adjust them.
1853 // Will it ever harm to have one '\n' too
1854 // many? i.e. that we sometimes will have
1855 // three in a row. (Lgb)
1859 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1862 && par->layout() == layout()
1863 && par->params().depth() == params().depth());
1865 if (style.isEnvironment()) {
1866 os << "\\end{" << style.latexname() << "}\n";
1870 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1871 return par; // ale970302
1875 bool Paragraph::isHfill(pos_type pos) const
1877 return IsHfillChar(getChar(pos));
1881 bool Paragraph::isInset(pos_type pos) const
1883 return IsInsetChar(getChar(pos));
1887 bool Paragraph::isNewline(pos_type pos) const
1889 return pos >= 0 && IsNewlineChar(getChar(pos));
1893 bool Paragraph::isSeparator(pos_type pos) const
1895 return IsSeparatorChar(getChar(pos));
1899 bool Paragraph::isLineSeparator(pos_type pos) const
1901 value_type const c = getChar(pos);
1902 return IsLineSeparatorChar(c)
1903 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1907 bool Paragraph::isKomma(pos_type pos) const
1909 return IsKommaChar(getChar(pos));
1913 /// Used by the spellchecker
1914 bool Paragraph::isLetter(pos_type pos) const
1916 value_type const c = getChar(pos);
1917 if (IsLetterChar(c))
1920 return getInset(pos)->isLetter();
1921 // We want to pass the ' and escape chars to ispell
1922 string const extra = lyxrc.isp_esc_chars + '\'';
1923 return contains(extra, c);
1927 bool Paragraph::isWord(pos_type pos) const
1929 return IsWordChar(getChar(pos)) ;
1934 Paragraph::getParLanguage(BufferParams const & bparams) const
1937 #ifndef INHERIT_LANGUAGE
1938 return getFirstFontSettings().language();
1940 Language const * lang = getFirstFontSettings().language();
1941 #ifdef WITH_WARNINGS
1942 #warning We should make this somewhat better, any ideas? (Jug)
1944 if (lang == inherit_language || lang == ignore_language)
1945 lang = bparams.language;
1948 } else if (previous_)
1949 return previous_->getParLanguage(bparams);
1951 return bparams.language;
1955 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1957 return lyxrc.rtl_support
1958 && getParLanguage(bparams)->RightToLeft();
1962 void Paragraph::changeLanguage(BufferParams const & bparams,
1963 Language const * from, Language const * to)
1965 for (pos_type i = 0; i < size(); ++i) {
1966 LyXFont font = getFontSettings(bparams, i);
1967 if (font.language() == from) {
1968 font.setLanguage(to);
1975 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1977 Language const * doc_language = bparams.language;
1978 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1979 cit != pimpl_->fontlist.end(); ++cit)
1980 if (cit->font().language() != ignore_language &&
1981 cit->font().language() != latex_language &&
1982 #ifdef INHERIT_LANGUAGE
1983 cit->font().language() != inherit_language &&
1985 cit->font().language() != doc_language)
1991 // Convert the paragraph to a string.
1992 // Used for building the table of contents
1993 string const Paragraph::asString(Buffer const * buffer, bool label)
1995 BufferParams const & bparams = buffer->params;
1997 if (label && !params().labelString().empty())
1998 s += params().labelString() + ' ';
1999 string::size_type const len = s.size();
2001 for (pos_type i = 0; i < size(); ++i) {
2002 value_type c = getChar(i);
2005 else if (c == META_INSET &&
2006 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2008 getInset(i)->ascii(buffer, ost);
2009 s += subst(ost.str().c_str(),'\n',' ');
2013 if (isRightToLeftPar(bparams))
2014 reverse(s.begin() + len,s.end());
2020 string const Paragraph::asString(Buffer const * buffer,
2021 pos_type beg, pos_type end, bool label)
2025 if (beg == 0 && label && !params().labelString().empty())
2026 ost << params().labelString() << ' ';
2028 for (pos_type i = beg; i < end; ++i) {
2029 value_type const c = getUChar(buffer->params, i);
2032 else if (c == META_NEWLINE)
2034 else if (c == META_HFILL)
2036 else if (c == META_INSET) {
2037 getInset(i)->ascii(buffer, ost);
2041 return ost.str().c_str();
2045 void Paragraph::setInsetOwner(Inset * i)
2047 pimpl_->inset_owner = i;
2048 for (InsetList::const_iterator cit = insetlist.begin();
2049 cit != insetlist.end(); ++cit) {
2051 cit->inset->setOwner(i);
2056 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2059 for (InsetList::const_iterator cit = insetlist.begin();
2060 cit != insetlist.end(); ++cit) {
2062 if (cit->inset->isTextInset()) {
2063 static_cast<UpdatableInset *>
2064 (cit->inset)->deleteLyXText(bv, true);
2071 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2074 for (InsetList::const_iterator cit = insetlist.begin();
2075 cit != insetlist.end(); ++cit)
2078 if (cit->inset->isTextInset()) {
2079 static_cast<UpdatableInset *>
2080 (cit->inset)->resizeLyXText(bv, true);
2087 void Paragraph::setContentsFromPar(Paragraph * par)
2089 pimpl_->setContentsFromPar(par);
2093 lyx::pos_type Paragraph::size() const
2095 return pimpl_->size();
2099 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2101 return pimpl_->getChar(pos);
2105 int Paragraph::id() const
2111 void Paragraph::id(int id_arg)
2113 pimpl_->id_ = id_arg;
2117 string const & Paragraph::layout() const
2123 void Paragraph::layout(string const & new_layout)
2125 layout_ = new_layout;
2129 bool Paragraph::isFirstInSequence() const
2131 Paragraph const * dhook = depthHook(getDepth());
2132 return (dhook == this
2133 || dhook->layout() != layout()
2134 || dhook->getDepth() != getDepth());
2138 Inset * Paragraph::inInset() const
2140 return pimpl_->inset_owner;
2144 void Paragraph::clearContents()
2150 void Paragraph::setCounter(int i, int v)
2152 pimpl_->counter_[i] = v;
2156 int Paragraph::getCounter(int i) const
2158 return pimpl_->counter_[i];
2162 void Paragraph::incCounter(int i)
2164 pimpl_->counter_[i]++;
2168 void Paragraph::setChar(pos_type pos, value_type c)
2170 pimpl_->setChar(pos, c);
2174 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2179 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2181 return inset_iterator(insetlist.begin());
2185 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2187 return inset_iterator(insetlist.end());
2191 ParagraphParameters & Paragraph::params()
2193 return pimpl_->params;
2197 ParagraphParameters const & Paragraph::params() const
2199 return pimpl_->params;
2203 Paragraph * Paragraph::getParFromID(int id) const
2205 return pimpl_->getParFromID(id);
2209 bool Paragraph::isFreeSpacing() const
2211 // for now we just need this, later should we need this in some
2212 // other way we can always add a function to Inset::() too.
2213 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2214 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);