#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_;
}
}
- 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).deleted()) {
+ if (owner_->isDeleted(i)) {
if( ++runparams.inDeletedInset == 1)
runparams.changeOfDeletedInset = owner_->lookupChange(i);
}
if (inset->canTrackChanges()) {
column += Changes::latexMarkChange(os, bparams, running_change,
- Change(Change::UNCHANGED));
+ Change(Change::UNCHANGED), runparams);
running_change = Change(Change::UNCHANGED);
}
column += os.tellp() - len;
}
- if (owner_->lookupChange(i).deleted())
+ if (owner_->isDeleted(i))
--runparams.inDeletedInset;
}
}
+namespace {
+
+// this shall be called just before every "os << ..." action.
+void flushString(ostream & os, docstring & s)
+{
+ os << to_utf8(s);
+ s.erase();
+}
+
+}
+
+
void Paragraph::write(ostream & os, BufferParams const & bparams,
depth_type & dth) const
{
Change running_change = Change(Change::UNCHANGED);
+ // this string is used as a buffer to avoid repetitive calls
+ // to to_utf8(), which turn out to be expensive (JMarc)
+ docstring write_buffer;
+
int column = 0;
for (pos_type i = 0; i <= size(); ++i) {
Change const change = lookupChange(i);
+ if (change != running_change)
+ flushString(os, write_buffer);
Changes::lyxMarkChange(os, bparams, column, running_change, change);
running_change = change;
Font font2 = getFontSettings(bparams, i);
font2.setMisspelled(false);
if (font2 != font1) {
+ flushString(os, write_buffer);
font2.lyxWriteChanges(font1, os);
column = 0;
font1 = font2;
switch (c) {
case META_INSET:
if (Inset const * inset = getInset(i)) {
+ flushString(os, write_buffer);
if (inset->directWrite()) {
// international char, let it write
// code directly so it's shorter in
}
break;
case '\\':
+ flushString(os, write_buffer);
os << "\n\\backslash\n";
column = 0;
break;
case '.':
+ flushString(os, write_buffer);
if (i + 1 < size() && d->text_[i + 1] == ' ') {
os << ".\n";
column = 0;
default:
if ((column > 70 && c == ' ')
|| column > 79) {
+ flushString(os, write_buffer);
os << '\n';
column = 0;
}
// this check is to amend a bug. LyX sometimes
// inserts '\0' this could cause problems.
if (c != '\0')
- os << to_utf8(docstring(1, c));
+ write_buffer.push_back(c);
else
LYXERR0("NUL char in structure.");
++column;
}
}
+ flushString(os, write_buffer);
os << "\n\\end_layout\n";
}
}
-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
running_font = basefont;
column += Changes::latexMarkChange(os, bparams,
- runningChange, Change(Change::UNCHANGED));
+ runningChange, Change(Change::UNCHANGED),
+ runparams);
runningChange = Change(Change::UNCHANGED);
os << "] ";
basefont = getLayoutFont(bparams, outerfont);
running_font = basefont;
- column += Changes::latexMarkChange(os, bparams, runningChange, change);
+ column += Changes::latexMarkChange(os, bparams, runningChange,
+ change, runparams);
runningChange = change;
}
#endif
}
- column += Changes::latexMarkChange(os, bparams, runningChange, Change(Change::UNCHANGED));
+ column += Changes::latexMarkChange(os, bparams, runningChange,
+ Change(Change::UNCHANGED), runparams);
// Needed if there is an optional argument but no contents.
if (body_pos > 0 && body_pos == size()) {
return_value = false;
}
- if (allowcust && 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);
return return_value;
}
-InsetCode Paragraph::ownerCode() const
-{
- return d->inset_owner_ ? d->inset_owner_->lyxCode() : NO_CODE;
-}
-
-
ParagraphParameters & Paragraph::params()
{
return d->params_;
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]);
- }
}
}