#include "OutputParams.h"
#include "output_latex.h"
#include "output_xhtml.h"
-#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "SpellChecker.h"
#include "sgml.h"
/// match a string against a particular point in the paragraph
bool isTextAt(string const & str, pos_type pos) const;
+
+
+ InsetCode ownerCode() const
+ {
+ return inset_owner_ ? inset_owner_->lyxCode() : NO_CODE;
+ }
/// Which Paragraph owns us?
Paragraph * owner_;
}
-bool Paragraph::isFullyDeleted(pos_type start, pos_type end) const
+bool Paragraph::isDeleted(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), /**/);
LASSERT(end > start && end <= size() + 1, /**/);
- return d->changes_.isFullyDeleted(start, end);
+ return d->changes_.isDeleted(start, end);
}
return true;
Change const change = d->changes_.lookup(size());
- return change.type == Change::INSERTED && change.author == 0;
+ return change.inserted() && change.currentAuthor();
}
* Conclusion: An inset's content should remain untouched if you delete it
*/
- if (change.type != Change::DELETED) {
+ if (!change.deleted()) {
for (pos_type pos = 0; pos < size(); ++pos) {
if (Inset * inset = getInset(pos))
inset->setChange(change);
d->changes_.set(change, pos);
// see comment in setChange(Change const &) above
- if (change.type != Change::DELETED && pos < size())
+ if (!change.deleted() && pos < size())
if (Inset * inset = getInset(pos))
inset->setChange(change);
}
// a) it was previously unchanged or
// b) it was inserted by a co-author
- if (change.type == Change::UNCHANGED ||
- (change.type == Change::INSERTED && change.author != 0)) {
+ if (!change.changed() ||
+ (change.inserted() && !change.currentAuthor())) {
setChange(pos, Change(Change::DELETED));
return false;
}
- if (change.type == Change::DELETED)
+ if (change.deleted())
return false;
}
}
}
- if (lyxrc.plaintext_linelen > 0
- && column > lyxrc.plaintext_linelen
+ if (runparams.linelen > 0
+ && column > runparams.linelen
&& i
&& text_[i - 1] != ' '
&& (i + 1 < int(text_.size()))
column = 0;
}
- if (owner_->lookupChange(i).type == Change::DELETED) {
+ if (owner_->isDeleted(i)) {
if( ++runparams.inDeletedInset == 1)
runparams.changeOfDeletedInset = owner_->lookupChange(i);
}
column += os.tellp() - len;
}
- if (owner_->lookupChange(i).type == Change::DELETED)
+ if (owner_->isDeleted(i))
--runparams.inDeletedInset;
}
for (pos_type i = 0; i <= size(); ++i) {
Change const change = lookupChange(i);
- Changes::lyxMarkChange(os, column, running_change, change);
+ Changes::lyxMarkChange(os, bparams, column, running_change, change);
running_change = change;
if (i == size())
}
-bool Paragraph::forcePlainLayout() const
-{
- return inInset().forcePlainLayout();
-}
-
-
bool Paragraph::allowParagraphCustomization() const
{
return inInset().allowParagraphCustomization();
}
string const begin_tag = "\\begin";
- InsetCode code = owner_->ownerCode();
+ InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
switch (curAlign) {
}
string const end_tag = "\n\\par\\end";
- InsetCode code = owner_->ownerCode();
+ InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
switch (curAlign) {
// FIXME This check should not be needed. Perhaps issue an
// error if it triggers.
- Layout const & style = forcePlainLayout() ?
+ Layout const & style = inInset().forcePlainLayout() ?
bparams.documentClass().plainLayout() : *d->layout_;
// Current base font for all inherited font changes, without any
Change runningChange = Change(Change::UNCHANGED);
+ Encoding const * const prev_encoding = runparams.encoding;
+
texrow.start(id(), 0);
// if the paragraph is empty, the loop will not be entered at all
// do not output text which is marked deleted
// if change tracking output is disabled
- if (!bparams.outputChanges && change.type == Change::DELETED) {
+ if (!bparams.outputChanges && change.deleted()) {
continue;
}
running_font = font;
open_font = true;
docstring fontchange = ods.str();
+ // check whether the fontchange ends with a \\textcolor
+ // modifier and the text starts with a space (bug 4473)
+ docstring const last_modifier = rsplit(fontchange, '\\');
+ if (prefixIs(last_modifier, from_ascii("textcolor")) && c == ' ')
+ os << fontchange << from_ascii("{}");
// check if the fontchange ends with a trailing blank
// (like "\small " (see bug 3382)
- if (suffixIs(fontchange, ' ') && c == ' ')
+ else if (suffixIs(fontchange, ' ') && c == ' ')
os << fontchange.substr(0, fontchange.size() - 1)
<< from_ascii("{}");
else
return_value = false;
}
- if (allowcust) {
- column += d->endTeXParParams(bparams, os, texrow,
- runparams);
+ if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams)
+ && runparams.encoding != prev_encoding) {
+ runparams.encoding = prev_encoding;
+ if (!bparams.useXetex)
+ os << setEncoding(prev_encoding->iconvName());
}
LYXERR(Debug::LATEX, "Paragraph::latex... done " << this);
for (pos_type i = beg; i < end; ++i) {
char_type const c = d->text_[i];
if (isPrintable(c) || c == '\t'
- || (c == '\n' && options & AS_STR_NEWLINES))
+ || (c == '\n' && (options & AS_STR_NEWLINES)))
os.put(c);
- else if (c == META_INSET && options & AS_STR_INSETS)
+ else if (c == META_INSET && (options & AS_STR_INSETS)) {
getInset(i)->tocString(os);
+ if (getInset(i)->asInsetMath())
+ os << " ";
+ }
}
return os.str();
for (pos_type i = beg; i < end; ++i) {
char_type const c = d->text_[i];
if (isPrintable(c) || c == '\t'
- || (c == '\n' && options & AS_STR_NEWLINES))
+ || (c == '\n' && (options & AS_STR_NEWLINES)))
os.put(c);
- else if (c == META_INSET && options & AS_STR_INSETS) {
+ else if (c == META_INSET && (options & AS_STR_INSETS)) {
getInset(i)->plaintext(os, runparams);
}
}
}
-InsetCode Paragraph::ownerCode() const
-{
- return d->inset_owner_ ? d->inset_owner_->lyxCode() : NO_CODE;
-}
-
-
ParagraphParameters & Paragraph::params()
{
return d->params_;
}
-bool Paragraph::isUnchanged(pos_type pos) const
+bool Paragraph::isChanged(pos_type pos) const
{
- return lookupChange(pos).type == Change::UNCHANGED;
+ return lookupChange(pos).changed();
}
bool Paragraph::isInserted(pos_type pos) const
{
- return lookupChange(pos).type == Change::INSERTED;
+ return lookupChange(pos).inserted();
}
bool Paragraph::isDeleted(pos_type pos) const
{
- return lookupChange(pos).type == Change::DELETED;
+ return lookupChange(pos).deleted();
}
void Paragraph::collectWords()
{
pos_type n = size();
- WordLangTuple wl;
- docstring_list suggestions;
for (pos_type pos = 0; pos < n; ++pos) {
if (isWordSeparator(pos))
continue;
docstring word = asString(from, pos, AS_STR_NONE);
d->words_.insert(word);
}
- if (lyxrc.spellcheck_continuously
- && spellCheck(from, pos, wl, suggestions)) {
- for (size_t i = 0; i != suggestions.size(); ++i)
- d->words_.insert(suggestions[i]);
- }
}
}
bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
- docstring_list & suggestions) const
+ docstring_list & suggestions, bool do_suggestion) const
{
SpellChecker * speller = theSpellChecker();
if (!speller)
if (lyxrc.spellcheck_continuously)
d->fontlist_.setMisspelled(from, to, misspelled);
- if (misspelled) {
- while (!(word = speller->nextMiss()).empty())
- suggestions.push_back(word);
- }
+ if (misspelled && do_suggestion)
+ speller->suggest(wl, suggestions);
+ else
+ suggestions.clear();
+
return misspelled;
}
pos_type to = pos;
WordLangTuple wl;
docstring_list suggestions;
- return spellCheck(from, to, wl, suggestions);
+ return spellCheck(from, to, wl, suggestions, false);
}