#include "LyXFunc.h"
#include "LyXRC.h"
#include "Paragraph.h"
-#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "TextClass.h"
#include "TextMetrics.h"
// now, because Inset::getLayout() will return a default-constructed
// InsetLayout, and that e.g. sets the foreground color to red. So we
// need to do some work to make that possible.
- InsetCollapsable const * icp = pars_[pit].inInset().asInsetCollapsable();
+ InsetCollapsable const * icp = owner_->asInsetCollapsable();
if (!icp)
return lf;
FontInfo icf = icp->getLayout().font();
FontInfo font = layout.font;
// Realize with the fonts of lesser depth.
- //font.realize(outerFont(pit, paragraphs()));
+ //font.realize(outerFont(pit));
font.realize(owner_->buffer().params().getFont().fontInfo());
return font;
while (!layoutfont.resolved() &&
tp != pit_type(paragraphs().size()) &&
pars_[tp].getDepth()) {
- tp = outerHook(tp, paragraphs());
+ tp = outerHook(tp);
if (tp != pit_type(paragraphs().size()))
layoutfont.realize(pars_[tp].layout().font);
}
}
+void Text::setLabelWidthStringToSequence(pit_type const par_offset,
+ docstring const & s)
+{
+ pit_type offset = par_offset;
+ // Find first of same layout in sequence
+ while (!isFirstInSequence(offset)) {
+ offset = depthHook(offset, pars_[offset].getDepth());
+ }
+
+ // now apply label width string to every par
+ // in sequence
+ pit_type const end = pars_.size();
+ depth_type const depth = pars_[offset].getDepth();
+ Layout const & layout = pars_[offset].layout();
+ for (pit_type pit = offset; pit != end; ++pit) {
+ while (pars_[pit].getDepth() > depth)
+ ++pit;
+ if (pars_[pit].getDepth() < depth)
+ return;
+ if (pars_[pit].layout() != layout)
+ return;
+ pars_[pit].setLabelWidthString(s);
+ }
+}
+
+
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
{
LASSERT(cur.text(), /**/);
// Do this only once for a selected range of paragraphs
// of the same layout and depth.
if (par.getDepth() != priordepth || par.layout() != priorlayout)
- setLabelWidthStringToSequence(pit, pars_,
- params.labelWidthString());
+ setLabelWidthStringToSequence(pit, params.labelWidthString());
par.params().apply(params, par.layout());
priordepth = par.getDepth();
priorlayout = par.layout();
// Do this only once for a selected range of paragraphs
// of the same layout and depth.
if (par.getDepth() != priordepth || par.layout() != priorlayout)
- setLabelWidthStringToSequence(pit, pars_,
- par.params().labelWidthString());
+ setLabelWidthStringToSequence(pit,
+ par.params().labelWidthString());
par.params().apply(p, par.layout());
priordepth = par.getDepth();
priorlayout = par.layout();
}
-// needed to insert the selection
-void Text::insertStringAsLines(Cursor & cur, docstring const & str)
-{
- cur.buffer()->insertStringAsLines(pars_, cur.pit(), cur.pos(),
- cur.current_font, str, autoBreakRows_);
-}
-
-
-// turn double CR to single CR, others are converted into one
-// blank. Then insertStringAsLines is called
-void Text::insertStringAsParagraphs(Cursor & cur, docstring const & str)
-{
- docstring linestr = str;
- bool newline_inserted = false;
-
- for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
- if (linestr[i] == '\n') {
- if (newline_inserted) {
- // we know that \r will be ignored by
- // insertStringAsLines. Of course, it is a dirty
- // trick, but it works...
- linestr[i - 1] = '\r';
- linestr[i] = '\n';
- } else {
- linestr[i] = ' ';
- newline_inserted = true;
- }
- } else if (isPrintable(linestr[i])) {
- newline_inserted = false;
- }
- }
- insertStringAsLines(cur, linestr);
-}
-
-
bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
bool setfont, bool boundary)
{