return;
}
pos_type endpos = last;
- owner_->locateWord(first, endpos, WHOLE_WORD);
+ owner_->locateWord(first, endpos, WHOLE_WORD, true);
if (endpos < last) {
endpos = last;
- owner_->locateWord(last, endpos, WHOLE_WORD);
+ owner_->locateWord(last, endpos, WHOLE_WORD, true);
}
last = endpos;
}
}
-void Paragraph::addChangesToBuffer(Buffer const & buf) const
-{
- d->changes_.updateBuffer(buf);
-}
-
-
-bool Paragraph::isChangeUpdateRequired() const
-{
- return d->changes_.isUpdateRequired();
-}
-
-
bool Paragraph::isDeleted(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), return false);
}
+bool Paragraph::isChanged() const
+{
+ return d->changes_.isChanged();
+}
+
+
bool Paragraph::isMergedOnEndOfParDeletion(bool trackChanges) const
{
// keep the logic here in sync with the logic of eraseChars()
return change.inserted() && change.currentAuthor();
}
+Change Paragraph::parEndChange() const
+{
+ return d->changes_.lookup(size());
+}
+
void Paragraph::setChange(Change const & change)
{
// see comment in setChange(Change const &) above
if (!change.deleted() && pos < size())
- if (Inset * inset = getInset(pos))
- inset->setChange(change);
+ if (Inset * inset = getInset(pos))
+ inset->setChange(change);
}
Change const & change = runparams.inDeletedInset
? runparams.changeOfDeletedInset : lookupChange(i);
+ char_type const c = d->text_[i];
+
// Check whether a display math inset follows
- if (d->text_[i] == META_INSET
+ if (c == META_INSET
&& i >= start_pos && (end_pos == -1 || i < end_pos)) {
+ if (isDeleted(i))
+ runparams.ctObject = getInset(i)->CtObject(runparams);
+
InsetMath const * im = getInset(i)->asInsetMath();
if (im && im->asHullInset()
&& im->asHullInset()->outerDisplay()) {
basefont, needPar);
open_font = false;
}
- basefont = getLayoutFont(bparams, outerfont);
+ basefont = (body_pos > i) ? getLabelFont(bparams, outerfont)
+ : getLayoutFont(bparams, outerfont);
running_font = basefont;
column += Changes::latexMarkChange(os, bparams,
Change(Change::INSERTED), change, rp);
basefont, basefont, needPar);
open_font = false;
}
- basefont = getLayoutFont(bparams, outerfont);
+ basefont = (body_pos > i) ? getLabelFont(bparams, outerfont)
+ : getLayoutFont(bparams, outerfont);
running_font = basefont;
column += Changes::latexMarkChange(os, bparams, runningChange,
change, runparams);
}
}
- char_type const c = d->text_[i];
-
// A display math inset inside an ulem command will be output
// as a box of width \linewidth, so we have to either disable
// indentation if the inset starts a paragraph, or start a new
current_font.language() != running_font.language()) &&
i != body_pos - 1)
{
+ bool const in_ct_deletion = (bparams.output_changes
+ && runningChange == change
+ && change.type == Change::DELETED
+ && !os.afterParbreak());
+ if (in_ct_deletion) {
+ // We have to close and then reopen \lyxdeleted,
+ // as strikeout needs to be on lowest level.
+ bool needPar = false;
+ OutputParams rp = runparams;
+ column += running_font.latexWriteEndChanges(
+ os, bparams, rp, basefont,
+ basefont, needPar);
+ os << '}';
+ column += 1;
+ }
odocstringstream ods;
column += current_font.latexWriteStartChanges(ods, bparams,
runparams, basefont,
<< from_ascii("{}");
else
os << fontchange;
+ if (in_ct_deletion) {
+ // We have to close and then reopen \lyxdeleted,
+ // as strikeout needs to be on lowest level.
+ OutputParams rp = runparams;
+ column += Changes::latexMarkChange(os, bparams,
+ Change(Change::UNCHANGED), change, rp);
+ }
}
// FIXME: think about end_pos implementation...
runningChange, style, i, column);
if (incremented)
--parInline;
+
+ if (runparams.ctObject == OutputParams::CT_DISPLAYOBJECT
+ || runparams.ctObject == OutputParams::CT_UDISPLAYOBJECT) {
+ // Close \lyx*deleted and force its
+ // reopening (if needed)
+ os << '}';
+ column++;
+ runningChange = Change(Change::UNCHANGED);
+ runparams.ctObject = OutputParams::CT_NORMAL;
+ }
}
} else if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
if (!bparams.useNonTeXFonts)
runparams.post_macro = rp.post_macro;
}
- // Close wrapper for alien script
+ // Close wrapper for alien script
if (!alien_script.empty()) {
os << "}";
alien_script.clear();
}
-bool Paragraph::isWordSeparator(pos_type pos) const
+bool Paragraph::isWordSeparator(pos_type pos, bool const ignore_deleted) const
{
if (pos == size())
return true;
+ if (ignore_deleted && isDeleted(pos))
+ return false;
if (Inset const * inset = getInset(pos))
return !inset->isLetter();
// if we have a hard hyphen (no en- or emdash) or apostrophe
void Paragraph::locateWord(pos_type & from, pos_type & to,
- word_location const loc) const
+ word_location const loc, bool const ignore_deleted) const
{
switch (loc) {
case WHOLE_WORD_STRICT:
if (from == 0 || from == size()
- || isWordSeparator(from)
- || isWordSeparator(from - 1)) {
+ || isWordSeparator(from, ignore_deleted)
+ || isWordSeparator(from - 1, ignore_deleted)) {
to = from;
return;
}
case WHOLE_WORD:
// If we are already at the beginning of a word, do nothing
- if (!from || isWordSeparator(from - 1))
+ if (!from || isWordSeparator(from - 1, ignore_deleted))
break;
// fall through
case PREVIOUS_WORD:
// always move the cursor to the beginning of previous word
- while (from && !isWordSeparator(from - 1))
+ while (from && !isWordSeparator(from - 1, ignore_deleted))
--from;
break;
case NEXT_WORD:
break;
}
to = from;
- while (to < size() && !isWordSeparator(to))
+ while (to < size() && !isWordSeparator(to, ignore_deleted))
++to;
}
if (!d->layout_->spellcheck || !inInset().allowSpellCheck())
return result;
- locateWord(from, to, WHOLE_WORD);
+ locateWord(from, to, WHOLE_WORD, true);
if (from == to || from >= size())
return result;