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 tmp->layout(layout());
864 // remember to set the inset_owner
865 tmp->setInsetOwner(inInset());
867 // this is an idea for a more userfriendly layout handling, I will
868 // see what the users say
870 // layout stays the same with latex-environments
872 tmp->layout(layout());
873 tmp->setLabelWidthString(params().labelWidthString());
876 if (size() > pos || !size() || flag == 2) {
877 tmp->layout(layout());
878 tmp->params().align(params().align());
879 tmp->setLabelWidthString(params().labelWidthString());
881 tmp->params().lineBottom(params().lineBottom());
882 params().lineBottom(false);
883 tmp->params().pagebreakBottom(params().pagebreakBottom());
884 params().pagebreakBottom(false);
885 tmp->params().spaceBottom(params().spaceBottom());
886 params().spaceBottom(VSpace(VSpace::NONE));
888 tmp->params().depth(params().depth());
889 tmp->params().noindent(params().noindent());
891 // copy everything behind the break-position
892 // to the new paragraph
893 pos_type pos_end = size() - 1;
896 for (; i <= pos_end; ++i) {
897 cutIntoMinibuffer(bparams, i);
898 if (tmp->insertFromMinibuffer(j - pos))
901 for (i = pos_end; i >= pos; --i) {
906 // just an idea of me
908 tmp->params().lineTop(params().lineTop());
909 tmp->params().pagebreakTop(params().pagebreakTop());
910 tmp->params().spaceTop(params().spaceTop());
911 tmp->bibkey = bibkey;
913 // layout stays the same with latex-environments
915 layout(tmp->layout());
916 setLabelWidthString(tmp->params().labelWidthString());
917 params().depth(tmp->params().depth());
923 void Paragraph::makeSameLayout(Paragraph const * par)
925 layout(par->layout());
927 params() = par->params();
931 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
933 if (textclasslist[tclass][layout()].free_spacing ||
939 while (size() && (isNewline(0) || isLineSeparator(0))) {
948 bool Paragraph::hasSameLayout(Paragraph const * par) const
951 par->layout() == layout() &&
952 params().sameLayout(par->params());
956 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
959 // create a new paragraph
960 Paragraph * tmp = new Paragraph(this);
961 tmp->makeSameLayout(this);
963 // When can pos > Last()?
964 // I guess pos == Last() is possible.
966 // copy everything behind the break-position to the new
968 pos_type pos_end = size() - 1;
972 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
973 cutIntoMinibuffer(bparams, i);
974 if (tmp->insertFromMinibuffer(j - pos))
978 for (pos_type k = pos_end; k >= pos; --k) {
985 // Be carefull, this does not make any check at all.
986 // This method has wrong name, it combined this par with the next par.
987 // In that sense it is the reverse of break paragraph. (Lgb)
988 void Paragraph::pasteParagraph(BufferParams const & bparams)
990 // copy the next paragraph to this one
991 Paragraph * the_next = next();
993 // first the DTP-stuff
994 params().lineBottom(the_next->params().lineBottom());
995 params().spaceBottom(the_next->params().spaceBottom());
996 params().pagebreakBottom(the_next->params().pagebreakBottom());
998 pos_type pos_end = the_next->pimpl_->size() - 1;
999 pos_type pos_insert = size();
1001 // ok, now copy the paragraph
1002 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1003 the_next->cutIntoMinibuffer(bparams, i);
1004 if (insertFromMinibuffer(pos_insert + j))
1008 // delete the next paragraph
1009 Paragraph * ppar = the_next->previous_;
1010 Paragraph * npar = the_next->next_;
1016 int Paragraph::getEndLabel(BufferParams const & bparams) const
1018 Paragraph const * par = this;
1019 depth_type par_depth = getDepth();
1021 string const & layout = par->layout();
1022 int const endlabeltype =
1023 textclasslist[bparams.textclass][layout].endlabeltype;
1024 if (endlabeltype != END_LABEL_NO_LABEL) {
1026 return endlabeltype;
1028 depth_type const next_depth = next_->getDepth();
1029 if (par_depth > next_depth ||
1030 (par_depth == next_depth
1031 && layout != next_->layout()))
1032 return endlabeltype;
1037 par = par->outerHook();
1039 par_depth = par->getDepth();
1041 return END_LABEL_NO_LABEL;
1045 Paragraph::depth_type Paragraph::getDepth() const
1047 return params().depth();
1051 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1053 bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
1056 return params().depth() + 1;
1058 return params().depth();
1062 char Paragraph::getAlign() const
1064 return params().align();
1068 string const & Paragraph::getLabelstring() const
1070 return params().labelString();
1074 int Paragraph::getFirstCounter(int i) const
1076 return pimpl_->counter_[i];
1080 // the next two functions are for the manual labels
1081 string const Paragraph::getLabelWidthString() const
1083 if (!params().labelWidthString().empty())
1084 return params().labelWidthString();
1086 return _("Senseless with this layout!");
1090 void Paragraph::setLabelWidthString(string const & s)
1092 params().labelWidthString(s);
1096 void Paragraph::applyLayout(string const & new_layout)
1099 params().labelWidthString(string());
1100 params().align(LYX_ALIGN_LAYOUT);
1101 params().spaceTop(VSpace(VSpace::NONE));
1102 params().spaceBottom(VSpace(VSpace::NONE));
1103 params().spacing(Spacing(Spacing::Default));
1107 // if the layout of a paragraph contains a manual label, the beginning of the
1108 // main body is the beginning of the second word. This is what the par-
1109 // function returns. If the layout does not contain a label, the main
1110 // body always starts with position 0. This differentiation is necessary,
1111 // because there cannot be a newline or a blank <= the beginning of the
1112 // main body in TeX.
1114 int Paragraph::beginningOfMainBody() const
1116 // Unroll the first two cycles of the loop
1117 // and remember the previous character to
1118 // remove unnecessary GetChar() calls
1121 && getChar(i) != Paragraph::META_NEWLINE) {
1123 char previous_char = 0;
1126 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1127 // Yes, this ^ is supposed to be "= " not "=="
1130 && previous_char != ' '
1131 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1133 previous_char = temp;
1142 Paragraph * Paragraph::depthHook(depth_type depth)
1144 Paragraph * newpar = this;
1147 newpar = newpar->previous();
1148 } while (newpar && newpar->getDepth() > depth);
1151 if (previous() || getDepth())
1152 lyxerr << "ERROR (Paragraph::DepthHook): "
1161 Paragraph const * Paragraph::depthHook(depth_type depth) const
1163 Paragraph const * newpar = this;
1166 newpar = newpar->previous();
1167 } while (newpar && newpar->getDepth() > depth);
1170 if (previous() || getDepth())
1171 lyxerr << "ERROR (Paragraph::DepthHook): "
1179 Paragraph * Paragraph::outerHook()
1183 return depthHook(depth_type(getDepth() - 1));
1186 Paragraph const * Paragraph::outerHook() const
1190 return depthHook(depth_type(getDepth() - 1));
1194 Paragraph::inset_iterator
1195 Paragraph::InsetIterator(pos_type pos)
1197 InsetTable search_inset(pos, 0);
1198 InsetList::iterator it = lower_bound(insetlist.begin(),
1200 search_inset, Pimpl::matchIT());
1201 return inset_iterator(it);
1205 // returns -1 if inset not found
1206 int Paragraph::getPositionOfInset(Inset const * inset) const
1209 for (InsetList::const_iterator cit = insetlist.begin();
1210 cit != insetlist.end(); ++cit) {
1211 if (cit->inset == inset) {
1215 if (inset == bibkey)
1222 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1223 BufferParams const & bparams,
1224 ostream & os, TexRow & texrow,
1227 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1228 Inset const * in = inInset();
1229 bool further_blank_line = false;
1232 // well we have to check if we are in an inset with unlimited
1233 // lenght (all in one row) if that is true then we don't allow
1234 // any special options in the paragraph and also we don't allow
1235 // any environment other then "Standard" to be valid!
1236 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1237 style = textclasslist[bparams.textclass][layout()];
1239 if (params().startOfAppendix()) {
1240 os << "\\appendix\n";
1244 if (!params().spacing().isDefault()
1245 && (!previous() || !previous()->hasSameLayout(this))) {
1246 os << params().spacing().writeEnvirBegin() << "\n";
1250 if (tex_code_break_column && style.isCommand()) {
1255 if (params().pagebreakTop()) {
1257 further_blank_line = true;
1259 if (params().spaceTop().kind() != VSpace::NONE) {
1260 os << params().spaceTop().asLatexCommand(bparams);
1261 further_blank_line = true;
1264 if (params().lineTop()) {
1265 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1266 << "\\vspace{-1\\parskip}";
1267 further_blank_line = true;
1270 if (further_blank_line) {
1275 style = textclasslist[bparams.textclass].defaultLayout();
1278 Language const * language = getParLanguage(bparams);
1279 Language const * doc_language = bparams.language;
1280 Language const * previous_language = previous()
1281 ? previous()->getParLanguage(bparams) : doc_language;
1283 if (language->babel() != previous_language->babel()
1284 // check if we already put language command in TeXEnvironment()
1285 && !(style.isEnvironment()
1286 && (!previous() || previous()->layout() != layout() ||
1287 previous()->params().depth() != params().depth())))
1289 if (!lyxrc.language_command_end.empty() &&
1290 previous_language->babel() != doc_language->babel())
1292 os << subst(lyxrc.language_command_end, "$$lang",
1293 previous_language->babel())
1298 if (lyxrc.language_command_end.empty() ||
1299 language->babel() != doc_language->babel())
1301 os << subst(lyxrc.language_command_begin, "$$lang",
1308 if (bparams.inputenc == "auto" &&
1309 language->encoding() != previous_language->encoding()) {
1310 os << "\\inputencoding{"
1311 << language->encoding()->LatexName()
1316 switch (style.latextype) {
1319 << style.latexname()
1320 << style.latexparam();
1322 case LATEX_ITEM_ENVIRONMENT:
1324 bibkey->latex(buf, os, false, false);
1328 case LATEX_LIST_ENVIRONMENT:
1335 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1337 // Make sure that \\par is done with the font of the last
1338 // character if this has another size as the default.
1339 // This is necessary because LaTeX (and LyX on the screen)
1340 // calculates the space between the baselines according
1341 // to this font. (Matthias)
1343 // Is this really needed ? (Dekel)
1344 // We do not need to use to change the font for the last paragraph
1345 // or for a command.
1346 LyXFont const font =
1348 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1350 bool is_command = style.isCommand();
1352 if (style.resfont.size() != font.size() && next_ && !is_command) {
1355 os << "\\" << font.latexSize() << " \\par}";
1356 } else if (need_par) {
1358 } else if (is_command)
1361 switch (style.latextype) {
1362 case LATEX_ITEM_ENVIRONMENT:
1363 case LATEX_LIST_ENVIRONMENT:
1364 if (next_ && (params().depth() < next_->params().depth())) {
1369 case LATEX_ENVIRONMENT:
1370 // if its the last paragraph of the current environment
1371 // skip it otherwise fall through
1373 && (next_->layout() != layout()
1374 || next_->params().depth() != params().depth()))
1376 // fall through possible
1378 // we don't need it for the last paragraph!!!
1385 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1386 further_blank_line = false;
1387 if (params().lineBottom()) {
1388 os << "\\lyxline{\\" << font.latexSize() << '}';
1389 further_blank_line = true;
1392 if (params().spaceBottom().kind() != VSpace::NONE) {
1393 os << params().spaceBottom().asLatexCommand(bparams);
1394 further_blank_line = true;
1397 if (params().pagebreakBottom()) {
1399 further_blank_line = true;
1402 if (further_blank_line) {
1407 if (!params().spacing().isDefault()
1408 && (!next_ || !next_->hasSameLayout(this))) {
1409 os << params().spacing().writeEnvirEnd() << "\n";
1414 // we don't need it for the last paragraph!!!
1419 // Since \selectlanguage write the language to the aux file,
1420 // we need to reset the language at the end of footnote or
1423 if (language->babel() != doc_language->babel()) {
1424 if (lyxrc.language_command_end.empty())
1425 os << subst(lyxrc.language_command_begin,
1427 doc_language->babel())
1430 os << subst(lyxrc.language_command_end,
1438 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1442 // This could go to ParagraphParameters if we want to
1443 int Paragraph::startTeXParParams(BufferParams const & bparams,
1448 if (params().noindent()) {
1449 os << "\\noindent ";
1453 switch (params().align()) {
1454 case LYX_ALIGN_NONE:
1455 case LYX_ALIGN_BLOCK:
1456 case LYX_ALIGN_LAYOUT:
1457 case LYX_ALIGN_SPECIAL:
1459 case LYX_ALIGN_LEFT:
1460 if (getParLanguage(bparams)->babel() != "hebrew") {
1461 os << "\\begin{flushleft}";
1464 os << "\\begin{flushright}";
1468 case LYX_ALIGN_RIGHT:
1469 if (getParLanguage(bparams)->babel() != "hebrew") {
1470 os << "\\begin{flushright}";
1473 os << "\\begin{flushleft}";
1477 case LYX_ALIGN_CENTER:
1478 os << "\\begin{center}";
1486 // This could go to ParagraphParameters if we want to
1487 int Paragraph::endTeXParParams(BufferParams const & bparams,
1492 switch (params().align()) {
1493 case LYX_ALIGN_NONE:
1494 case LYX_ALIGN_BLOCK:
1495 case LYX_ALIGN_LAYOUT:
1496 case LYX_ALIGN_SPECIAL:
1498 case LYX_ALIGN_LEFT:
1499 if (getParLanguage(bparams)->babel() != "hebrew") {
1500 os << "\\end{flushleft}";
1503 os << "\\end{flushright}";
1507 case LYX_ALIGN_RIGHT:
1508 if (getParLanguage(bparams)->babel() != "hebrew") {
1509 os << "\\end{flushright}";
1512 os << "\\end{flushleft}";
1516 case LYX_ALIGN_CENTER:
1517 os << "\\end{center}";
1525 // This one spits out the text of the paragraph
1526 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1527 BufferParams const & bparams,
1528 ostream & os, TexRow & texrow,
1531 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1533 bool return_value = false;
1537 // well we have to check if we are in an inset with unlimited
1538 // lenght (all in one row) if that is true then we don't allow
1539 // any special options in the paragraph and also we don't allow
1540 // any environment other then "Standard" to be valid!
1542 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1545 style = textclasslist[bparams.textclass].defaultLayout();
1547 style = textclasslist[bparams.textclass][layout()];
1552 // Maybe we have to create a optional argument.
1554 if (style.labeltype != LABEL_MANUAL)
1557 main_body = beginningOfMainBody();
1561 if (main_body > 0) {
1564 basefont = getLabelFont(bparams);
1566 basefont = getLayoutFont(bparams);
1569 moving_arg |= style.needprotect;
1571 // Which font is currently active?
1572 LyXFont running_font(basefont);
1573 // Do we have an open font change?
1574 bool open_font = false;
1576 texrow.start(this, 0);
1578 // if the paragraph is empty, the loop will not be entered at all
1580 if (style.isCommand()) {
1585 column += startTeXParParams(bparams, os);
1589 for (pos_type i = 0; i < size(); ++i) {
1591 // First char in paragraph or after label?
1592 if (i == main_body) {
1593 if (main_body > 0) {
1595 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1598 basefont = getLayoutFont(bparams);
1599 running_font = basefont;
1603 if (style.isCommand()) {
1609 column += startTeXParParams(bparams, os);
1612 value_type c = getChar(i);
1614 // Fully instantiated font
1615 LyXFont font = getFont(bparams, i);
1617 LyXFont const & last_font = running_font;
1619 // Spaces at end of font change are simulated to be
1620 // outside font change, i.e. we write "\textXX{text} "
1621 // rather than "\textXX{text }". (Asger)
1622 if (open_font && c == ' ' && i <= size() - 2) {
1623 LyXFont const & next_font = getFont(bparams, i + 1);
1624 if (next_font != running_font
1625 && next_font != font) {
1630 // We end font definition before blanks
1631 if (font != running_font && open_font) {
1632 column += running_font.latexWriteEndChanges(os,
1634 (i == main_body-1) ? basefont : font);
1635 running_font = basefont;
1639 // Blanks are printed before start of fontswitch
1641 // Do not print the separation of the optional argument
1642 if (i != main_body - 1) {
1643 pimpl_->simpleTeXBlanks(os, texrow, i,
1644 column, font, style);
1648 // Do we need to change font?
1649 if (font != running_font && i != main_body - 1) {
1650 column += font.latexWriteStartChanges(os, basefont,
1652 running_font = font;
1656 if (c == Paragraph::META_NEWLINE) {
1657 // newlines are handled differently here than
1658 // the default in SimpleTeXSpecialChars().
1659 if (!style.newline_allowed) {
1663 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1666 basefont = getLayoutFont(bparams);
1667 running_font = basefont;
1668 if (font.family() ==
1669 LyXFont::TYPEWRITER_FAMILY) {
1677 texrow.start(this, i + 1);
1680 pimpl_->simpleTeXSpecialChars(buf, bparams,
1681 os, texrow, moving_arg,
1683 basefont, open_font,
1684 style, i, column, c);
1688 // If we have an open font definition, we have to close it
1690 #ifdef FIXED_LANGUAGE_END_DETECTION
1693 .latexWriteEndChanges(os, basefont,
1694 next_->getFont(bparams,
1697 running_font.latexWriteEndChanges(os, basefont,
1701 #ifdef WITH_WARNINGS
1702 //#warning For now we ALWAYS have to close the foreign font settings if they are
1703 //#warning there as we start another \selectlanguage with the next paragraph if
1704 //#warning we are in need of this. This should be fixed sometime (Jug)
1706 running_font.latexWriteEndChanges(os, basefont, basefont);
1710 // Needed if there is an optional argument but no contents.
1711 if (main_body > 0 && main_body == size()) {
1713 return_value = false;
1717 column += endTeXParParams(bparams, os);
1720 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1721 return return_value;
1725 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1727 bool retval = false;
1729 case Paragraph::META_HFILL:
1730 sgml_string.erase();
1732 case Paragraph::META_NEWLINE:
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 = "{";
1763 sgml_string = "}";
1766 sgml_string = "˜";
1769 sgml_string = """;
1772 sgml_string = "\";
1778 case '\0': // Ignore :-)
1779 sgml_string.erase();
1789 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1790 BufferParams const & bparams,
1791 ostream & os, TexRow & texrow)
1793 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1795 LyXLayout const & style =
1796 textclasslist[bparams.textclass][layout()];
1798 Language const * language = getParLanguage(bparams);
1799 Language const * doc_language = bparams.language;
1800 Language const * previous_language = previous_
1801 ? previous_->getParLanguage(bparams) : doc_language;
1802 if (language->babel() != previous_language->babel()) {
1804 if (!lyxrc.language_command_end.empty() &&
1805 previous_language->babel() != doc_language->babel()) {
1806 os << subst(lyxrc.language_command_end, "$$lang",
1807 previous_language->babel())
1812 if (lyxrc.language_command_end.empty() ||
1813 language->babel() != doc_language->babel()) {
1814 os << subst(lyxrc.language_command_begin, "$$lang",
1821 if (style.isEnvironment()) {
1822 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1823 os << "\\begin{" << style.latexname() << "}{"
1824 << params().labelWidthString() << "}\n";
1825 } else if (style.labeltype == LABEL_BIBLIO) {
1827 os << "\\begin{" << style.latexname() << "}{"
1828 << bibitemWidest(buf)
1830 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1831 os << "\\begin{" << style.latexname() << '}'
1832 << style.latexparam() << '\n';
1834 os << "\\begin{" << style.latexname() << '}'
1835 << style.latexparam() << '\n';
1838 Paragraph * par = this;
1840 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1842 if (par && par->params().depth() > params().depth()) {
1843 if (textclasslist[bparams.textclass][par->layout()].isParagraph()
1845 // How to handle this? (Lgb)
1846 //&& !suffixIs(os, "\n\n")
1848 // There should be at least one '\n' already
1849 // but we need there to be two for Standard
1850 // paragraphs that are depth-increment'ed to be
1851 // output correctly. However, tables can
1852 // also be paragraphs so don't adjust them.
1855 // Will it ever harm to have one '\n' too
1856 // many? i.e. that we sometimes will have
1857 // three in a row. (Lgb)
1861 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1864 && par->layout() == layout()
1865 && par->params().depth() == params().depth());
1867 if (style.isEnvironment()) {
1868 os << "\\end{" << style.latexname() << "}\n";
1872 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1873 return par; // ale970302
1877 bool Paragraph::isHfill(pos_type pos) const
1879 return IsHfillChar(getChar(pos));
1883 bool Paragraph::isInset(pos_type pos) const
1885 return IsInsetChar(getChar(pos));
1889 bool Paragraph::isNewline(pos_type pos) const
1891 return pos >= 0 && IsNewlineChar(getChar(pos));
1895 bool Paragraph::isSeparator(pos_type pos) const
1897 return IsSeparatorChar(getChar(pos));
1901 bool Paragraph::isLineSeparator(pos_type pos) const
1903 value_type const c = getChar(pos);
1904 return IsLineSeparatorChar(c)
1905 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1909 bool Paragraph::isKomma(pos_type pos) const
1911 return IsKommaChar(getChar(pos));
1915 /// Used by the spellchecker
1916 bool Paragraph::isLetter(pos_type pos) const
1918 value_type const c = getChar(pos);
1919 if (IsLetterChar(c))
1922 return getInset(pos)->isLetter();
1923 // We want to pass the ' and escape chars to ispell
1924 string const extra = lyxrc.isp_esc_chars + '\'';
1925 return contains(extra, c);
1929 bool Paragraph::isWord(pos_type pos) const
1931 return IsWordChar(getChar(pos)) ;
1936 Paragraph::getParLanguage(BufferParams const & bparams) const
1939 #ifndef INHERIT_LANGUAGE
1940 return getFirstFontSettings().language();
1942 Language const * lang = getFirstFontSettings().language();
1943 #ifdef WITH_WARNINGS
1944 #warning We should make this somewhat better, any ideas? (Jug)
1946 if (lang == inherit_language || lang == ignore_language)
1947 lang = bparams.language;
1950 } else if (previous_)
1951 return previous_->getParLanguage(bparams);
1953 return bparams.language;
1957 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1959 return lyxrc.rtl_support
1960 && getParLanguage(bparams)->RightToLeft();
1964 void Paragraph::changeLanguage(BufferParams const & bparams,
1965 Language const * from, Language const * to)
1967 for (pos_type i = 0; i < size(); ++i) {
1968 LyXFont font = getFontSettings(bparams, i);
1969 if (font.language() == from) {
1970 font.setLanguage(to);
1977 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1979 Language const * doc_language = bparams.language;
1980 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1981 cit != pimpl_->fontlist.end(); ++cit)
1982 if (cit->font().language() != ignore_language &&
1983 cit->font().language() != latex_language &&
1984 #ifdef INHERIT_LANGUAGE
1985 cit->font().language() != inherit_language &&
1987 cit->font().language() != doc_language)
1993 // Convert the paragraph to a string.
1994 // Used for building the table of contents
1995 string const Paragraph::asString(Buffer const * buffer, bool label)
1997 BufferParams const & bparams = buffer->params;
1999 if (label && !params().labelString().empty())
2000 s += params().labelString() + ' ';
2001 string::size_type const len = s.size();
2003 for (pos_type i = 0; i < size(); ++i) {
2004 value_type c = getChar(i);
2007 else if (c == META_INSET &&
2008 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2010 getInset(i)->ascii(buffer, ost);
2011 s += subst(ost.str().c_str(),'\n',' ');
2015 if (isRightToLeftPar(bparams))
2016 reverse(s.begin() + len,s.end());
2022 string const Paragraph::asString(Buffer const * buffer,
2023 pos_type beg, pos_type end, bool label)
2027 if (beg == 0 && label && !params().labelString().empty())
2028 ost << params().labelString() << ' ';
2030 for (pos_type i = beg; i < end; ++i) {
2031 value_type const c = getUChar(buffer->params, i);
2034 else if (c == META_NEWLINE)
2036 else if (c == META_HFILL)
2038 else if (c == META_INSET) {
2039 getInset(i)->ascii(buffer, ost);
2043 return ost.str().c_str();
2047 void Paragraph::setInsetOwner(Inset * i)
2049 pimpl_->inset_owner = i;
2050 for (InsetList::const_iterator cit = insetlist.begin();
2051 cit != insetlist.end(); ++cit) {
2053 cit->inset->setOwner(i);
2058 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2061 for (InsetList::const_iterator cit = insetlist.begin();
2062 cit != insetlist.end(); ++cit) {
2064 if (cit->inset->isTextInset()) {
2065 static_cast<UpdatableInset *>
2066 (cit->inset)->deleteLyXText(bv, true);
2073 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2076 for (InsetList::const_iterator cit = insetlist.begin();
2077 cit != insetlist.end(); ++cit)
2080 if (cit->inset->isTextInset()) {
2081 static_cast<UpdatableInset *>
2082 (cit->inset)->resizeLyXText(bv, true);
2089 void Paragraph::setContentsFromPar(Paragraph * par)
2091 pimpl_->setContentsFromPar(par);
2095 lyx::pos_type Paragraph::size() const
2097 return pimpl_->size();
2101 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2103 return pimpl_->getChar(pos);
2107 int Paragraph::id() const
2113 void Paragraph::id(int id_arg)
2115 pimpl_->id_ = id_arg;
2119 string const & Paragraph::layout() const
2125 void Paragraph::layout(string const & new_layout)
2127 layout_ = new_layout;
2131 bool Paragraph::isFirstInSequence() const
2133 Paragraph const * dhook = depthHook(getDepth());
2134 return (dhook == this
2135 || dhook->layout() != layout()
2136 || dhook->getDepth() != getDepth());
2140 Inset * Paragraph::inInset() const
2142 return pimpl_->inset_owner;
2146 void Paragraph::clearContents()
2152 void Paragraph::setCounter(int i, int v)
2154 pimpl_->counter_[i] = v;
2158 int Paragraph::getCounter(int i) const
2160 return pimpl_->counter_[i];
2164 void Paragraph::incCounter(int i)
2166 pimpl_->counter_[i]++;
2170 void Paragraph::setChar(pos_type pos, value_type c)
2172 pimpl_->setChar(pos, c);
2176 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2181 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2183 return inset_iterator(insetlist.begin());
2187 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2189 return inset_iterator(insetlist.end());
2193 ParagraphParameters & Paragraph::params()
2195 return pimpl_->params;
2199 ParagraphParameters const & Paragraph::params() const
2201 return pimpl_->params;
2205 Paragraph * Paragraph::getParFromID(int id) const
2207 return pimpl_->getParFromID(id);
2211 bool Paragraph::isFreeSpacing() const
2213 // for now we just need this, later should we need this in some
2214 // other way we can always add a function to Inset::() too.
2215 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2216 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);