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;
58 using lyx::layout_type;
60 int tex_code_break_column = 72; // needs non-zero initialization. set later.
61 // this is a bad idea, but how can Paragraph find its buffer to get
62 // parameters? (JMarc)
64 extern string bibitemWidest(Buffer const *);
66 // this is a minibuffer
71 LyXFont minibuffer_font;
72 Inset * minibuffer_inset;
77 extern BufferView * current_view;
80 Paragraph::Paragraph()
81 : layout(0), pimpl_(new Paragraph::Pimpl(this))
83 for (int i = 0; i < 10; ++i)
89 bibkey = 0; // ale970302
94 // This constructor inserts the new paragraph in a list.
95 Paragraph::Paragraph(Paragraph * par)
96 : layout(0), pimpl_(new Paragraph::Pimpl(this))
98 for (int i = 0; i < 10; ++i)
103 // double linked list begin
106 next_->previous_ = this;
108 previous_->next_ = this;
111 bibkey = 0; // ale970302
117 Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
118 : layout(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
120 for (int i = 0; i < 10; ++i)
127 // this is because of the dummy layout of the paragraphs that
133 bibkey = static_cast<InsetBibKey *>
134 (lp.bibkey->clone(*current_view->buffer()));
139 // copy everything behind the break-position to the new paragraph
140 insetlist = lp.insetlist;
141 for (InsetList::iterator it = insetlist.begin();
142 it != insetlist.end(); ++it)
144 it->inset = it->inset->clone(*current_view->buffer(), same_ids);
145 // tell the new inset who is the boss now
146 it->inset->parOwner(this);
151 // the destructor removes the new paragraph from the list
152 Paragraph::~Paragraph()
155 previous_->next_ = next_;
157 next_->previous_ = previous_;
159 for (InsetList::iterator it = insetlist.begin();
160 it != insetlist.end(); ++it) {
169 //lyxerr << "Paragraph::paragraph_id = "
170 // << Paragraph::paragraph_id << endl;
174 void Paragraph::writeFile(Buffer const * buf, ostream & os,
175 BufferParams const & bparams,
176 depth_type dth) const
178 // The beginning or end of a deeper (i.e. nested) area?
179 if (dth != params().depth()) {
180 if (params().depth() > dth) {
181 while (params().depth() > dth) {
182 os << "\n\\begin_deeper ";
186 while (params().depth() < dth) {
187 os << "\n\\end_deeper ";
193 // First write the layout
195 << textclasslist.NameOfLayout(bparams.textclass, layout)
198 // Maybe some vertical spaces.
199 if (params().spaceTop().kind() != VSpace::NONE)
200 os << "\\added_space_top "
201 << params().spaceTop().asLyXCommand() << " ";
202 if (params().spaceBottom().kind() != VSpace::NONE)
203 os << "\\added_space_bottom "
204 << params().spaceBottom().asLyXCommand() << " ";
206 // Maybe the paragraph has special spacing
207 params().spacing().writeFile(os, true);
209 // The labelwidth string used in lists.
210 if (!params().labelWidthString().empty())
211 os << "\\labelwidthstring "
212 << params().labelWidthString() << '\n';
214 // Lines above or below?
215 if (params().lineTop())
217 if (params().lineBottom())
218 os << "\\line_bottom ";
220 // Pagebreaks above or below?
221 if (params().pagebreakTop())
222 os << "\\pagebreak_top ";
223 if (params().pagebreakBottom())
224 os << "\\pagebreak_bottom ";
226 // Start of appendix?
227 if (params().startOfAppendix())
228 os << "\\start_of_appendix ";
231 if (params().noindent())
235 if (params().align() != LYX_ALIGN_LAYOUT) {
237 switch (params().align()) {
238 case LYX_ALIGN_LEFT: h = 1; break;
239 case LYX_ALIGN_RIGHT: h = 2; break;
240 case LYX_ALIGN_CENTER: h = 3; break;
241 default: h = 0; break;
243 os << "\\align " << string_align[h] << " ";
248 bibkey->write(buf, os);
250 LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
253 for (pos_type i = 0; i < size(); ++i) {
259 // Write font changes
260 LyXFont font2 = getFontSettings(bparams, i);
261 if (font2 != font1) {
262 #ifndef INHERIT_LANGUAGE
263 font2.lyxWriteChanges(font1, os);
265 font2.lyxWriteChanges(font1, bparams.language, os);
271 value_type const c = getChar(i);
275 Inset const * inset = getInset(i);
277 if (inset->directWrite()) {
278 // international char, let it write
279 // code directly so it's shorter in
281 inset->write(buf, os);
283 os << "\n\\begin_inset ";
284 inset->write(buf, os);
285 os << "\n\\end_inset \n\n";
291 os << "\n\\newline \n";
295 os << "\n\\hfill \n";
299 os << "\n\\backslash \n";
303 if (i + 1 < size() && getChar(i + 1) == ' ') {
310 if ((column > 70 && c == ' ')
315 // this check is to amend a bug. LyX sometimes
316 // inserts '\0' this could cause problems.
320 lyxerr << "ERROR (Paragraph::writeFile):"
321 " NULL char in structure." << endl;
327 // now write the next paragraph
329 next_->writeFile(buf, os, bparams, dth);
333 void Paragraph::validate(LaTeXFeatures & features) const
335 BufferParams const & bparams = features.bufferParams();
338 if (params().lineTop() || params().lineBottom())
339 features.require("lyxline");
340 if (!params().spacing().isDefault())
341 features.require("setspace");
344 features.useLayout(getLayout());
347 Language const * doc_language = bparams.language;
349 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
350 cit != pimpl_->fontlist.end(); ++cit) {
351 if (cit->font().noun() == LyXFont::ON) {
352 lyxerr[Debug::LATEX] << "font.noun: "
353 << cit->font().noun()
355 features.require("noun");
356 lyxerr[Debug::LATEX] << "Noun enabled. Font: "
357 << cit->font().stateText(0)
360 switch (cit->font().color()) {
362 case LColor::inherit:
364 // probably we should put here all interface colors used for
365 // font displaying! For now I just add this ones I know of (Jug)
370 features.require("color");
371 lyxerr[Debug::LATEX] << "Color enabled. Font: "
372 << cit->font().stateText(0)
376 Language const * language = cit->font().language();
377 if (language->babel() != doc_language->babel() &&
378 language != ignore_language &&
379 #ifdef INHERIT_LANGUAGE
380 language != inherit_language &&
382 language != latex_language)
384 features.useLanguage(language);
385 lyxerr[Debug::LATEX] << "Found language "
386 << language->babel() << endl;
391 LyXLayout const & layout =
392 textclasslist.Style(bparams.textclass, getLayout());
394 for (InsetList::const_iterator cit = insetlist.begin();
395 cit != insetlist.end(); ++cit) {
397 cit->inset->validate(features);
398 if (layout.needprotect &&
399 cit->inset->lyxCode() == Inset::FOOT_CODE)
400 features.require("NeedLyXFootnoteCode");
406 // First few functions needed for cut and paste and paragraph breaking.
407 void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
409 BufferParams bparams = buffer.params;
411 minibuffer_char = getChar(pos);
412 minibuffer_font = getFontSettings(bparams, pos);
413 minibuffer_inset = 0;
414 if (minibuffer_char == Paragraph::META_INSET) {
416 minibuffer_inset = getInset(pos)->clone(buffer);
418 minibuffer_inset = 0;
419 minibuffer_char = ' ';
420 // This reflects what GetInset() does (ARRae)
426 void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
428 minibuffer_char = getChar(pos);
429 minibuffer_font = getFontSettings(bparams, pos);
430 minibuffer_inset = 0;
431 if (minibuffer_char == Paragraph::META_INSET) {
433 minibuffer_inset = getInset(pos);
434 // This is a little hack since I want exactly
435 // the inset, not just a clone. Otherwise
436 // the inset would be deleted when calling Erase(pos)
438 InsetTable search_elem(pos, 0);
439 InsetList::iterator it =
440 lower_bound(insetlist.begin(),
442 search_elem, Pimpl::matchIT());
443 if (it != insetlist.end() && it->pos == pos)
445 // the inset is not in a paragraph anymore
446 minibuffer_inset->parOwner(0);
448 minibuffer_inset = 0;
449 minibuffer_char = ' ';
450 // This reflects what GetInset() does (ARRae)
455 // Erase(pos); now the caller is responsible for that.
459 bool Paragraph::insertFromMinibuffer(pos_type pos)
461 if (minibuffer_char == Paragraph::META_INSET) {
462 if (!insetAllowed(minibuffer_inset->lyxCode())) {
465 insertInset(pos, minibuffer_inset, minibuffer_font);
467 LyXFont f = minibuffer_font;
468 if (!checkInsertChar(f)) {
471 insertChar(pos, minibuffer_char, f);
480 void Paragraph::clear()
489 void Paragraph::erase(pos_type pos)
495 bool Paragraph::checkInsertChar(LyXFont & font)
497 if (pimpl_->inset_owner)
498 return pimpl_->inset_owner->checkInsertChar(font);
503 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
505 LyXFont const f(LyXFont::ALL_INHERIT);
506 insertChar(pos, c, f);
510 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
511 LyXFont const & font)
513 pimpl_->insertChar(pos, c, font);
517 void Paragraph::insertInset(pos_type pos, Inset * inset)
519 LyXFont const f(LyXFont::ALL_INHERIT);
520 insertInset(pos, inset, f);
524 void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font)
526 pimpl_->insertInset(pos, inset, font);
530 bool Paragraph::insetAllowed(Inset::Code code)
532 //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
534 if (pimpl_->inset_owner)
535 return pimpl_->inset_owner->insetAllowed(code);
540 Inset * Paragraph::getInset(pos_type pos)
542 lyx::Assert(pos < size());
545 InsetTable search_inset(pos, 0);
546 InsetList::iterator it = lower_bound(insetlist.begin(),
548 search_inset, Pimpl::matchIT());
549 if (it != insetlist.end() && it->pos == pos)
552 lyxerr << "ERROR (Paragraph::getInset): "
553 "Inset does not exist: " << pos << endl;
556 // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
557 // Did this commenting out introduce a bug? So far I have not
558 // see any, please enlighten me. (Lgb)
559 // My guess is that since the inset does not exist, we might
560 // as well replace it with a space to prevent craches. (Asger)
565 Inset const * Paragraph::getInset(pos_type pos) const
567 lyx::Assert(pos < size());
570 InsetTable search_inset(pos, 0);
571 InsetList::const_iterator cit = lower_bound(insetlist.begin(),
573 search_inset, Pimpl::matchIT());
574 if (cit != insetlist.end() && cit->pos == pos)
577 lyxerr << "ERROR (Paragraph::GetInset): "
578 "Inset does not exist: " << pos << endl;
580 //text[pos] = ' '; // WHY!!! does this set the pos to ' '????
581 // Did this commenting out introduce a bug? So far I have not
582 // see any, please enlighten me. (Lgb)
583 // My guess is that since the inset does not exist, we might
584 // as well replace it with a space to prevent craches. (Asger)
589 // Gets uninstantiated font setting at position.
590 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
593 lyx::Assert(pos <= size());
595 Pimpl::FontTable search_font(pos, LyXFont());
596 Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
597 pimpl_->fontlist.end(),
598 search_font, Pimpl::matchFT());
600 if (cit != pimpl_->fontlist.end()) {
601 retfont = cit->font();
602 } else if (pos == size() && size()) {
603 retfont = getFontSettings(bparams, pos - 1);
605 retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
606 #ifdef INHERIT_LANGUAGE
607 if (retfont.language() == inherit_language)
608 retfont.setLanguage(bparams.language);
615 // Gets uninstantiated font setting at position 0
616 LyXFont const Paragraph::getFirstFontSettings() const
618 if (size() > 0 && !pimpl_->fontlist.empty())
619 return pimpl_->fontlist[0].font();
621 return LyXFont(LyXFont::ALL_INHERIT);
625 // Gets the fully instantiated font at a given position in a paragraph
626 // This is basically the same function as LyXText::GetFont() in text2.C.
627 // The difference is that this one is used for generating the LaTeX file,
628 // and thus cosmetic "improvements" are disallowed: This has to deliver
629 // the true picture of the buffer. (Asger)
630 // If position is -1, we get the layout font of the paragraph.
631 // If position is -2, we get the font of the manual label of the paragraph.
632 LyXFont const Paragraph::getFont(BufferParams const & bparams,
635 lyx::Assert(pos >= 0);
637 LyXLayout const & layout =
638 textclasslist.Style(bparams.textclass,
640 pos_type main_body = 0;
641 if (layout.labeltype == LABEL_MANUAL)
642 main_body = beginningOfMainBody();
646 layoutfont = layout.labelfont;
648 layoutfont = layout.font;
650 LyXFont tmpfont = getFontSettings(bparams, pos);
651 #ifndef INHERIT_LANGUAGE
652 tmpfont.realize(layoutfont);
654 tmpfont.realize(layoutfont, bparams.language);
657 return pimpl_->realizeFont(tmpfont, bparams);
661 LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
663 LyXLayout const & layout =
664 textclasslist.Style(bparams.textclass, getLayout());
666 LyXFont tmpfont = layout.labelfont;
667 tmpfont.setLanguage(getParLanguage(bparams));
669 return pimpl_->realizeFont(tmpfont, bparams);
673 LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
675 LyXLayout const & layout =
676 textclasslist.Style(bparams.textclass,
679 LyXFont tmpfont = layout.font;
680 tmpfont.setLanguage(getParLanguage(bparams));
682 return pimpl_->realizeFont(tmpfont, bparams);
686 /// Returns the height of the highest font in range
688 Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
689 LyXFont::FONT_SIZE const def_size) const
691 if (pimpl_->fontlist.empty())
694 LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
695 Pimpl::FontTable end_search(endpos, LyXFont());
696 Pimpl::FontList::const_iterator end_it =
697 lower_bound(pimpl_->fontlist.begin(),
698 pimpl_->fontlist.end(),
699 end_search, Pimpl::matchFT());
700 if (end_it != pimpl_->fontlist.end())
703 Pimpl::FontTable start_search(startpos, LyXFont());
704 Pimpl::FontList::const_iterator cit =
705 lower_bound(pimpl_->fontlist.begin(),
706 pimpl_->fontlist.end(),
707 start_search, Pimpl::matchFT());
709 for (; cit != end_it; ++cit) {
710 LyXFont::FONT_SIZE size = cit->font().size();
711 if (size == LyXFont::INHERIT_SIZE)
713 if (size > maxsize && size <= LyXFont::SIZE_HUGER)
720 Paragraph::value_type
721 Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
723 value_type c = getChar(pos);
724 if (!lyxrc.rtl_support)
754 if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
761 void Paragraph::setFont(pos_type pos, LyXFont const & font)
763 lyx::Assert(pos <= size());
765 // First, reduce font against layout/label font
766 // Update: The SetCharFont() routine in text2.C already
767 // reduces font, so we don't need to do that here. (Asger)
768 // No need to simplify this because it will disappear
769 // in a new kernel. (Asger)
770 // Next search font table
772 Pimpl::FontTable search_font(pos, LyXFont());
773 Pimpl::FontList::iterator it = lower_bound(pimpl_->fontlist.begin(),
774 pimpl_->fontlist.end(),
775 search_font, Pimpl::matchFT());
776 unsigned int i = it - pimpl_->fontlist.begin();
777 bool notfound = it == pimpl_->fontlist.end();
779 if (!notfound && pimpl_->fontlist[i].font() == font)
782 bool begin = pos == 0 || notfound ||
783 (i > 0 && pimpl_->fontlist[i-1].pos() == pos - 1);
784 // Is position pos is a beginning of a font block?
785 bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
786 // Is position pos is the end of a font block?
787 if (begin && end) { // A single char block
788 if (i + 1 < pimpl_->fontlist.size() &&
789 pimpl_->fontlist[i + 1].font() == font) {
790 // Merge the singleton block with the next block
791 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
792 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
793 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i-1);
794 } else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
795 // Merge the singleton block with the previous block
796 pimpl_->fontlist[i - 1].pos(pos);
797 pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
799 pimpl_->fontlist[i].font(font);
801 if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
802 pimpl_->fontlist[i - 1].pos(pos);
804 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
805 Pimpl::FontTable(pos, font));
807 pimpl_->fontlist[i].pos(pos - 1);
808 if (!(i + 1 < pimpl_->fontlist.size() &&
809 pimpl_->fontlist[i + 1].font() == font))
810 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
811 Pimpl::FontTable(pos, font));
812 } else { // The general case. The block is splitted into 3 blocks
813 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
814 Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
815 pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
816 Pimpl::FontTable(pos, font));
822 void Paragraph::next(Paragraph * p)
828 // This function is able to hide closed footnotes.
829 Paragraph * Paragraph::next()
835 Paragraph const * Paragraph::next() const
841 void Paragraph::previous(Paragraph * p)
847 // This function is able to hide closed footnotes.
848 Paragraph * Paragraph::previous()
854 // This function is able to hide closed footnotes.
855 Paragraph const * Paragraph::previous() const
861 void Paragraph::breakParagraph(BufferParams const & bparams,
865 // create a new paragraph
866 Paragraph * tmp = new Paragraph(this);
867 // remember to set the inset_owner
868 tmp->setInsetOwner(inInset());
870 // this is an idea for a more userfriendly layout handling, I will
871 // see what the users say
873 // layout stays the same with latex-environments
875 tmp->setOnlyLayout(layout);
876 tmp->setLabelWidthString(params().labelWidthString());
879 if (size() > pos || !size() || flag == 2) {
880 tmp->setOnlyLayout(layout);
881 tmp->params().align(params().align());
882 tmp->setLabelWidthString(params().labelWidthString());
884 tmp->params().lineBottom(params().lineBottom());
885 params().lineBottom(false);
886 tmp->params().pagebreakBottom(params().pagebreakBottom());
887 params().pagebreakBottom(false);
888 tmp->params().spaceBottom(params().spaceBottom());
889 params().spaceBottom(VSpace(VSpace::NONE));
891 tmp->params().depth(params().depth());
892 tmp->params().noindent(params().noindent());
894 // copy everything behind the break-position
895 // to the new paragraph
896 pos_type pos_end = size() - 1;
899 for (; i <= pos_end; ++i) {
900 cutIntoMinibuffer(bparams, i);
901 if (tmp->insertFromMinibuffer(j - pos))
904 for (i = pos_end; i >= pos; --i) {
909 // just an idea of me
911 tmp->params().lineTop(params().lineTop());
912 tmp->params().pagebreakTop(params().pagebreakTop());
913 tmp->params().spaceTop(params().spaceTop());
914 tmp->bibkey = bibkey;
916 // layout stays the same with latex-environments
918 setOnlyLayout(tmp->layout);
919 setLabelWidthString(tmp->params().labelWidthString());
920 params().depth(tmp->params().depth());
926 void Paragraph::makeSameLayout(Paragraph const * par)
928 layout = par->layout;
930 params() = par->params();
934 int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
936 if (textclasslist.Style(tclass, getLayout()).free_spacing ||
943 while (size() && (isNewline(0) || isLineSeparator(0))) {
952 bool Paragraph::hasSameLayout(Paragraph const * par) const
955 par->layout == layout &&
956 params().sameLayout(par->params());
960 void Paragraph::breakParagraphConservative(BufferParams const & bparams,
963 // create a new paragraph
964 Paragraph * tmp = new Paragraph(this);
965 tmp->makeSameLayout(this);
967 // When can pos > Last()?
968 // I guess pos == Last() is possible.
970 // copy everything behind the break-position to the new
972 pos_type pos_end = size() - 1;
976 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
977 cutIntoMinibuffer(bparams, i);
978 if (tmp->insertFromMinibuffer(j - pos))
982 for (pos_type k = pos_end; k >= pos; --k) {
989 // Be carefull, this does not make any check at all.
990 // This method has wrong name, it combined this par with the next par.
991 // In that sense it is the reverse of break paragraph. (Lgb)
992 void Paragraph::pasteParagraph(BufferParams const & bparams)
994 // copy the next paragraph to this one
995 Paragraph * the_next = next();
997 // first the DTP-stuff
998 params().lineBottom(the_next->params().lineBottom());
999 params().spaceBottom(the_next->params().spaceBottom());
1000 params().pagebreakBottom(the_next->params().pagebreakBottom());
1002 pos_type pos_end = the_next->pimpl_->size() - 1;
1003 pos_type pos_insert = size();
1005 // ok, now copy the paragraph
1006 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
1007 the_next->cutIntoMinibuffer(bparams, i);
1008 if (insertFromMinibuffer(pos_insert + j))
1012 // delete the next paragraph
1013 Paragraph * ppar = the_next->previous_;
1014 Paragraph * npar = the_next->next_;
1020 int Paragraph::getEndLabel(BufferParams const & bparams) const
1022 Paragraph const * par = this;
1023 depth_type par_depth = getDepth();
1025 layout_type layout = par->getLayout();
1026 int const endlabeltype =
1027 textclasslist.Style(bparams.textclass,
1028 layout).endlabeltype;
1029 if (endlabeltype != END_LABEL_NO_LABEL) {
1031 return endlabeltype;
1033 depth_type const next_depth = next_->getDepth();
1034 if (par_depth > next_depth ||
1035 (par_depth == next_depth
1036 && layout != next_->getLayout()))
1037 return endlabeltype;
1042 par = par->outerHook();
1044 par_depth = par->getDepth();
1046 return END_LABEL_NO_LABEL;
1050 Paragraph::depth_type Paragraph::getDepth() const
1052 return params().depth();
1056 Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
1058 const bool isenv = textclasslist.Style(buffer->params.textclass,
1059 getLayout()).isEnvironment();
1062 return params().depth() + 1;
1064 return params().depth();
1068 char Paragraph::getAlign() const
1070 return params().align();
1074 string const & Paragraph::getLabelstring() const
1076 return params().labelString();
1080 int Paragraph::getFirstCounter(int i) const
1082 return pimpl_->counter_[i];
1086 // the next two functions are for the manual labels
1087 string const Paragraph::getLabelWidthString() const
1089 if (!params().labelWidthString().empty())
1090 return params().labelWidthString();
1092 return _("Senseless with this layout!");
1096 void Paragraph::setLabelWidthString(string const & s)
1098 params().labelWidthString(s);
1102 void Paragraph::setOnlyLayout(layout_type new_layout)
1104 layout = new_layout;
1108 void Paragraph::setLayout(layout_type new_layout)
1110 layout = new_layout;
1111 params().labelWidthString(string());
1112 params().align(LYX_ALIGN_LAYOUT);
1113 params().spaceTop(VSpace(VSpace::NONE));
1114 params().spaceBottom(VSpace(VSpace::NONE));
1115 params().spacing(Spacing(Spacing::Default));
1119 // if the layout of a paragraph contains a manual label, the beginning of the
1120 // main body is the beginning of the second word. This is what the par-
1121 // function returns. If the layout does not contain a label, the main
1122 // body always starts with position 0. This differentiation is necessary,
1123 // because there cannot be a newline or a blank <= the beginning of the
1124 // main body in TeX.
1126 int Paragraph::beginningOfMainBody() const
1128 // Unroll the first two cycles of the loop
1129 // and remember the previous character to
1130 // remove unnecessary GetChar() calls
1133 && getChar(i) != Paragraph::META_NEWLINE) {
1135 char previous_char = 0;
1138 && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) {
1139 // Yes, this ^ is supposed to be "= " not "=="
1142 && previous_char != ' '
1143 && (temp = getChar(i)) != Paragraph::META_NEWLINE) {
1145 previous_char = temp;
1154 Paragraph * Paragraph::depthHook(depth_type depth)
1156 Paragraph * newpar = this;
1159 newpar = newpar->previous();
1160 } while (newpar && newpar->getDepth() > depth);
1163 if (previous() || getDepth())
1164 lyxerr << "ERROR (Paragraph::DepthHook): "
1173 Paragraph const * Paragraph::depthHook(depth_type depth) const
1175 Paragraph const * newpar = this;
1178 newpar = newpar->previous();
1179 } while (newpar && newpar->getDepth() > depth);
1182 if (previous() || getDepth())
1183 lyxerr << "ERROR (Paragraph::DepthHook): "
1191 Paragraph * Paragraph::outerHook()
1195 return depthHook(depth_type(getDepth() - 1));
1198 Paragraph const * Paragraph::outerHook() const
1202 return depthHook(depth_type(getDepth() - 1));
1206 Paragraph::inset_iterator
1207 Paragraph::InsetIterator(pos_type pos)
1209 InsetTable search_inset(pos, 0);
1210 InsetList::iterator it = lower_bound(insetlist.begin(),
1212 search_inset, Pimpl::matchIT());
1213 return inset_iterator(it);
1217 // returns -1 if inset not found
1218 int Paragraph::getPositionOfInset(Inset const * inset) const
1221 for (InsetList::const_iterator cit = insetlist.begin();
1222 cit != insetlist.end(); ++cit) {
1223 if (cit->inset == inset) {
1227 if (inset == bibkey)
1234 Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
1235 BufferParams const & bparams,
1236 ostream & os, TexRow & texrow,
1239 lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
1240 Inset const * in = inInset();
1241 bool further_blank_line = false;
1244 // well we have to check if we are in an inset with unlimited
1245 // lenght (all in one row) if that is true then we don't allow
1246 // any special options in the paragraph and also we don't allow
1247 // any environment other then "Standard" to be valid!
1248 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1249 style = textclasslist.Style(bparams.textclass, layout);
1251 if (params().startOfAppendix()) {
1252 os << "\\appendix\n";
1256 if (!params().spacing().isDefault()
1257 && (!previous() || !previous()->hasSameLayout(this))) {
1258 os << params().spacing().writeEnvirBegin() << "\n";
1262 if (tex_code_break_column && style.isCommand()) {
1267 if (params().pagebreakTop()) {
1269 further_blank_line = true;
1271 if (params().spaceTop().kind() != VSpace::NONE) {
1272 os << params().spaceTop().asLatexCommand(bparams);
1273 further_blank_line = true;
1276 if (params().lineTop()) {
1277 os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
1278 << "\\vspace{-1\\parskip}";
1279 further_blank_line = true;
1282 if (further_blank_line) {
1287 style = textclasslist.Style(bparams.textclass, 0);
1290 Language const * language = getParLanguage(bparams);
1291 Language const * doc_language = bparams.language;
1292 Language const * previous_language = previous()
1293 ? previous()->getParLanguage(bparams) : doc_language;
1295 if (language->babel() != previous_language->babel()
1296 // check if we already put language command in TeXEnvironment()
1297 && !(style.isEnvironment()
1298 && (!previous() || previous()->layout != layout ||
1299 previous()->params().depth() != params().depth())))
1301 if (!lyxrc.language_command_end.empty() &&
1302 previous_language->babel() != doc_language->babel())
1304 os << subst(lyxrc.language_command_end, "$$lang",
1305 previous_language->babel())
1310 if (lyxrc.language_command_end.empty() ||
1311 language->babel() != doc_language->babel())
1313 os << subst(lyxrc.language_command_begin, "$$lang",
1320 if (bparams.inputenc == "auto" &&
1321 language->encoding() != previous_language->encoding()) {
1322 os << "\\inputencoding{"
1323 << language->encoding()->LatexName()
1328 switch (style.latextype) {
1331 << style.latexname()
1332 << style.latexparam();
1334 case LATEX_ITEM_ENVIRONMENT:
1336 bibkey->latex(buf, os, false, false);
1340 case LATEX_LIST_ENVIRONMENT:
1347 bool need_par = simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
1349 // Make sure that \\par is done with the font of the last
1350 // character if this has another size as the default.
1351 // This is necessary because LaTeX (and LyX on the screen)
1352 // calculates the space between the baselines according
1353 // to this font. (Matthias)
1355 // Is this really needed ? (Dekel)
1356 // We do not need to use to change the font for the last paragraph
1357 // or for a command.
1358 LyXFont const font =
1360 ? getLayoutFont(bparams) : getFont(bparams, size() - 1));
1362 bool is_command = style.isCommand();
1364 if (style.resfont.size() != font.size() && next_ && !is_command) {
1367 os << "\\" << font.latexSize() << " \\par}";
1368 } else if (need_par) {
1370 } else if (is_command)
1373 switch (style.latextype) {
1374 case LATEX_ITEM_ENVIRONMENT:
1375 case LATEX_LIST_ENVIRONMENT:
1376 if (next_ && (params().depth() < next_->params().depth())) {
1381 case LATEX_ENVIRONMENT:
1382 // if its the last paragraph of the current environment
1383 // skip it otherwise fall through
1385 && (next_->layout != layout
1386 || next_->params().depth() != params().depth()))
1388 // fall through possible
1390 // we don't need it for the last paragraph!!!
1397 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
1398 further_blank_line = false;
1399 if (params().lineBottom()) {
1400 os << "\\lyxline{\\" << font.latexSize() << '}';
1401 further_blank_line = true;
1404 if (params().spaceBottom().kind() != VSpace::NONE) {
1405 os << params().spaceBottom().asLatexCommand(bparams);
1406 further_blank_line = true;
1409 if (params().pagebreakBottom()) {
1411 further_blank_line = true;
1414 if (further_blank_line) {
1419 if (!params().spacing().isDefault()
1420 && (!next_ || !next_->hasSameLayout(this))) {
1421 os << params().spacing().writeEnvirEnd() << "\n";
1426 // we don't need it for the last paragraph!!!
1431 // Since \selectlanguage write the language to the aux file,
1432 // we need to reset the language at the end of footnote or
1435 if (language->babel() != doc_language->babel()) {
1436 if (lyxrc.language_command_end.empty())
1437 os << subst(lyxrc.language_command_begin,
1439 doc_language->babel())
1442 os << subst(lyxrc.language_command_end,
1450 lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
1454 // This could go to ParagraphParameters if we want to
1455 int Paragraph::startTeXParParams(BufferParams const & bparams,
1460 if (params().noindent()) {
1461 os << "\\noindent ";
1465 switch (params().align()) {
1466 case LYX_ALIGN_NONE:
1467 case LYX_ALIGN_BLOCK:
1468 case LYX_ALIGN_LAYOUT:
1469 case LYX_ALIGN_SPECIAL:
1471 case LYX_ALIGN_LEFT:
1472 if (getParLanguage(bparams)->babel() != "hebrew") {
1473 os << "\\begin{flushleft}";
1476 os << "\\begin{flushright}";
1480 case LYX_ALIGN_RIGHT:
1481 if (getParLanguage(bparams)->babel() != "hebrew") {
1482 os << "\\begin{flushright}";
1485 os << "\\begin{flushleft}";
1489 case LYX_ALIGN_CENTER:
1490 os << "\\begin{center}";
1498 // This could go to ParagraphParameters if we want to
1499 int Paragraph::endTeXParParams(BufferParams const & bparams,
1504 switch (params().align()) {
1505 case LYX_ALIGN_NONE:
1506 case LYX_ALIGN_BLOCK:
1507 case LYX_ALIGN_LAYOUT:
1508 case LYX_ALIGN_SPECIAL:
1510 case LYX_ALIGN_LEFT:
1511 if (getParLanguage(bparams)->babel() != "hebrew") {
1512 os << "\\end{flushleft}";
1515 os << "\\end{flushright}";
1519 case LYX_ALIGN_RIGHT:
1520 if (getParLanguage(bparams)->babel() != "hebrew") {
1521 os << "\\end{flushright}";
1524 os << "\\end{flushleft}";
1528 case LYX_ALIGN_CENTER:
1529 os << "\\end{center}";
1537 // This one spits out the text of the paragraph
1538 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
1539 BufferParams const & bparams,
1540 ostream & os, TexRow & texrow,
1543 lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
1545 bool return_value = false;
1549 // well we have to check if we are in an inset with unlimited
1550 // lenght (all in one row) if that is true then we don't allow
1551 // any special options in the paragraph and also we don't allow
1552 // any environment other then "Standard" to be valid!
1554 (inInset() && inInset()->forceDefaultParagraphs(inInset()));
1557 style = textclasslist.Style(bparams.textclass, 0);
1559 style = textclasslist.Style(bparams.textclass, layout);
1564 // Maybe we have to create a optional argument.
1566 if (style.labeltype != LABEL_MANUAL)
1569 main_body = beginningOfMainBody();
1573 if (main_body > 0) {
1576 basefont = getLabelFont(bparams);
1578 basefont = getLayoutFont(bparams);
1581 moving_arg |= style.needprotect;
1583 // Which font is currently active?
1584 LyXFont running_font(basefont);
1585 // Do we have an open font change?
1586 bool open_font = false;
1588 texrow.start(this, 0);
1590 // if the paragraph is empty, the loop will not be entered at all
1592 if (style.isCommand()) {
1597 column += startTeXParParams(bparams, os);
1601 for (pos_type i = 0; i < size(); ++i) {
1603 // First char in paragraph or after label?
1604 if (i == main_body) {
1605 if (main_body > 0) {
1607 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1610 basefont = getLayoutFont(bparams);
1611 running_font = basefont;
1615 if (style.isCommand()) {
1621 column += startTeXParParams(bparams, os);
1624 value_type c = getChar(i);
1626 // Fully instantiated font
1627 LyXFont font = getFont(bparams, i);
1629 LyXFont const & last_font = running_font;
1631 // Spaces at end of font change are simulated to be
1632 // outside font change, i.e. we write "\textXX{text} "
1633 // rather than "\textXX{text }". (Asger)
1634 if (open_font && c == ' ' && i <= size() - 2) {
1635 LyXFont const & next_font = getFont(bparams, i + 1);
1636 if (next_font != running_font
1637 && next_font != font) {
1642 // We end font definition before blanks
1643 if (font != running_font && open_font) {
1644 column += running_font.latexWriteEndChanges(os,
1646 (i == main_body-1) ? basefont : font);
1647 running_font = basefont;
1651 // Blanks are printed before start of fontswitch
1653 // Do not print the separation of the optional argument
1654 if (i != main_body - 1) {
1655 pimpl_->simpleTeXBlanks(os, texrow, i,
1656 column, font, style);
1660 // Do we need to change font?
1661 if (font != running_font && i != main_body - 1) {
1662 column += font.latexWriteStartChanges(os, basefont,
1664 running_font = font;
1668 if (c == Paragraph::META_NEWLINE) {
1669 // newlines are handled differently here than
1670 // the default in SimpleTeXSpecialChars().
1671 if (!style.newline_allowed) {
1675 column += running_font.latexWriteEndChanges(os, basefont, basefont);
1678 basefont = getLayoutFont(bparams);
1679 running_font = basefont;
1680 if (font.family() ==
1681 LyXFont::TYPEWRITER_FAMILY) {
1689 texrow.start(this, i + 1);
1692 pimpl_->simpleTeXSpecialChars(buf, bparams,
1693 os, texrow, moving_arg,
1695 basefont, open_font,
1696 style, i, column, c);
1700 // If we have an open font definition, we have to close it
1702 #ifdef FIXED_LANGUAGE_END_DETECTION
1705 .latexWriteEndChanges(os, basefont,
1706 next_->getFont(bparams,
1709 running_font.latexWriteEndChanges(os, basefont,
1713 #ifdef WITH_WARNINGS
1714 //#warning For now we ALWAYS have to close the foreign font settings if they are
1715 //#warning there as we start another \selectlanguage with the next paragraph if
1716 //#warning we are in need of this. This should be fixed sometime (Jug)
1718 running_font.latexWriteEndChanges(os, basefont, basefont);
1722 // Needed if there is an optional argument but no contents.
1723 if (main_body > 0 && main_body == size()) {
1725 return_value = false;
1729 column += endTeXParParams(bparams, os);
1732 lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
1733 return return_value;
1737 bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
1739 bool retval = false;
1741 case Paragraph::META_HFILL:
1742 sgml_string.erase();
1744 case Paragraph::META_NEWLINE:
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 = "{";
1775 sgml_string = "}";
1778 sgml_string = "˜";
1781 sgml_string = """;
1784 sgml_string = "\";
1790 case '\0': // Ignore :-)
1791 sgml_string.erase();
1801 Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
1802 BufferParams const & bparams,
1803 ostream & os, TexRow & texrow)
1805 lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
1807 LyXLayout const & style =
1808 textclasslist.Style(bparams.textclass,
1811 Language const * language = getParLanguage(bparams);
1812 Language const * doc_language = bparams.language;
1813 Language const * previous_language = previous_
1814 ? previous_->getParLanguage(bparams) : doc_language;
1815 if (language->babel() != previous_language->babel()) {
1817 if (!lyxrc.language_command_end.empty() &&
1818 previous_language->babel() != doc_language->babel()) {
1819 os << subst(lyxrc.language_command_end, "$$lang",
1820 previous_language->babel())
1825 if (lyxrc.language_command_end.empty() ||
1826 language->babel() != doc_language->babel()) {
1827 os << subst(lyxrc.language_command_begin, "$$lang",
1834 if (style.isEnvironment()) {
1835 if (style.latextype == LATEX_LIST_ENVIRONMENT) {
1836 os << "\\begin{" << style.latexname() << "}{"
1837 << params().labelWidthString() << "}\n";
1838 } else if (style.labeltype == LABEL_BIBLIO) {
1840 os << "\\begin{" << style.latexname() << "}{"
1841 << bibitemWidest(buf)
1843 } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
1844 os << "\\begin{" << style.latexname() << '}'
1845 << style.latexparam() << '\n';
1847 os << "\\begin{" << style.latexname() << '}'
1848 << style.latexparam() << '\n';
1851 Paragraph * par = this;
1853 par = par->TeXOnePar(buf, bparams, os, texrow, false);
1855 if (par && par->params().depth() > params().depth()) {
1856 if (textclasslist.Style(bparams.textclass,
1857 par->layout).isParagraph()
1859 // How to handle this? (Lgb)
1860 //&& !suffixIs(os, "\n\n")
1862 // There should be at least one '\n' already
1863 // but we need there to be two for Standard
1864 // paragraphs that are depth-increment'ed to be
1865 // output correctly. However, tables can
1866 // also be paragraphs so don't adjust them.
1869 // Will it ever harm to have one '\n' too
1870 // many? i.e. that we sometimes will have
1871 // three in a row. (Lgb)
1875 par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
1878 && par->layout == layout
1879 && par->params().depth() == params().depth());
1881 if (style.isEnvironment()) {
1882 os << "\\end{" << style.latexname() << "}\n";
1886 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
1887 return par; // ale970302
1891 bool Paragraph::isHfill(pos_type pos) const
1893 return IsHfillChar(getChar(pos));
1897 bool Paragraph::isInset(pos_type pos) const
1899 return IsInsetChar(getChar(pos));
1903 bool Paragraph::isNewline(pos_type pos) const
1905 return pos >= 0 && IsNewlineChar(getChar(pos));
1909 bool Paragraph::isSeparator(pos_type pos) const
1911 return IsSeparatorChar(getChar(pos));
1915 bool Paragraph::isLineSeparator(pos_type pos) const
1917 value_type const c = getChar(pos);
1918 return IsLineSeparatorChar(c)
1919 || (IsInsetChar(c) && getInset(pos)->isLineSeparator());
1923 bool Paragraph::isKomma(pos_type pos) const
1925 return IsKommaChar(getChar(pos));
1929 /// Used by the spellchecker
1930 bool Paragraph::isLetter(pos_type pos) const
1932 value_type const c = getChar(pos);
1933 if (IsLetterChar(c))
1936 return getInset(pos)->isLetter();
1937 // We want to pass the ' and escape chars to ispell
1938 string const extra = lyxrc.isp_esc_chars + '\'';
1939 return contains(extra, c);
1943 bool Paragraph::isWord(pos_type pos) const
1945 return IsWordChar(getChar(pos)) ;
1950 Paragraph::getParLanguage(BufferParams const & bparams) const
1953 #ifndef INHERIT_LANGUAGE
1954 return getFirstFontSettings().language();
1956 Language const * lang = getFirstFontSettings().language();
1957 #ifdef WITH_WARNINGS
1958 #warning We should make this somewhat better, any ideas? (Jug)
1960 if (lang == inherit_language || lang == ignore_language)
1961 lang = bparams.language;
1964 } else if (previous_)
1965 return previous_->getParLanguage(bparams);
1967 return bparams.language;
1971 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
1973 return lyxrc.rtl_support
1974 && getParLanguage(bparams)->RightToLeft();
1978 void Paragraph::changeLanguage(BufferParams const & bparams,
1979 Language const * from, Language const * to)
1981 for (pos_type i = 0; i < size(); ++i) {
1982 LyXFont font = getFontSettings(bparams, i);
1983 if (font.language() == from) {
1984 font.setLanguage(to);
1991 bool Paragraph::isMultiLingual(BufferParams const & bparams)
1993 Language const * doc_language = bparams.language;
1994 for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
1995 cit != pimpl_->fontlist.end(); ++cit)
1996 if (cit->font().language() != ignore_language &&
1997 cit->font().language() != latex_language &&
1998 #ifdef INHERIT_LANGUAGE
1999 cit->font().language() != inherit_language &&
2001 cit->font().language() != doc_language)
2007 // Convert the paragraph to a string.
2008 // Used for building the table of contents
2009 string const Paragraph::asString(Buffer const * buffer, bool label)
2011 BufferParams const & bparams = buffer->params;
2013 if (label && !params().labelString().empty())
2014 s += params().labelString() + ' ';
2015 string::size_type const len = s.size();
2017 for (pos_type i = 0; i < size(); ++i) {
2018 value_type c = getChar(i);
2021 else if (c == META_INSET &&
2022 getInset(i)->lyxCode() == Inset::MATH_CODE) {
2024 getInset(i)->ascii(buffer, ost);
2025 s += subst(ost.str().c_str(),'\n',' ');
2029 if (isRightToLeftPar(bparams))
2030 reverse(s.begin() + len,s.end());
2036 string const Paragraph::asString(Buffer const * buffer,
2037 pos_type beg, pos_type end, bool label)
2041 if (beg == 0 && label && !params().labelString().empty())
2042 ost << params().labelString() << ' ';
2044 for (pos_type i = beg; i < end; ++i) {
2045 value_type const c = getUChar(buffer->params, i);
2048 else if (c == META_NEWLINE)
2050 else if (c == META_HFILL)
2052 else if (c == META_INSET) {
2053 getInset(i)->ascii(buffer, ost);
2057 return ost.str().c_str();
2061 void Paragraph::setInsetOwner(Inset * i)
2063 pimpl_->inset_owner = i;
2064 for (InsetList::const_iterator cit = insetlist.begin();
2065 cit != insetlist.end(); ++cit) {
2067 cit->inset->setOwner(i);
2072 void Paragraph::deleteInsetsLyXText(BufferView * bv)
2075 for (InsetList::const_iterator cit = insetlist.begin();
2076 cit != insetlist.end(); ++cit) {
2078 if (cit->inset->isTextInset()) {
2079 static_cast<UpdatableInset *>
2080 (cit->inset)->deleteLyXText(bv, true);
2087 void Paragraph::resizeInsetsLyXText(BufferView * bv)
2090 for (InsetList::const_iterator cit = insetlist.begin();
2091 cit != insetlist.end(); ++cit)
2094 if (cit->inset->isTextInset()) {
2095 static_cast<UpdatableInset *>
2096 (cit->inset)->resizeLyXText(bv, true);
2103 void Paragraph::setContentsFromPar(Paragraph * par)
2105 pimpl_->setContentsFromPar(par);
2109 lyx::pos_type Paragraph::size() const
2111 return pimpl_->size();
2115 Paragraph::value_type Paragraph::getChar(pos_type pos) const
2117 return pimpl_->getChar(pos);
2121 int Paragraph::id() const
2127 void Paragraph::id(int id_arg)
2129 pimpl_->id_ = id_arg;
2133 layout_type Paragraph::getLayout() const
2139 bool Paragraph::isFirstInSequence() const
2141 Paragraph const * dhook = depthHook(getDepth());
2142 return (dhook == this
2143 || dhook->getLayout() != getLayout()
2144 || dhook->getDepth() != getDepth());
2148 Inset * Paragraph::inInset() const
2150 return pimpl_->inset_owner;
2154 void Paragraph::clearContents()
2160 void Paragraph::setCounter(int i, int v)
2162 pimpl_->counter_[i] = v;
2166 int Paragraph::getCounter(int i) const
2168 return pimpl_->counter_[i];
2172 void Paragraph::incCounter(int i)
2174 pimpl_->counter_[i]++;
2178 void Paragraph::setChar(pos_type pos, value_type c)
2180 pimpl_->setChar(pos, c);
2184 Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
2189 Paragraph::inset_iterator Paragraph::inset_iterator_begin()
2191 return inset_iterator(insetlist.begin());
2195 Paragraph::inset_iterator Paragraph::inset_iterator_end()
2197 return inset_iterator(insetlist.end());
2201 ParagraphParameters & Paragraph::params()
2203 return pimpl_->params;
2207 ParagraphParameters const & Paragraph::params() const
2209 return pimpl_->params;
2213 Paragraph * Paragraph::getParFromID(int id) const
2215 return pimpl_->getParFromID(id);
2219 bool Paragraph::isFreeSpacing() const
2221 // for now we just need this, later should we need this in some
2222 // other way we can always add a function to Inset::() too.
2223 if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
2224 return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);