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
92 // This constructor inserts the new paragraph in a list.
93 Paragraph::Paragraph(Paragraph * par)
94 : pimpl_(new Paragraph::Pimpl(this))
96 for (int i = 0; i < 10; ++i)
101 // double linked list begin
104 next_->previous_ = this;
106 previous_->next_ = this;
109 bibkey = 0; // ale970302
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 string lay = layout();
192 lay = textclasslist[bparams.textclass].defaultLayoutName();
195 os << "\n\\layout " << layout() << "\n";
197 // Maybe some vertical spaces.
198 if (params().spaceTop().kind() != VSpace::NONE)
199 os << "\\added_space_top "
200 << params().spaceTop().asLyXCommand() << " ";
201 if (params().spaceBottom().kind() != VSpace::NONE)
202 os << "\\added_space_bottom "
203 << params().spaceBottom().asLyXCommand() << " ";
205 // Maybe the paragraph has special spacing
206 params().spacing().writeFile(os, true);
208 // The labelwidth string used in lists.
209 if (!params().labelWidthString().empty())
210 os << "\\labelwidthstring "
211 << params().labelWidthString() << '\n';
213 // Lines above or below?
214 if (params().lineTop())
216 if (params().lineBottom())
217 os << "\\line_bottom ";
219 // Pagebreaks above or below?
220 if (params().pagebreakTop())
221 os << "\\pagebreak_top ";
222 if (params().pagebreakBottom())
223 os << "\\pagebreak_bottom ";
225 // Start of appendix?
226 if (params().startOfAppendix())
227 os << "\\start_of_appendix ";
230 if (params().noindent())
234 if (params().align() != LYX_ALIGN_LAYOUT) {
236 switch (params().align()) {
237 case LYX_ALIGN_LEFT: h = 1; break;
238 case LYX_ALIGN_RIGHT: h = 2; break;
239 case LYX_ALIGN_CENTER: h = 3; break;
240 default: h = 0; break;
242 os << "\\align " << string_align[h] << " ";
247 bibkey->write(buf, os);
249 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
252 for (pos_type i = 0; i < size(); ++i) {
258 // Write font changes
259 LyXFont font2 = getFontSettings(bparams, i);
260 if (font2 != font1) {
261 #ifndef INHERIT_LANGUAGE
262 font2.lyxWriteChanges(font1, os);
264 font2.lyxWriteChanges(font1, bparams.language, os);
270 value_type const c = getChar(i);
274 Inset const * inset = getInset(i);
276 if (inset->directWrite()) {
277 // international char, let it write
278 // code directly so it's shorter in
280 inset->write(buf, os);
282 os << "\n\\begin_inset ";
283 inset->write(buf, os);
284 os << "\n\\end_inset \n\n";
290 os << "\n\\newline \n";
294 os << "\n\\hfill \n";
298 os << "\n\\backslash \n";
302 if (i + 1 < size() && getChar(i + 1) == ' ') {
309 if ((column > 70 && c == ' ')
314 // this check is to amend a bug. LyX sometimes
315 // inserts '\0' this could cause problems.
319 lyxerr << "ERROR (Paragraph::writeFile):"
320 " NULL char in structure." << endl;
326 // now write the next paragraph
328 next_->writeFile(buf, os, bparams, dth);
332 void Paragraph::validate(LaTeXFeatures & features) const
334 BufferParams const & bparams = features.bufferParams();
337 if (params().lineTop() || params().lineBottom())
338 features.require("lyxline");
339 if (!params().spacing().isDefault())
340 features.require("setspace");
343 features.useLayout(layout());
346 Language const * doc_language = bparams.language;
348 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
349 cit != pimpl_->fontlist.end(); ++cit) {
350 if (cit->font().noun() == LyXFont::ON) {
351 lyxerr[Debug::LATEX] << "font.noun: "
352 << cit->font().noun()
354 features.require("noun");
355 lyxerr[Debug::LATEX] << "Noun enabled. Font: "
356 << cit->font().stateText(0)
359 switch (cit->font().color()) {
361 case LColor::inherit:
363 // probably we should put here all interface colors used for
364 // font displaying! For now I just add this ones I know of (Jug)
369 features.require("color");
370 lyxerr[Debug::LATEX] << "Color enabled. Font: "
371 << cit->font().stateText(0)
375 Language const * language = cit->font().language();
376 if (language->babel() != doc_language->babel() &&
377 language != ignore_language &&
378 #ifdef INHERIT_LANGUAGE
379 language != inherit_language &&
381 language != latex_language)
383 features.useLanguage(language);
384 lyxerr[Debug::LATEX] << "Found language "
385 << language->babel() << endl;
390 LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
392 for (InsetList::const_iterator cit = insetlist.begin();
393 cit != insetlist.end(); ++cit) {
395 cit->inset->validate(features);
396 if (lout.needprotect &&
397 cit->inset->lyxCode() == Inset::FOOT_CODE)
398 features.require("NeedLyXFootnoteCode");
404 // First few functions needed for cut and paste and paragraph breaking.
405 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
407 BufferParams bparams = buffer.params;
409 minibuffer_char = getChar(pos);
410 minibuffer_font = getFontSettings(bparams, pos);
411 minibuffer_inset = 0;
412 if (minibuffer_char == Paragraph::META_INSET) {
414 minibuffer_inset = getInset(pos)->clone(buffer);
416 minibuffer_inset = 0;
417 minibuffer_char = ' ';
418 // This reflects what GetInset() does (ARRae)
424 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
426 minibuffer_char = getChar(pos);
427 minibuffer_font = getFontSettings(bparams, pos);
428 minibuffer_inset = 0;
429 if (minibuffer_char == Paragraph::META_INSET) {
431 minibuffer_inset = getInset(pos);
432 // This is a little hack since I want exactly
433 // the inset, not just a clone. Otherwise
434 // the inset would be deleted when calling Erase(pos)
436 InsetTable search_elem(pos, 0);
437 InsetList::iterator it =
438 lower_bound(insetlist.begin(),
440 search_elem, Pimpl::matchIT());
441 if (it != insetlist.end() && it->pos == pos)
443 // the inset is not in a paragraph anymore
444 minibuffer_inset->parOwner(0);
446 minibuffer_inset = 0;
447 minibuffer_char = ' ';
448 // This reflects what GetInset() does (ARRae)
453 // Erase(pos); now the caller is responsible for that.
457 bool Paragraph::insertFromMinibuffer(pos_type pos)
459 if (minibuffer_char == Paragraph::META_INSET) {
460 if (!insetAllowed(minibuffer_inset->lyxCode())) {
463 insertInset(pos, minibuffer_inset, minibuffer_font);
465 LyXFont f = minibuffer_font;
466 if (!checkInsertChar(f)) {
469 insertChar(pos, minibuffer_char, f);
477 void Paragraph::erase(pos_type pos)
483 bool Paragraph::checkInsertChar(LyXFont & font)
485 if (pimpl_->inset_owner)
486 return pimpl_->inset_owner->checkInsertChar(font);
491 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
493 LyXFont const f(LyXFont::ALL_INHERIT);
494 insertChar(pos, c, f);
498 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
499 LyXFont const & font)
501 pimpl_->insertChar(pos, c, font);
505 void Paragraph::insertInset(pos_type pos, Inset * inset)
507 LyXFont const f(LyXFont::ALL_INHERIT);
508 insertInset(pos, inset, f);
512 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
514 pimpl_->insertInset(pos, inset, font);
518 bool Paragraph::insetAllowed(Inset::Code code)
520 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
522 if (pimpl_->inset_owner)
523 return pimpl_->inset_owner->insetAllowed(code);
528 Inset * Paragraph::getInset(pos_type pos)
530 lyx::Assert(pos < size());
533 InsetTable search_inset(pos, 0);
534 InsetList::iterator it = lower_bound(insetlist.begin(),
536 search_inset, Pimpl::matchIT());
537 if (it != insetlist.end() && it->pos == pos)
540 lyxerr << "ERROR (Paragraph::getInset): "
541 "Inset does not exist: " << pos << endl;
544 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
545 // Did this commenting out introduce a bug? So far I have not
546 // see any, please enlighten me. (Lgb)
547 // My guess is that since the inset does not exist, we might
548 // as well replace it with a space to prevent craches. (Asger)
553 Inset const * Paragraph::getInset(pos_type pos) const
555 lyx::Assert(pos < size());
558 InsetTable search_inset(pos, 0);
559 InsetList::const_iterator cit = lower_bound(insetlist.begin(),
561 search_inset, Pimpl::matchIT());
562 if (cit != insetlist.end() && cit->pos == pos)
565 lyxerr << "ERROR (Paragraph::GetInset): "
566 "Inset does not exist: " << pos << endl;
568 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
569 // Did this commenting out introduce a bug? So far I have not
570 // see any, please enlighten me. (Lgb)
571 // My guess is that since the inset does not exist, we might
572 // as well replace it with a space to prevent craches. (Asger)
577 // Gets uninstantiated font setting at position.
578 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
581 lyx::Assert(pos <= size());
583 Pimpl::FontTable search_font(pos, LyXFont());
584 Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
585 pimpl_->fontlist.end(),
586 search_font, Pimpl::matchFT());
588 if (cit != pimpl_->fontlist.end()) {
589 retfont = cit->font();
590 } else if (pos == size() && size()) {
591 retfont = getFontSettings(bparams, pos - 1);
593 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
594 #ifdef INHERIT_LANGUAGE
595 if (retfont.language() == inherit_language)
596 retfont.setLanguage(bparams.language);
603 // Gets uninstantiated font setting at position 0
604 LyXFont const Paragraph::getFirstFontSettings() const
606 if (size() > 0 && !pimpl_->fontlist.empty())
607 return pimpl_->fontlist[0].font();
609 return LyXFont(LyXFont::ALL_INHERIT);
613 // Gets the fully instantiated font at a given position in a paragraph
614 // This is basically the same function as LyXText::GetFont() in text2.C.
615 // The difference is that this one is used for generating the LaTeX file,
616 // and thus cosmetic "improvements" are disallowed: This has to deliver
617 // the true picture of the buffer. (Asger)
618 // If position is -1, we get the layout font of the paragraph.
619 // If position is -2, we get the font of the manual label of the paragraph.
620 LyXFont const Paragraph::getFont(BufferParams const & bparams,
623 lyx::Assert(pos >= 0);
625 LyXLayout const & lout =
626 textclasslist[bparams.textclass][layout()];
627 pos_type main_body = 0;
628 if (lout.labeltype == LABEL_MANUAL)
629 main_body = beginningOfMainBody();
633 layoutfont = lout.labelfont;
635 layoutfont = lout.font;
637 LyXFont tmpfont = getFontSettings(bparams, pos);
638 #ifndef INHERIT_LANGUAGE
639 tmpfont.realize(layoutfont);
641 tmpfont.realize(layoutfont, bparams.language);
644 return pimpl_->realizeFont(tmpfont, bparams);
648 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
650 LyXLayout const & lout =
651 textclasslist[bparams.textclass][layout()];
653 LyXFont tmpfont = lout.labelfont;
654 tmpfont.setLanguage(getParLanguage(bparams));
656 return pimpl_->realizeFont(tmpfont, bparams);
660 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
662 LyXLayout const & lout =
663 textclasslist[bparams.textclass][layout()];
665 LyXFont tmpfont = lout.font;
666 tmpfont.setLanguage(getParLanguage(bparams));
668 return pimpl_->realizeFont(tmpfont, bparams);
672 /// Returns the height of the highest font in range
674 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
675 LyXFont::FONT_SIZE const def_size) const
677 if (pimpl_->fontlist.empty())
680 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
681 Pimpl::FontTable end_search(endpos, LyXFont());
682 Pimpl::FontList::const_iterator end_it =
683 lower_bound(pimpl_->fontlist.begin(),
684 pimpl_->fontlist.end(),
685 end_search, Pimpl::matchFT());
686 if (end_it != pimpl_->fontlist.end())
689 Pimpl::FontTable start_search(startpos, LyXFont());
690 Pimpl::FontList::const_iterator cit =
691 lower_bound(pimpl_->fontlist.begin(),
692 pimpl_->fontlist.end(),
693 start_search, Pimpl::matchFT());
695 for (; cit != end_it; ++cit) {
696 LyXFont::FONT_SIZE size = cit->font().size();
697 if (size == LyXFont::INHERIT_SIZE)
699 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
706 Paragraph::value_type
707 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
709 value_type c = getChar(pos);
710 if (!lyxrc.rtl_support)
740 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
747 void Paragraph::setFont(pos_type pos, LyXFont const & font)
749 lyx::Assert(pos <= size());
751 // First, reduce font against layout/label font
752 // Update: The SetCharFont() routine in text2.C already
753 // reduces font, so we don't need to do that here. (Asger)
754 // No need to simplify this because it will disappear
755 // in a new kernel. (Asger)
756 // Next search font table
758 Pimpl::FontTable search_font(pos, LyXFont());
759 Pimpl::FontList::iterator it = lower_bound(pimpl_->fontlist.begin(),
760 pimpl_->fontlist.end(),
761 search_font, Pimpl::matchFT());
762 unsigned int i = it - pimpl_->fontlist.begin();
763 bool notfound = it == pimpl_->fontlist.end();
765 if (!notfound && pimpl_->fontlist[i].font() == font)
768 bool begin = pos == 0 || notfound ||
769 (i > 0 && pimpl_->fontlist[i-1].pos() == pos - 1);
770 // Is position pos is a beginning of a font block?
771 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
772 // Is position pos is the end of a font block?
773 if (begin && end) { // A single char block
774 if (i + 1 < pimpl_->fontlist.size() &&
775 pimpl_->fontlist[i + 1].font() == font) {
776 // Merge the singleton block with the next block
777 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
778 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
779 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
780 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
781 // Merge the singleton block with the previous block
782 pimpl_->fontlist[i - 1].pos(pos);
783 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
785 pimpl_->fontlist[i].font(font);
787 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
788 pimpl_->fontlist[i - 1].pos(pos);
790 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
791 Pimpl::FontTable(pos, font));
793 pimpl_->fontlist[i].pos(pos - 1);
794 if (!(i + 1 < pimpl_->fontlist.size() &&
795 pimpl_->fontlist[i + 1].font() == font))
796 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
797 Pimpl::FontTable(pos, font));
798 } else { // The general case. The block is splitted into 3 blocks
799 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
800 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
801 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
802 Pimpl::FontTable(pos, font));
808 void Paragraph::next(Paragraph * p)
814 // This function is able to hide closed footnotes.
815 Paragraph * Paragraph::next()
821 Paragraph const * Paragraph::next() const
827 void Paragraph::previous(Paragraph * p)
833 // This function is able to hide closed footnotes.
834 Paragraph * Paragraph::previous()
840 // This function is able to hide closed footnotes.
841 Paragraph const * Paragraph::previous() const
847 void Paragraph::breakParagraph(BufferParams const & bparams,
851 // create a new paragraph
852 Paragraph * tmp = new Paragraph(this);
853 tmp->layout(textclasslist[bparams.textclass].defaultLayoutName());
855 // remember to set the inset_owner
856 tmp->setInsetOwner(inInset());
858 // this is an idea for a more userfriendly layout handling, I will
859 // see what the users say
861 // layout stays the same with latex-environments
863 tmp->layout(layout());
864 tmp->setLabelWidthString(params().labelWidthString());
867 if (size() > pos || !size() || flag == 2) {
868 tmp->layout(layout());
869 tmp->params().align(params().align());
870 tmp->setLabelWidthString(params().labelWidthString());
872 tmp->params().lineBottom(params().lineBottom());
873 params().lineBottom(false);
874 tmp->params().pagebreakBottom(params().pagebreakBottom());
875 params().pagebreakBottom(false);
876 tmp->params().spaceBottom(params().spaceBottom());
877 params().spaceBottom(VSpace(VSpace::NONE));
879 tmp->params().depth(params().depth());
880 tmp->params().noindent(params().noindent());
882 // copy everything behind the break-position
883 // to the new paragraph
884 pos_type pos_end = size() - 1;
887 for (; i <= pos_end; ++i) {
888 cutIntoMinibuffer(bparams, i);
889 if (tmp->insertFromMinibuffer(j - pos))
892 for (i = pos_end; i >= pos; --i) {
897 // just an idea of me
899 tmp->params().lineTop(params().lineTop());
900 tmp->params().pagebreakTop(params().pagebreakTop());
901 tmp->params().spaceTop(params().spaceTop());
902 tmp->bibkey = bibkey;
906 layout(textclasslist[bparams.textclass].defaultLayoutName());
908 // layout stays the same with latex-environments
910 layout(tmp->layout());
911 setLabelWidthString(tmp->params().labelWidthString());
912 params().depth(tmp->params().depth());
918 void Paragraph::makeSameLayout(Paragraph const * par)
920 layout(par->layout());
922 params() = par->params();
926 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
928 if (textclasslist[tclass][layout()].free_spacing ||
934 while (size() && (isNewline(0) || isLineSeparator(0))) {
943 bool Paragraph::hasSameLayout(Paragraph const * par) const
946 par->layout() == layout() &&
947 params().sameLayout(par->params());
951 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
954 // create a new paragraph
955 Paragraph * tmp = new Paragraph(this);
956 tmp->makeSameLayout(this);
958 // When can pos > Last()?
959 // I guess pos == Last() is possible.
961 // copy everything behind the break-position to the new
963 pos_type pos_end = size() - 1;
967 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
968 cutIntoMinibuffer(bparams, i);
969 if (tmp->insertFromMinibuffer(j - pos))
973 for (pos_type k = pos_end; k >= pos; --k) {
980 // Be carefull, this does not make any check at all.
981 // This method has wrong name, it combined this par with the next par.
982 // In that sense it is the reverse of break paragraph. (Lgb)
983 void Paragraph::pasteParagraph(BufferParams const & bparams)
985 // copy the next paragraph to this one
986 Paragraph * the_next = next();
988 // first the DTP-stuff
989 params().lineBottom(the_next->params().lineBottom());
990 params().spaceBottom(the_next->params().spaceBottom());
991 params().pagebreakBottom(the_next->params().pagebreakBottom());
993 pos_type pos_end = the_next->pimpl_->size() - 1;
994 pos_type pos_insert = size();
996 // ok, now copy the paragraph
997 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
998 the_next->cutIntoMinibuffer(bparams, i);
999 if (insertFromMinibuffer(pos_insert + j))
1003 // delete the next paragraph
1004 Paragraph * ppar = the_next->previous_;
1005 Paragraph * npar = the_next->next_;
1011 int Paragraph::getEndLabel(BufferParams const & bparams) const
1013 Paragraph const * par = this;
1014 depth_type par_depth = getDepth();
1016 string const & layout = par->layout();
1017 int const endlabeltype =
1018 textclasslist[bparams.textclass][layout].endlabeltype;
1019 if (endlabeltype != END_LABEL_NO_LABEL) {
1021 return endlabeltype;
1023 depth_type const next_depth = next_->getDepth();
1024 if (par_depth > next_depth ||
1025 (par_depth == next_depth
1026 && layout != next_->layout()))
1027 return endlabeltype;
1032 par = par->outerHook();
1034 par_depth = par->getDepth();
1036 return END_LABEL_NO_LABEL;
1040 Paragraph::depth_type Paragraph::getDepth() const
1042 return params().depth();
1046 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1048 bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
1051 return params().depth() + 1;
1053 return params().depth();
1057 char Paragraph::getAlign() const
1059 return params().align();
1063 string const & Paragraph::getLabelstring() const
1065 return params().labelString();
1069 int Paragraph::getFirstCounter(int i) const
1071 return pimpl_->counter_[i];
1075 // the next two functions are for the manual labels
1076 string const Paragraph::getLabelWidthString() const
1078 if (!params().labelWidthString().empty())
1079 return params().labelWidthString();
1081 return _("Senseless with this layout!");
1085 void Paragraph::setLabelWidthString(string const & s)
1087 params().labelWidthString(s);
1091 void Paragraph::applyLayout(string const & new_layout)
1094 params().labelWidthString(string());
1095 params().align(LYX_ALIGN_LAYOUT);
1096 params().spaceTop(VSpace(VSpace::NONE));
1097 params().spaceBottom(VSpace(VSpace::NONE));
1098 params().spacing(Spacing(Spacing::Default));
1102 // if the layout of a paragraph contains a manual label, the beginning of the
1103 // main body is the beginning of the second word. This is what the par-
1104 // function returns. If the layout does not contain a label, the main
1105 // body always starts with position 0. This differentiation is necessary,
1106 // because there cannot be a newline or a blank <= the beginning of the
1107 // main body in TeX.
1109 int Paragraph::beginningOfMainBody() const
1111 // Unroll the first two cycles of the loop
1112 // and remember the previous character to
1113 // remove unnecessary GetChar() calls
1116 && getChar(i) != Paragraph::META_NEWLINE) {
1118 char previous_char = 0;
1121 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1122 // Yes, this ^ is supposed to be "= " not "=="
1125 && previous_char != ' '
1126 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1128 previous_char = temp;
1137 Paragraph * Paragraph::depthHook(depth_type depth)
1139 Paragraph * newpar = this;
1142 newpar = newpar->previous();
1143 } while (newpar && newpar->getDepth() > depth);
1146 if (previous() || getDepth())
1147 lyxerr << "ERROR (Paragraph::DepthHook): "
1156 Paragraph const * Paragraph::depthHook(depth_type depth) const
1158 Paragraph const * newpar = this;
1161 newpar = newpar->previous();
1162 } while (newpar && newpar->getDepth() > depth);
1165 if (previous() || getDepth())
1166 lyxerr << "ERROR (Paragraph::DepthHook): "
1174 Paragraph * Paragraph::outerHook()
1178 return depthHook(depth_type(getDepth() - 1));
1181 Paragraph const * Paragraph::outerHook() const
1185 return depthHook(depth_type(getDepth() - 1));
1189 Paragraph::inset_iterator
1190 Paragraph::InsetIterator(pos_type pos)
1192 InsetTable search_inset(pos, 0);
1193 InsetList::iterator it = lower_bound(insetlist.begin(),
1195 search_inset, Pimpl::matchIT());
1196 return inset_iterator(it);
1200 // returns -1 if inset not found
1201 int Paragraph::getPositionOfInset(Inset const * inset) const
1204 for (InsetList::const_iterator cit = insetlist.begin();
1205 cit != insetlist.end(); ++cit) {
1206 if (cit->inset == inset) {
1210 if (inset == bibkey)
1217 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1218 BufferParams const & bparams,
1219 ostream & os, TexRow & texrow,
1222 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1223 Inset const * in = inInset();
1224 bool further_blank_line = false;
1227 // well we have to check if we are in an inset with unlimited
1228 // lenght (all in one row) if that is true then we don't allow
1229 // any special options in the paragraph and also we don't allow
1230 // any environment other then "Standard" to be valid!
1231 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1232 style = textclasslist[bparams.textclass][layout()];
1234 if (params().startOfAppendix()) {
1235 os << "\\appendix\n";
1239 if (!params().spacing().isDefault()
1240 && (!previous() || !previous()->hasSameLayout(this))) {
1241 os << params().spacing().writeEnvirBegin() << "\n";
1245 if (tex_code_break_column && style.isCommand()) {
1250 if (params().pagebreakTop()) {
1252 further_blank_line = true;
1254 if (params().spaceTop().kind() != VSpace::NONE) {
1255 os << params().spaceTop().asLatexCommand(bparams);
1256 further_blank_line = true;
1259 if (params().lineTop()) {
1260 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1261 << "\\vspace{-1\\parskip}";
1262 further_blank_line = true;
1265 if (further_blank_line) {
1270 style = textclasslist[bparams.textclass].defaultLayout();
1273 Language const * language = getParLanguage(bparams);
1274 Language const * doc_language = bparams.language;
1275 Language const * previous_language = previous()
1276 ? previous()->getParLanguage(bparams) : doc_language;
1278 if (language->babel() != previous_language->babel()
1279 // check if we already put language command in TeXEnvironment()
1280 && !(style.isEnvironment()
1281 && (!previous() || previous()->layout() != layout() ||
1282 previous()->params().depth() != params().depth())))
1284 if (!lyxrc.language_command_end.empty() &&
1285 previous_language->babel() != doc_language->babel())
1287 os << subst(lyxrc.language_command_end, "$$lang",
1288 previous_language->babel())
1293 if (lyxrc.language_command_end.empty() ||
1294 language->babel() != doc_language->babel())
1296 os << subst(lyxrc.language_command_begin, "$$lang",
1303 if (bparams.inputenc == "auto" &&
1304 language->encoding() != previous_language->encoding()) {
1305 os << "\\inputencoding{"
1306 << language->encoding()->LatexName()
1311 switch (style.latextype) {
1314 << style.latexname()
1315 << style.latexparam();
1317 case LATEX_ITEM_ENVIRONMENT:
1319 bibkey->latex(buf, os, false, false);
1323 case LATEX_LIST_ENVIRONMENT:
1330 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1332 // Make sure that \\par is done with the font of the last
1333 // character if this has another size as the default.
1334 // This is necessary because LaTeX (and LyX on the screen)
1335 // calculates the space between the baselines according
1336 // to this font. (Matthias)
1338 // Is this really needed ? (Dekel)
1339 // We do not need to use to change the font for the last paragraph
1340 // or for a command.
1341 LyXFont const font =
1343 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1345 bool is_command = style.isCommand();
1347 if (style.resfont.size() != font.size() && next_ && !is_command) {
1350 os << "\\" << font.latexSize() << " \\par}";
1351 } else if (need_par) {
1353 } else if (is_command)
1356 switch (style.latextype) {
1357 case LATEX_ITEM_ENVIRONMENT:
1358 case LATEX_LIST_ENVIRONMENT:
1359 if (next_ && (params().depth() < next_->params().depth())) {
1364 case LATEX_ENVIRONMENT:
1365 // if its the last paragraph of the current environment
1366 // skip it otherwise fall through
1368 && (next_->layout() != layout()
1369 || next_->params().depth() != params().depth()))
1371 // fall through possible
1373 // we don't need it for the last paragraph!!!
1380 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1381 further_blank_line = false;
1382 if (params().lineBottom()) {
1383 os << "\\lyxline{\\" << font.latexSize() << '}';
1384 further_blank_line = true;
1387 if (params().spaceBottom().kind() != VSpace::NONE) {
1388 os << params().spaceBottom().asLatexCommand(bparams);
1389 further_blank_line = true;
1392 if (params().pagebreakBottom()) {
1394 further_blank_line = true;
1397 if (further_blank_line) {
1402 if (!params().spacing().isDefault()
1403 && (!next_ || !next_->hasSameLayout(this))) {
1404 os << params().spacing().writeEnvirEnd() << "\n";
1409 // we don't need it for the last paragraph!!!
1414 // Since \selectlanguage write the language to the aux file,
1415 // we need to reset the language at the end of footnote or
1418 if (language->babel() != doc_language->babel()) {
1419 if (lyxrc.language_command_end.empty())
1420 os << subst(lyxrc.language_command_begin,
1422 doc_language->babel())
1425 os << subst(lyxrc.language_command_end,
1433 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1437 // This could go to ParagraphParameters if we want to
1438 int Paragraph::startTeXParParams(BufferParams const & bparams,
1443 if (params().noindent()) {
1444 os << "\\noindent ";
1448 switch (params().align()) {
1449 case LYX_ALIGN_NONE:
1450 case LYX_ALIGN_BLOCK:
1451 case LYX_ALIGN_LAYOUT:
1452 case LYX_ALIGN_SPECIAL:
1454 case LYX_ALIGN_LEFT:
1455 if (getParLanguage(bparams)->babel() != "hebrew") {
1456 os << "\\begin{flushleft}";
1459 os << "\\begin{flushright}";
1463 case LYX_ALIGN_RIGHT:
1464 if (getParLanguage(bparams)->babel() != "hebrew") {
1465 os << "\\begin{flushright}";
1468 os << "\\begin{flushleft}";
1472 case LYX_ALIGN_CENTER:
1473 os << "\\begin{center}";
1481 // This could go to ParagraphParameters if we want to
1482 int Paragraph::endTeXParParams(BufferParams const & bparams,
1487 switch (params().align()) {
1488 case LYX_ALIGN_NONE:
1489 case LYX_ALIGN_BLOCK:
1490 case LYX_ALIGN_LAYOUT:
1491 case LYX_ALIGN_SPECIAL:
1493 case LYX_ALIGN_LEFT:
1494 if (getParLanguage(bparams)->babel() != "hebrew") {
1495 os << "\\end{flushleft}";
1498 os << "\\end{flushright}";
1502 case LYX_ALIGN_RIGHT:
1503 if (getParLanguage(bparams)->babel() != "hebrew") {
1504 os << "\\end{flushright}";
1507 os << "\\end{flushleft}";
1511 case LYX_ALIGN_CENTER:
1512 os << "\\end{center}";
1520 // This one spits out the text of the paragraph
1521 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1522 BufferParams const & bparams,
1523 ostream & os, TexRow & texrow,
1526 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1528 bool return_value = false;
1532 // well we have to check if we are in an inset with unlimited
1533 // lenght (all in one row) if that is true then we don't allow
1534 // any special options in the paragraph and also we don't allow
1535 // any environment other then "Standard" to be valid!
1537 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1540 style = textclasslist[bparams.textclass].defaultLayout();
1542 style = textclasslist[bparams.textclass][layout()];
1547 // Maybe we have to create a optional argument.
1549 if (style.labeltype != LABEL_MANUAL)
1552 main_body = beginningOfMainBody();
1556 if (main_body > 0) {
1559 basefont = getLabelFont(bparams);
1561 basefont = getLayoutFont(bparams);
1564 moving_arg |= style.needprotect;
1566 // Which font is currently active?
1567 LyXFont running_font(basefont);
1568 // Do we have an open font change?
1569 bool open_font = false;
1571 texrow.start(this, 0);
1573 // if the paragraph is empty, the loop will not be entered at all
1575 if (style.isCommand()) {
1580 column += startTeXParParams(bparams, os);
1584 for (pos_type i = 0; i < size(); ++i) {
1586 // First char in paragraph or after label?
1587 if (i == main_body) {
1588 if (main_body > 0) {
1590 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1593 basefont = getLayoutFont(bparams);
1594 running_font = basefont;
1598 if (style.isCommand()) {
1604 column += startTeXParParams(bparams, os);
1607 value_type c = getChar(i);
1609 // Fully instantiated font
1610 LyXFont font = getFont(bparams, i);
1612 LyXFont const & last_font = running_font;
1614 // Spaces at end of font change are simulated to be
1615 // outside font change, i.e. we write "\textXX{text} "
1616 // rather than "\textXX{text }". (Asger)
1617 if (open_font && c == ' ' && i <= size() - 2) {
1618 LyXFont const & next_font = getFont(bparams, i + 1);
1619 if (next_font != running_font
1620 && next_font != font) {
1625 // We end font definition before blanks
1626 if (font != running_font && open_font) {
1627 column += running_font.latexWriteEndChanges(os,
1629 (i == main_body-1) ? basefont : font);
1630 running_font = basefont;
1634 // Blanks are printed before start of fontswitch
1636 // Do not print the separation of the optional argument
1637 if (i != main_body - 1) {
1638 pimpl_->simpleTeXBlanks(os, texrow, i,
1639 column, font, style);
1643 // Do we need to change font?
1644 if (font != running_font && i != main_body - 1) {
1645 column += font.latexWriteStartChanges(os, basefont,
1647 running_font = font;
1651 if (c == Paragraph::META_NEWLINE) {
1652 // newlines are handled differently here than
1653 // the default in SimpleTeXSpecialChars().
1654 if (!style.newline_allowed) {
1658 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1661 basefont = getLayoutFont(bparams);
1662 running_font = basefont;
1663 if (font.family() ==
1664 LyXFont::TYPEWRITER_FAMILY) {
1672 texrow.start(this, i + 1);
1675 pimpl_->simpleTeXSpecialChars(buf, bparams,
1676 os, texrow, moving_arg,
1678 basefont, open_font,
1679 style, i, column, c);
1683 // If we have an open font definition, we have to close it
1685 #ifdef FIXED_LANGUAGE_END_DETECTION
1688 .latexWriteEndChanges(os, basefont,
1689 next_->getFont(bparams,
1692 running_font.latexWriteEndChanges(os, basefont,
1696 #ifdef WITH_WARNINGS
1697 //#warning For now we ALWAYS have to close the foreign font settings if they are
1698 //#warning there as we start another \selectlanguage with the next paragraph if
1699 //#warning we are in need of this. This should be fixed sometime (Jug)
1701 running_font.latexWriteEndChanges(os, basefont, basefont);
1705 // Needed if there is an optional argument but no contents.
1706 if (main_body > 0 && main_body == size()) {
1708 return_value = false;
1712 column += endTeXParParams(bparams, os);
1715 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1716 return return_value;
1720 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1722 bool retval = false;
1724 case Paragraph::META_HFILL:
1725 sgml_string.erase();
1727 case Paragraph::META_NEWLINE:
1731 sgml_string = "&";
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 = "\";
1773 case '\0': // Ignore :-)
1774 sgml_string.erase();
1784 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1785 BufferParams const & bparams,
1786 ostream & os, TexRow & texrow)
1788 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1790 LyXLayout const & style =
1791 textclasslist[bparams.textclass][layout()];
1793 Language const * language = getParLanguage(bparams);
1794 Language const * doc_language = bparams.language;
1795 Language const * previous_language = previous_
1796 ? previous_->getParLanguage(bparams) : doc_language;
1797 if (language->babel() != previous_language->babel()) {
1799 if (!lyxrc.language_command_end.empty() &&
1800 previous_language->babel() != doc_language->babel()) {
1801 os << subst(lyxrc.language_command_end, "$$lang",
1802 previous_language->babel())
1807 if (lyxrc.language_command_end.empty() ||
1808 language->babel() != doc_language->babel()) {
1809 os << subst(lyxrc.language_command_begin, "$$lang",
1816 if (style.isEnvironment()) {
1817 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1818 os << "\\begin{" << style.latexname() << "}{"
1819 << params().labelWidthString() << "}\n";
1820 } else if (style.labeltype == LABEL_BIBLIO) {
1822 os << "\\begin{" << style.latexname() << "}{"
1823 << bibitemWidest(buf)
1825 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1826 os << "\\begin{" << style.latexname() << '}'
1827 << style.latexparam() << '\n';
1829 os << "\\begin{" << style.latexname() << '}'
1830 << style.latexparam() << '\n';
1833 Paragraph * par = this;
1835 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1837 if (par && par->params().depth() > params().depth()) {
1838 if (textclasslist[bparams.textclass][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());
1862 if (style.isEnvironment()) {
1863 os << "\\end{" << style.latexname() << "}\n";
1867 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1868 return par; // ale970302
1872 bool Paragraph::isHfill(pos_type pos) const
1874 return IsHfillChar(getChar(pos));
1878 bool Paragraph::isInset(pos_type pos) const
1880 return IsInsetChar(getChar(pos));
1884 bool Paragraph::isNewline(pos_type pos) const
1886 return pos >= 0 && IsNewlineChar(getChar(pos));
1890 bool Paragraph::isSeparator(pos_type pos) const
1892 return IsSeparatorChar(getChar(pos));
1896 bool Paragraph::isLineSeparator(pos_type pos) const
1898 value_type const c = getChar(pos);
1899 return IsLineSeparatorChar(c)
1900 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1904 bool Paragraph::isKomma(pos_type pos) const
1906 return IsKommaChar(getChar(pos));
1910 /// Used by the spellchecker
1911 bool Paragraph::isLetter(pos_type pos) const
1913 value_type const c = getChar(pos);
1914 if (IsLetterChar(c))
1917 return getInset(pos)->isLetter();
1918 // We want to pass the ' and escape chars to ispell
1919 string const extra = lyxrc.isp_esc_chars + '\'';
1920 return contains(extra, c);
1924 bool Paragraph::isWord(pos_type pos) const
1926 return IsWordChar(getChar(pos)) ;
1931 Paragraph::getParLanguage(BufferParams const & bparams) const
1934 #ifndef INHERIT_LANGUAGE
1935 return getFirstFontSettings().language();
1937 Language const * lang = getFirstFontSettings().language();
1938 #ifdef WITH_WARNINGS
1939 #warning We should make this somewhat better, any ideas? (Jug)
1941 if (lang == inherit_language || lang == ignore_language)
1942 lang = bparams.language;
1945 } else if (previous_)
1946 return previous_->getParLanguage(bparams);
1948 return bparams.language;
1952 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1954 return lyxrc.rtl_support
1955 && getParLanguage(bparams)->RightToLeft();
1959 void Paragraph::changeLanguage(BufferParams const & bparams,
1960 Language const * from, Language const * to)
1962 for (pos_type i = 0; i < size(); ++i) {
1963 LyXFont font = getFontSettings(bparams, i);
1964 if (font.language() == from) {
1965 font.setLanguage(to);
1972 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1974 Language const * doc_language = bparams.language;
1975 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1976 cit != pimpl_->fontlist.end(); ++cit)
1977 if (cit->font().language() != ignore_language &&
1978 cit->font().language() != latex_language &&
1979 #ifdef INHERIT_LANGUAGE
1980 cit->font().language() != inherit_language &&
1982 cit->font().language() != doc_language)
1988 // Convert the paragraph to a string.
1989 // Used for building the table of contents
1990 string const Paragraph::asString(Buffer const * buffer, bool label)
1992 BufferParams const & bparams = buffer->params;
1994 if (label && !params().labelString().empty())
1995 s += params().labelString() + ' ';
1996 string::size_type const len = s.size();
1998 for (pos_type i = 0; i < size(); ++i) {
1999 value_type c = getChar(i);
2002 else if (c == META_INSET &&
2003 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2005 getInset(i)->ascii(buffer, ost);
2006 s += subst(ost.str().c_str(),'\n',' ');
2010 if (isRightToLeftPar(bparams))
2011 reverse(s.begin() + len,s.end());
2017 string const Paragraph::asString(Buffer const * buffer,
2018 pos_type beg, pos_type end, bool label)
2022 if (beg == 0 && label && !params().labelString().empty())
2023 ost << params().labelString() << ' ';
2025 for (pos_type i = beg; i < end; ++i) {
2026 value_type const c = getUChar(buffer->params, i);
2029 else if (c == META_NEWLINE)
2031 else if (c == META_HFILL)
2033 else if (c == META_INSET) {
2034 getInset(i)->ascii(buffer, ost);
2038 return ost.str().c_str();
2042 void Paragraph::setInsetOwner(Inset * i)
2044 pimpl_->inset_owner = i;
2045 for (InsetList::const_iterator cit = insetlist.begin();
2046 cit != insetlist.end(); ++cit) {
2048 cit->inset->setOwner(i);
2053 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2056 for (InsetList::const_iterator cit = insetlist.begin();
2057 cit != insetlist.end(); ++cit) {
2059 if (cit->inset->isTextInset()) {
2060 static_cast<UpdatableInset *>
2061 (cit->inset)->deleteLyXText(bv, true);
2068 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2071 for (InsetList::const_iterator cit = insetlist.begin();
2072 cit != insetlist.end(); ++cit)
2075 if (cit->inset->isTextInset()) {
2076 static_cast<UpdatableInset *>
2077 (cit->inset)->resizeLyXText(bv, true);
2084 void Paragraph::setContentsFromPar(Paragraph * par)
2086 pimpl_->setContentsFromPar(par);
2090 lyx::pos_type Paragraph::size() const
2092 return pimpl_->size();
2096 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2098 return pimpl_->getChar(pos);
2102 int Paragraph::id() const
2108 void Paragraph::id(int id_arg)
2110 pimpl_->id_ = id_arg;
2114 string const & Paragraph::layout() const
2120 void Paragraph::layout(string const & new_layout)
2122 lyx::Assert(!new_layout.empty());
2124 layout_ = new_layout;
2128 bool Paragraph::isFirstInSequence() const
2130 Paragraph const * dhook = depthHook(getDepth());
2131 return (dhook == this
2132 || dhook->layout() != layout()
2133 || dhook->getDepth() != getDepth());
2137 Inset * Paragraph::inInset() const
2139 return pimpl_->inset_owner;
2143 void Paragraph::clearContents()
2149 void Paragraph::setCounter(int i, int v)
2151 pimpl_->counter_[i] = v;
2155 int Paragraph::getCounter(int i) const
2157 return pimpl_->counter_[i];
2161 void Paragraph::incCounter(int i)
2163 pimpl_->counter_[i]++;
2167 void Paragraph::setChar(pos_type pos, value_type c)
2169 pimpl_->setChar(pos, c);
2173 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2178 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2180 return inset_iterator(insetlist.begin());
2184 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2186 return inset_iterator(insetlist.end());
2190 ParagraphParameters & Paragraph::params()
2192 return pimpl_->params;
2196 ParagraphParameters const & Paragraph::params() const
2198 return pimpl_->params;
2202 Paragraph * Paragraph::getParFromID(int id) const
2204 return pimpl_->getParFromID(id);
2208 bool Paragraph::isFreeSpacing() const
2210 // for now we just need this, later should we need this in some
2211 // other way we can always add a function to Inset::() too.
2212 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2213 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);