3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "rowpainter.h"
17 #include "coordcache.h"
20 #include "bufferparams.h"
21 #include "BufferView.h"
28 #include "lyxrow_funcs.h"
29 #include "metricsinfo.h"
30 #include "paragraph.h"
31 #include "paragraph_funcs.h"
32 #include "ParagraphParameters.h"
35 #include "frontends/font_metrics.h"
36 #include "frontends/nullpainter.h"
37 #include "frontends/Painter.h"
39 #include "insets/insettext.h"
41 #include "support/textutils.h"
54 * A class used for painting an individual row of text.
58 /// initialise and run painter
59 RowPainter(BufferView const & bv, Painter & pain, LyXText const & text,
60 par_type pit, RowList::iterator rit, int y);
62 // paint various parts
63 void paintBackground();
64 void paintSelection();
67 void paintChangeBar();
70 void paintForeignMark(double orig_x, LyXFont const & orig_font);
71 void paintHebrewComposeChar(lyx::pos_type & vpos);
72 void paintArabicComposeChar(lyx::pos_type & vpos);
73 void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
74 int paintAppendixStart(int y);
76 void paintFromPos(lyx::pos_type & vpos);
77 void paintInset(lyx::pos_type const pos);
79 /// return left margin
80 int leftMargin() const;
82 /// return the font at the given pos
83 LyXFont const getFont(lyx::pos_type pos) const;
85 /// return the label font for this row
86 LyXFont const getLabelFont() const;
88 /// return pixel width for the given pos
89 int singleWidth(lyx::pos_type pos) const;
90 int singleWidth(lyx::pos_type pos, char c) const;
92 /// bufferview to paint on
93 BufferView const & bv_;
98 /// LyXText for the row
99 LyXText const & text_;
100 ParagraphList & pars_;
103 RowList::iterator const rit_;
107 mutable par_type pit_;
120 RowPainter::RowPainter(BufferView const & bv, Painter & pain,
121 LyXText const & text, par_type pit, RowList::iterator rit, int y)
122 : bv_(bv), pain_(pain), text_(text), pars_(text.paragraphs()),
123 rit_(rit), row_(*rit), pit_(pit),
124 xo_(text_.xo_), yo_(y), width_(text_.width())
126 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
127 // << " pit->y: " << pit_->y
128 // << " row: " << (pars_[pit_].size() ? pars_[pit_].getChar(row_.pos()) : 'X') << endl;
130 RowMetrics m = text_.computeRowMetrics(pit, row_);
133 separator_ = m.separator;
135 label_hfill_ = m.label_hfill;
137 // background has already been cleared.
138 if (&text_ == bv_.text())
141 // paint the selection background
142 if (bv_.cursor().selection() && &text_ == bv_.cursor().text())
145 // vertical lines for appendix
148 // environment depth brackets
157 if (row_.endpos() >= pars_[pit_].size())
166 LyXFont const RowPainter::getFont(pos_type pos) const
168 return text_.getFont(pit_, pos);
172 int RowPainter::singleWidth(lyx::pos_type pos) const
174 return text_.singleWidth(pit_, pos);
178 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
180 LyXFont const & font = text_.getFont(pit_, pos);
181 return text_.singleWidth(pit_, pos, c, font);
185 LyXFont const RowPainter::getLabelFont() const
187 return text_.getLabelFont(pit_);
191 int RowPainter::leftMargin() const
193 return text_.leftMargin(pit_, row_.pos());
197 void RowPainter::paintInset(pos_type const pos)
199 InsetBase const * inset = pars_[pit_].getInset(pos);
201 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
202 pi.base.font = getFont(pos);
203 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
204 theCoords.insets_.add(inset, int(x_), yo_ + row_.baseline());
205 inset->drawSelection(pi, int(x_), yo_ + row_.baseline());
206 inset->draw(pi, int(x_), yo_ + row_.baseline());
207 x_ += inset->width();
211 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
213 pos_type pos = text_.bidi.vis2log(vpos);
218 char c = pars_[pit_].getChar(pos);
222 LyXFont const & font = getFont(pos);
223 int const width = font_metrics::width(c, font);
226 for (pos_type i = pos - 1; i >= 0; --i) {
227 c = pars_[pit_].getChar(i);
228 if (!Encodings::IsComposeChar_hebrew(c)) {
229 if (IsPrintableNonspace(c)) {
230 int const width2 = singleWidth(i, c);
232 dx = (c == 'ø' || c == 'ã')
234 : (width2 - width) / 2;
241 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
245 void RowPainter::paintArabicComposeChar(pos_type & vpos)
247 pos_type pos = text_.bidi.vis2log(vpos);
251 char c = pars_[pit_].getChar(pos);
252 c = pars_[pit_].transformChar(c, pos);
256 LyXFont const & font = getFont(pos);
257 int const width = font_metrics::width(c, font);
260 for (pos_type i = pos - 1; i >= 0; --i) {
261 c = pars_[pit_].getChar(i);
262 if (!Encodings::IsComposeChar_arabic(c)) {
263 if (IsPrintableNonspace(c)) {
264 int const width2 = singleWidth(i, c);
265 dx = (width2 - width) / 2;
271 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
275 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
277 pos_type pos = text_.bidi.vis2log(vpos);
278 pos_type const end = row_.endpos();
279 LyXFont orig_font = getFont(pos);
283 str += pars_[pit_].getChar(pos);
285 unsigned char c = str[0];
286 str[0] = pars_[pit_].transformChar(c, pos);
289 bool prev_struckout = isDeletedText(pars_[pit_], pos);
290 bool prev_newtext = isInsertedText(pars_[pit_], pos);
292 // collect as much similar chars as we can
293 for (++vpos; vpos < end && (pos = text_.bidi.vis2log(vpos)) >= 0; ++vpos) {
294 char c = pars_[pit_].getChar(pos);
296 if (!IsPrintableNonspace(c))
299 if (prev_struckout != isDeletedText(pars_[pit_], pos))
302 if (prev_newtext != isInsertedText(pars_[pit_], pos))
305 if (arabic && Encodings::IsComposeChar_arabic(c))
308 if (hebrew && Encodings::IsComposeChar_hebrew(c))
311 if (orig_font != getFont(pos))
315 c = pars_[pit_].transformChar(c, pos);
321 orig_font.setColor(LColor::strikeout);
322 else if (prev_newtext)
323 orig_font.setColor(LColor::newtext);
325 // Draw text and set the new x position
326 //lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_.baseline()
328 pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
329 x_ += font_metrics::width(str, orig_font);
333 void RowPainter::paintForeignMark(double orig_x, LyXFont const & orig_font)
335 if (!lyxrc.mark_foreign_language)
337 if (orig_font.language() == latex_language)
339 if (orig_font.language() == bv_.buffer()->params().language)
342 int const y = yo_ + row_.baseline() + 1;
343 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
347 void RowPainter::paintFromPos(pos_type & vpos)
349 pos_type const pos = text_.bidi.vis2log(vpos);
351 LyXFont const & orig_font = getFont(pos);
353 double const orig_x = x_;
355 char const c = pars_[pit_].getChar(pos);
357 if (c == Paragraph::META_INSET) {
360 paintForeignMark(orig_x, orig_font);
364 // usual characters, no insets
366 // special case languages
367 bool const hebrew = (orig_font.language()->lang() == "hebrew");
369 orig_font.language()->lang() == "arabic" &&
370 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
371 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
373 // draw as many chars as we can
374 if ((!hebrew && !arabic)
375 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
376 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
377 paintChars(vpos, hebrew, arabic);
379 paintHebrewComposeChar(vpos);
381 paintArabicComposeChar(vpos);
384 paintForeignMark(orig_x, orig_font);
388 void RowPainter::paintBackground()
390 int const x = int(xo_);
391 int const y = yo_ < 0 ? 0 : yo_;
392 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
393 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
397 void RowPainter::paintSelection()
399 bool const is_rtl = text_.isRTL(pars_[pit_]);
401 // the current selection
402 LCursor const & cur = bv_.cursor();
403 int const starty = text_.cursorY(cur.selBegin());
404 int const endy = text_.cursorY(cur.selEnd());
405 par_type startpit = cur.selBegin().par();
406 par_type endpit = cur.selEnd().par();
407 RowList::iterator startrow = pars_[startpit].getRow(cur.selBegin().pos());
408 RowList::iterator endrow = pars_[endpit].getRow(cur.selEnd().pos());
409 int const h = row_.height();
411 int const row_y = text_.yo_ + pars_[pit_].y + row_.y_offset();
413 bool const sel_starts_here = startpit == pit_ && startrow == rit_;
414 bool const sel_ends_here = endpit == pit_ && endrow == rit_;
415 bool const sel_on_one_row = sel_starts_here && sel_ends_here;
417 if (text_.bidi.same_direction()) {
418 if (sel_on_one_row) {
419 int const startx = text_.cursorX(cur.selBegin());
420 int const endx = text_.cursorX(cur.selEnd());
421 int const x1 = is_rtl ? endx : startx;
422 int const x2 = is_rtl ? startx : endx;
423 pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
424 } else if (sel_starts_here) {
425 int const startx = text_.cursorX(cur.selBegin());
426 int const x1 = is_rtl ? int(xo_) : startx;
427 int const x2 = is_rtl ? startx : int(xo_) + width_;
428 pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
429 } else if (sel_ends_here) {
430 int const endx = text_.cursorX(cur.selEnd());
431 int const x1 = is_rtl ? endx : int(xo_);
432 int const x2 = is_rtl ? int(xo_) + width_ : endx;
433 pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
434 } else if (row_y > starty && row_y < endy) {
435 pain_.fillRectangle(int(xo_), yo_, width_, h, LColor::selection);
440 if ((startpit != pit_ && startrow != rit_ && !is_rtl)
441 || (endpit != pit_ && endrow != rit_ && is_rtl))
442 pain_.fillRectangle(int(xo_), yo_,
443 int(x_), h, LColor::selection);
445 pos_type const body_pos = pars_[pit_].beginOfBody();
446 pos_type const end = row_.endpos();
449 for (pos_type vpos = row_.pos(); vpos < end; ++vpos) {
450 pos_type pos = text_.bidi.vis2log(vpos);
451 double const old_tmpx = tmpx;
452 if (body_pos > 0 && pos == body_pos - 1) {
453 LyXLayout_ptr const & layout = pars_[pit_].layout();
454 LyXFont const lfont = getLabelFont();
456 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
458 if (pars_[pit_].isLineSeparator(body_pos - 1))
459 tmpx -= singleWidth(body_pos - 1);
462 tmpx += singleWidth(pos);
464 if (hfillExpansion(pars_[pit_], row_, pos)) {
468 tmpx += label_hfill_;
470 if (pars_[pit_].isSeparator(pos) && pos >= body_pos)
474 if (((startpit != pit_ && startrow != rit_)
475 || cur.selBegin().pos() <= pos) &&
476 ((endpit != pit_ && endrow != rit_)
477 || pos < cur.selEnd().pos())) {
478 // Here we do not use x_ as xo_ was added to x_.
479 pain_.fillRectangle(int(old_tmpx), yo_,
480 int(tmpx - old_tmpx + 1), h, LColor::selection);
484 if ((startpit != pit_ && startrow != rit_ && is_rtl) ||
485 (endpit != pit_ && endrow != rit_ && !is_rtl)) {
486 pain_.fillRectangle(int(xo_ + tmpx),
487 yo_, int(width_ - tmpx), h, LColor::selection);
492 void RowPainter::paintChangeBar()
494 pos_type const start = row_.pos();
495 pos_type const end = row_.endpos();
497 if (start == end || !pars_[pit_].isChanged(start, end - 1))
500 int const height = text_.isLastRow(pit_, row_)
502 : row_.height() + boost::next(rit_)->top_of_text();
504 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
508 void RowPainter::paintAppendix()
510 if (!pars_[pit_].params().appendix())
515 if (pars_[pit_].params().startOfAppendix())
516 y += 2 * defaultRowHeight();
518 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
519 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
523 void RowPainter::paintDepthBar()
525 Paragraph::depth_type const depth = pars_[pit_].getDepth();
530 Paragraph::depth_type prev_depth = 0;
531 if (!text_.isFirstRow(pit_, row_)) {
532 par_type pit2 = pit_;
535 prev_depth = pars_[pit2].getDepth();
538 Paragraph::depth_type next_depth = 0;
539 if (!text_.isLastRow(pit_, row_)) {
540 par_type pit2 = pit_;
541 if (row_.endpos() >= pars_[pit2].size())
543 next_depth = pars_[pit2].getDepth();
546 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
547 int const w = nestMargin() / 5;
548 int x = int(xo_) + w * i;
549 // only consider the changebar space if we're drawing outermost text
550 if (text_.isMainText())
551 x += changebarMargin();
553 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
555 pain_.line(x, yo_, x, h, LColor::depthbar);
558 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
560 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
565 int RowPainter::paintAppendixStart(int y)
568 pb_font.setColor(LColor::appendix);
571 string const label = _("Appendix");
575 font_metrics::rectText(label, pb_font, w, a, d);
577 int const text_start = int(xo_ + (width_ - w) / 2);
578 int const text_end = text_start + w;
580 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
582 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
583 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
585 return 3 * defaultRowHeight();
589 void RowPainter::paintFirst()
591 ParagraphParameters const & parparams = pars_[pit_].params();
595 // start of appendix?
596 if (parparams.startOfAppendix())
597 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
599 Buffer const & buffer = *bv_.buffer();
601 LyXLayout_ptr const & layout = pars_[pit_].layout();
603 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
605 if (layout->latextype == LATEX_PARAGRAPH
606 && !pars_[pit_].getDepth()) {
607 y_top += buffer.params().getDefSkip().inPixels(bv_);
609 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
610 if (playout->latextype == LATEX_PARAGRAPH
611 && !pars_[pit_ - 1].getDepth()) {
612 // is it right to use defskip here, too? (AS)
613 y_top += buffer.params().getDefSkip().inPixels(bv_);
619 bool const is_rtl = text_.isRTL(pars_[pit_]);
620 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
621 //lyxerr << "paintFirst: " << pars_[pit_].id() << " is_seq: " << is_seq << std::endl;
623 // should we print a label?
624 if (layout->labeltype >= LABEL_STATIC
625 && (layout->labeltype != LABEL_STATIC
626 || layout->latextype != LATEX_ENVIRONMENT
629 LyXFont font = getLabelFont();
630 if (!pars_[pit_].getLabelstring().empty()) {
632 string const str = pars_[pit_].getLabelstring();
634 // this is special code for the chapter layout. This is
635 // printed in an extra row and has a pagebreak at
637 if (layout->counter == "chapter") {
638 if (buffer.params().secnumdepth >= 0) {
639 float spacing_val = 1.0;
640 if (!parparams.spacing().isDefault()) {
641 spacing_val = parparams.spacing().getValue();
643 spacing_val = buffer.params().spacing().getValue();
647 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
648 + int(layout->parsep) * defaultRowHeight();
651 x = width_ - leftMargin() -
652 font_metrics::width(str, font);
656 yo_ + row_.baseline() -
657 row_.ascent_of_text() - maxdesc,
662 x = width_ - leftMargin()
663 + font_metrics::width(layout->labelsep, font);
665 x = x_ - font_metrics::width(layout->labelsep, font)
666 - font_metrics::width(str, font);
669 pain_.text(int(x), yo_ + row_.baseline(), str, font);
673 // the labels at the top of an environment.
674 // More or less for bibliography
676 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
677 layout->labeltype == LABEL_BIBLIO ||
678 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
679 LyXFont font = getLabelFont();
680 if (!pars_[pit_].getLabelstring().empty()) {
681 string const str = pars_[pit_].getLabelstring();
682 float spacing_val = 1.0;
683 if (!parparams.spacing().isDefault()) {
684 spacing_val = parparams.spacing().getValue();
686 spacing_val = buffer.params().spacing().getValue();
690 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
691 + (layout->labelbottomsep * defaultRowHeight()));
694 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
695 x = ((is_rtl ? leftMargin() : x_)
696 + width_ - text_.rightMargin(pars_[pit_])) / 2;
697 x -= font_metrics::width(str, font) / 2;
699 x = width_ - leftMargin() -
700 font_metrics::width(str, font);
703 yo_ + row_.baseline() - row_.ascent_of_text() - maxdesc,
710 void RowPainter::paintLast()
712 bool const is_rtl = text_.isRTL(pars_[pit_]);
713 int const endlabel = getEndLabel(pit_, text_.paragraphs());
718 case END_LABEL_FILLED_BOX: {
719 LyXFont const font = getLabelFont();
720 int const size = int(0.75 * font_metrics::maxAscent(font));
721 int const y = yo_ + row_.baseline() - size;
722 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
724 if (width_ - int(row_.width()) <= size)
725 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
727 if (endlabel == END_LABEL_BOX)
728 pain_.rectangle(x, y, size, size, LColor::eolmarker);
730 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
734 case END_LABEL_STATIC: {
735 LyXFont font = getLabelFont();
736 string const & str = pars_[pit_].layout()->endlabelstring();
737 double const x = is_rtl ?
738 x_ - font_metrics::width(str, font)
739 : - text_.rightMargin(pars_[pit_]) - row_.width();
740 pain_.text(int(x), yo_ + row_.baseline(), str, font);
744 case END_LABEL_NO_LABEL:
750 void RowPainter::paintText()
752 pos_type const end = row_.endpos();
753 pos_type body_pos = pars_[pit_].beginOfBody();
755 (body_pos > end || !pars_[pit_].isLineSeparator(body_pos - 1))) {
759 LyXLayout_ptr const & layout = pars_[pit_].layout();
761 bool running_strikeout = false;
762 bool is_struckout = false;
763 int last_strikeout_x = 0;
765 for (pos_type vpos = row_.pos(); vpos < end; ) {
766 if (x_ > bv_.workWidth())
769 pos_type pos = text_.bidi.vis2log(vpos);
771 if (pos >= pars_[pit_].size()) {
776 if (x_ + singleWidth(pos) < 0) {
777 x_ += singleWidth(pos);
782 is_struckout = isDeletedText(pars_[pit_], pos);
784 if (is_struckout && !running_strikeout) {
785 running_strikeout = true;
786 last_strikeout_x = int(x_);
789 bool const highly_editable_inset = pars_[pit_].isInset(pos)
790 && isHighlyEditableInset(pars_[pit_].getInset(pos));
792 // if we reach the end of a struck out range, paint it
793 // we also don't paint across things like tables
794 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
795 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
796 pain_.line(last_strikeout_x, middle, int(x_), middle,
797 LColor::strikeout, Painter::line_solid, Painter::line_thin);
798 running_strikeout = false;
801 if (body_pos > 0 && pos == body_pos - 1) {
802 int const lwidth = font_metrics::width(layout->labelsep,
805 x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
808 if (pars_[pit_].isHfill(pos)) {
811 int const y0 = yo_ + row_.baseline();
812 int const y1 = y0 - defaultRowHeight() / 2;
814 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
816 if (hfillExpansion(pars_[pit_], row_, pos)) {
817 int const y2 = (y0 + y1) / 2;
819 if (pos >= body_pos) {
820 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
822 Painter::line_onoffdash);
825 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
827 Painter::line_onoffdash);
830 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
834 } else if (pars_[pit_].isSeparator(pos)) {
835 x_ += singleWidth(pos);
844 // if we reach the end of a struck out range, paint it
845 if (running_strikeout) {
846 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
847 pain_.line(last_strikeout_x, middle, int(x_), middle,
848 LColor::strikeout, Painter::line_solid, Painter::line_thin);
849 running_strikeout = false;
854 int paintPars(BufferView const & bv, Painter & pain,
855 LyXText const & text, par_type pit, par_type end)
857 //lyxerr << " paintRows: pit: " << &*pit << endl;
858 ParagraphList & pars = text.paragraphs();
860 int y = pars[pit].y + text.yo_ - bv.top_y();
862 for (; pit != end; ++pit) {
863 RowList::iterator row = pars[pit].rows.begin();
864 RowList::iterator rend = pars[pit].rows.end();
866 // We draw full paragraphs to get the (xo, yo) cache of all
867 // contained insets right. This is needed for properly working
868 // editXY. And maybe not even sufficient.
869 // FIXME: Alfredo, please have a look at the coordinate business
871 for ( ; row != rend; ++row) {
872 RowPainter(bv, pain, text, pit, row, y);
883 void refreshPar(BufferView const & bv, LyXText const & text, par_type pit)
885 static NullPainter nop;
886 paintPars(bv, nop, text, pit, pit + 1);
890 int paintText(BufferView const & bv)
893 getParsInRange(bv.text()->paragraphs(), bv.top_y(),
894 bv.top_y() + bv.workHeight(), pit, end);
895 //lyxerr << "top_y: " << bv.top_y() << " y: " << pit->y << endl;
896 return paintPars(bv, bv.painter(), *bv.text(), pit, end);
900 void paintTextInset(LyXText const & text, PainterInfo & pi)
902 paintPars(*pi.base.bv, pi.pain, text, 0, text.paragraphs().size());