2001-06-25 00:06:33 +00:00
|
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
|
* ======================================================
|
|
|
|
|
*
|
2001-06-25 00:06:33 +00:00
|
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2001-06-25 00:06:33 +00:00
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2002-03-21 17:27:08 +00:00
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
*
|
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "paragraph_pimpl.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "debug.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "encoding.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
|
#include "latexrunparams.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-04-14 18:35:29 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "texrow.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2001-07-29 15:34:18 +00:00
|
|
|
|
#include "support/LAssert.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
using namespace lyx::support;
|
2001-11-27 10:34:16 +00:00
|
|
|
|
using lyx::pos_type;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::upper_bound;
|
|
|
|
|
using std::lower_bound;
|
2001-11-27 10:34:16 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// Initialize static member.
|
|
|
|
|
ShareContainer<LyXFont> Paragraph::Pimpl::FontTable::container;
|
2001-11-27 11:57:57 +00:00
|
|
|
|
// Initialization of the counter for the paragraph id's,
|
|
|
|
|
unsigned int Paragraph::Pimpl::paragraph_id = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-11-27 11:57:57 +00:00
|
|
|
|
namespace {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
|
struct special_phrase {
|
|
|
|
|
string phrase;
|
|
|
|
|
string macro;
|
|
|
|
|
bool builtin;
|
|
|
|
|
};
|
2002-08-10 15:21:07 +00:00
|
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
|
special_phrase special_phrases[] = {
|
|
|
|
|
{ "LyX", "\\LyX{}", false },
|
|
|
|
|
{ "TeX", "\\TeX{}", true },
|
|
|
|
|
{ "LaTeX2e", "\\LaTeXe{}", true },
|
|
|
|
|
{ "LaTeX", "\\LaTeX{}", true },
|
|
|
|
|
};
|
|
|
|
|
|
2002-07-20 17:27:03 +00:00
|
|
|
|
size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-27 11:57:57 +00:00
|
|
|
|
} // namespace anon
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
Paragraph::Pimpl::Pimpl(Paragraph * owner)
|
|
|
|
|
: owner_(owner)
|
|
|
|
|
{
|
|
|
|
|
inset_owner = 0;
|
|
|
|
|
id_ = paragraph_id++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-25 08:49:48 +00:00
|
|
|
|
Paragraph::Pimpl::Pimpl(Pimpl const & p, Paragraph * owner)
|
2001-06-29 09:58:56 +00:00
|
|
|
|
: params(p.params), owner_(owner)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
|
|
|
|
inset_owner = p.inset_owner;
|
|
|
|
|
text = p.text;
|
|
|
|
|
fontlist = p.fontlist;
|
2003-05-25 08:49:48 +00:00
|
|
|
|
id_ = paragraph_id++;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
if (p.tracking())
|
|
|
|
|
changes_.reset(new Changes(*p.changes_.get()));
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::clear()
|
|
|
|
|
{
|
|
|
|
|
text.clear();
|
2003-03-03 21:15:49 +00:00
|
|
|
|
#warning changes ?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-29 10:39:08 +00:00
|
|
|
|
void Paragraph::Pimpl::setContentsFromPar(Paragraph const & par)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-04-29 10:39:08 +00:00
|
|
|
|
text = par.pimpl_->text;
|
|
|
|
|
if (par.pimpl_->tracking()) {
|
|
|
|
|
changes_.reset(new Changes(*(par.pimpl_->changes_.get())));
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::trackChanges(Change::Type type)
|
|
|
|
|
{
|
|
|
|
|
if (tracking()) {
|
|
|
|
|
lyxerr[Debug::CHANGES] << "already tracking for par " << id_ << endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
lyxerr[Debug::CHANGES] << "track changes for par "
|
|
|
|
|
<< id_ << " type " << type << endl;
|
|
|
|
|
changes_.reset(new Changes(type));
|
|
|
|
|
changes_->set(type, 0, size());
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::untrackChanges()
|
|
|
|
|
{
|
|
|
|
|
changes_.reset(0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::cleanChanges()
|
|
|
|
|
{
|
|
|
|
|
// if we're not tracking, we don't want to reset...
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
changes_.reset(new Changes(Change::INSERTED));
|
|
|
|
|
changes_->set(Change::INSERTED, 0, size());
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return changes_->isChange(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Paragraph::Pimpl::isChangeEdited(pos_type start, pos_type end) const
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return changes_->isChangeEdited(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::setChange(pos_type pos, Change::Type type)
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
changes_->set(type, pos);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type Paragraph::Pimpl::lookupChange(pos_type pos) const
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return Change::UNCHANGED;
|
|
|
|
|
|
|
|
|
|
return changes_->lookup(pos);
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return Change(Change::UNCHANGED);
|
|
|
|
|
|
|
|
|
|
return changes_->lookupFull(pos);
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::markErased()
|
|
|
|
|
{
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(tracking());
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
// FIXME: we should actually remove INSERTED chars.
|
|
|
|
|
// difficult because owning insettexts/tabulars need
|
|
|
|
|
// to update themselves when rows etc. change
|
|
|
|
|
changes_->set(Change::DELETED, 0, size());
|
|
|
|
|
changes_->reset(Change::DELETED);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (!size()) {
|
|
|
|
|
changes_.reset(new Changes(Change::UNCHANGED));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
|
|
|
|
lyxerr << "acceptchange" << endl;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
pos_type i = start;
|
|
|
|
|
|
|
|
|
|
for (; i < end; ++i) {
|
|
|
|
|
switch (lookupChange(i)) {
|
|
|
|
|
case Change::UNCHANGED:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Change::INSERTED:
|
|
|
|
|
changes_->set(Change::UNCHANGED, i);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Change::DELETED:
|
|
|
|
|
eraseIntern(i);
|
|
|
|
|
changes_->erase(i);
|
|
|
|
|
--end;
|
|
|
|
|
--i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
lyxerr << "endacceptchange" << endl;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
changes_->reset(Change::UNCHANGED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
|
|
|
|
|
{
|
|
|
|
|
if (!tracking())
|
|
|
|
|
return;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (!size()) {
|
|
|
|
|
changes_.reset(new Changes(Change::UNCHANGED));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
pos_type i = start;
|
|
|
|
|
|
|
|
|
|
for (; i < end; ++i) {
|
|
|
|
|
switch (lookupChange(i)) {
|
|
|
|
|
case Change::UNCHANGED:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Change::INSERTED:
|
|
|
|
|
eraseIntern(i);
|
|
|
|
|
changes_->erase(i);
|
|
|
|
|
--end;
|
|
|
|
|
--i;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Change::DELETED:
|
|
|
|
|
changes_->set(Change::UNCHANGED, i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
changes_->reset(Change::UNCHANGED);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-04-03 00:36:31 +00:00
|
|
|
|
#if 1
|
2003-03-13 10:30:28 +00:00
|
|
|
|
// This is in the critical path for loading!
|
|
|
|
|
pos_type const siz = size();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(pos <= siz);
|
2003-03-18 23:23:28 +00:00
|
|
|
|
|
2003-03-13 17:50:39 +00:00
|
|
|
|
if (pos == siz) {
|
2003-03-12 18:06:49 +00:00
|
|
|
|
lyxerr << "getChar() on pos " << pos << " in par id "
|
2003-03-18 23:23:28 +00:00
|
|
|
|
<< owner_->id() << " of size " << siz
|
|
|
|
|
<< " is a bit silly !" << endl;
|
2002-05-29 14:58:21 +00:00
|
|
|
|
return '\0';
|
2003-03-12 18:06:49 +00:00
|
|
|
|
}
|
2003-03-18 23:23:28 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return text[pos];
|
2003-03-18 23:23:28 +00:00
|
|
|
|
#else
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(pos < size());
|
2003-03-18 23:23:28 +00:00
|
|
|
|
return text[pos];
|
|
|
|
|
#endif
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::Pimpl::setChar(pos_type pos, value_type c)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#warning changes
|
2001-06-25 00:06:33 +00:00
|
|
|
|
text[pos] = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::Pimpl::insertChar(pos_type pos, value_type c,
|
2003-02-08 19:18:01 +00:00
|
|
|
|
LyXFont const & font, Change change)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(pos <= size());
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (tracking()) {
|
|
|
|
|
changes_->record(change, pos);
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-29 14:32:11 +00:00
|
|
|
|
// This is actually very common when parsing buffers (and
|
|
|
|
|
// maybe inserting ascii text)
|
|
|
|
|
if (pos == size()) {
|
|
|
|
|
// when appending characters, no need to update tables
|
|
|
|
|
text.push_back(c);
|
|
|
|
|
owner_->setFont(pos, font);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
text.insert(text.begin() + pos, c);
|
|
|
|
|
|
|
|
|
|
// Update the font table.
|
|
|
|
|
FontTable search_font(pos, LyXFont());
|
2002-02-16 15:59:55 +00:00
|
|
|
|
for (FontList::iterator it = lower_bound(fontlist.begin(),
|
2002-03-21 17:27:08 +00:00
|
|
|
|
fontlist.end(),
|
|
|
|
|
search_font, matchFT());
|
2001-06-25 00:06:33 +00:00
|
|
|
|
it != fontlist.end(); ++it)
|
2001-10-19 15:40:01 +00:00
|
|
|
|
{
|
2001-07-12 11:11:10 +00:00
|
|
|
|
it->pos(it->pos() + 1);
|
2001-10-19 15:40:01 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
|
// Update the insets
|
|
|
|
|
owner_->insetlist.increasePosAfterPos(pos);
|
2002-08-20 21:50:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
owner_->setFont(pos, font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::Pimpl::insertInset(pos_type pos,
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Inset * inset, LyXFont const & font, Change change)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(inset);
|
|
|
|
|
Assert(pos <= size());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
insertChar(pos, META_INSET, font, change);
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(text[pos] == META_INSET);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
|
// Add a new entry in the insetlist.
|
|
|
|
|
owner_->insetlist.insert(inset, pos);
|
|
|
|
|
inset->parOwner(owner_);
|
2002-08-20 21:50:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (inset_owner)
|
|
|
|
|
inset->setOwner(inset_owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::Pimpl::eraseIntern(pos_type pos)
|
|
|
|
|
{
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// if it is an inset, delete the inset entry
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (text[pos] == Paragraph::META_INSET) {
|
2002-08-11 15:03:52 +00:00
|
|
|
|
owner_->insetlist.erase(pos);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
text.erase(text.begin() + pos);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// Erase entries in the tables.
|
|
|
|
|
FontTable search_font(pos, LyXFont());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
FontList::iterator it =
|
2002-02-16 15:59:55 +00:00
|
|
|
|
lower_bound(fontlist.begin(),
|
2001-06-25 00:06:33 +00:00
|
|
|
|
fontlist.end(),
|
|
|
|
|
search_font, matchFT());
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (it != fontlist.end() && it->pos() == pos &&
|
2002-03-21 17:27:08 +00:00
|
|
|
|
(pos == 0 ||
|
|
|
|
|
(it != fontlist.begin()
|
2001-07-12 11:11:10 +00:00
|
|
|
|
&& boost::prior(it)->pos() == pos - 1))) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// If it is a multi-character font
|
|
|
|
|
// entry, we just make it smaller
|
|
|
|
|
// (see update below), otherwise we
|
|
|
|
|
// should delete it.
|
|
|
|
|
unsigned int const i = it - fontlist.begin();
|
|
|
|
|
fontlist.erase(fontlist.begin() + i);
|
|
|
|
|
it = fontlist.begin() + i;
|
|
|
|
|
if (i > 0 && i < fontlist.size() &&
|
|
|
|
|
fontlist[i - 1].font() == fontlist[i].font()) {
|
|
|
|
|
fontlist.erase(fontlist.begin() + i - 1);
|
|
|
|
|
it = fontlist.begin() + i - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// Update all other entries.
|
|
|
|
|
FontList::iterator fend = fontlist.end();
|
|
|
|
|
for (; it != fend; ++it)
|
2001-07-12 11:11:10 +00:00
|
|
|
|
it->pos(it->pos() - 1);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
|
// Update the insetlist.
|
|
|
|
|
owner_->insetlist.decreasePosAfterPos(pos);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-01 09:15:15 +00:00
|
|
|
|
bool Paragraph::Pimpl::erase(pos_type pos)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
2003-06-30 23:56:22 +00:00
|
|
|
|
Assert(pos < size());
|
2003-05-01 09:15:15 +00:00
|
|
|
|
|
|
|
|
|
if (tracking()) {
|
|
|
|
|
Change::Type changetype(changes_->lookup(pos));
|
|
|
|
|
changes_->record(Change(Change::DELETED), pos);
|
|
|
|
|
|
|
|
|
|
// only allow the actual removal if it was /new/ text
|
|
|
|
|
if (changetype != Change::INSERTED) {
|
|
|
|
|
if (text[pos] == Paragraph::META_INSET) {
|
|
|
|
|
Inset * i(owner_->getInset(pos));
|
|
|
|
|
i->markErased();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eraseIntern(pos);
|
|
|
|
|
return true;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-04-29 09:40:49 +00:00
|
|
|
|
int Paragraph::Pimpl::erase(pos_type start, pos_type end)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
pos_type i = start;
|
|
|
|
|
pos_type count = end - start;
|
|
|
|
|
while (count) {
|
2003-05-01 09:15:15 +00:00
|
|
|
|
if (!erase(i)) {
|
2003-02-08 19:18:01 +00:00
|
|
|
|
++i;
|
2003-05-01 09:15:15 +00:00
|
|
|
|
}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
--count;
|
|
|
|
|
}
|
2003-04-29 09:40:49 +00:00
|
|
|
|
return end - i;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
pos_type const i,
|
2003-01-08 09:03:32 +00:00
|
|
|
|
unsigned int & column,
|
|
|
|
|
LyXFont const & font,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXLayout const & style)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-03-15 15:56:07 +00:00
|
|
|
|
if (style.pass_thru)
|
|
|
|
|
return;
|
|
|
|
|
|
2002-08-09 00:42:12 +00:00
|
|
|
|
if (column > lyxrc.ascii_linelen
|
2002-03-21 17:27:08 +00:00
|
|
|
|
&& i
|
2001-07-06 19:56:32 +00:00
|
|
|
|
&& getChar(i - 1) != ' '
|
|
|
|
|
&& (i < size() - 1)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// same in FreeSpacing mode
|
2003-06-07 17:45:43 +00:00
|
|
|
|
&& !owner_->isFreeSpacing()
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// In typewriter mode, we want to avoid
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// ! . ? : at the end of a line
|
|
|
|
|
&& !(font.family() == LyXFont::TYPEWRITER_FAMILY
|
2001-07-06 19:56:32 +00:00
|
|
|
|
&& (getChar(i - 1) == '.'
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|| getChar(i - 1) == '?'
|
2001-07-06 19:56:32 +00:00
|
|
|
|
|| getChar(i - 1) == ':'
|
|
|
|
|
|| getChar(i - 1) == '!'))) {
|
2002-08-09 00:42:12 +00:00
|
|
|
|
os << '\n';
|
2001-06-25 00:06:33 +00:00
|
|
|
|
texrow.newline();
|
2003-05-07 21:27:29 +00:00
|
|
|
|
texrow.start(owner_->id(), i + 1);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
column = 0;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
} else if (style.free_spacing) {
|
|
|
|
|
os << '~';
|
|
|
|
|
} else {
|
|
|
|
|
os << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
|
bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos) const
|
2001-11-23 09:59:01 +00:00
|
|
|
|
{
|
2002-05-29 22:07:59 +00:00
|
|
|
|
pos_type const len = str.length();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-05-29 22:07:59 +00:00
|
|
|
|
// is the paragraph large enough?
|
|
|
|
|
if (pos + len > size())
|
|
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-05-29 22:07:59 +00:00
|
|
|
|
// does the wanted text start at point?
|
2001-11-27 11:57:57 +00:00
|
|
|
|
for (string::size_type i = 0; i < str.length(); ++i) {
|
2002-05-29 22:07:59 +00:00
|
|
|
|
if (str[i] != text[pos + i])
|
2001-11-27 11:57:57 +00:00
|
|
|
|
return false;
|
2001-11-23 09:59:01 +00:00
|
|
|
|
}
|
2002-05-29 22:07:59 +00:00
|
|
|
|
|
|
|
|
|
// is there a font change in middle of the word?
|
|
|
|
|
FontList::const_iterator cit = fontlist.begin();
|
|
|
|
|
FontList::const_iterator end = fontlist.end();
|
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
|
if (cit->pos() >= pos)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (cit != end && pos + len - 1 > cit->pos())
|
|
|
|
|
return false;
|
|
|
|
|
|
2001-11-23 09:59:01 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
|
|
|
|
|
BufferParams const & bparams,
|
2002-02-16 15:59:55 +00:00
|
|
|
|
ostream & os,
|
2001-06-27 15:33:55 +00:00
|
|
|
|
TexRow & texrow,
|
2003-05-22 18:59:10 +00:00
|
|
|
|
LatexRunParams const & runparams,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont & font,
|
|
|
|
|
LyXFont & running_font,
|
|
|
|
|
LyXFont & basefont,
|
2003-04-15 00:49:11 +00:00
|
|
|
|
LyXFont const & outerfont,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool & open_font,
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type & running_change,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXLayout const & style,
|
2001-11-26 16:42:04 +00:00
|
|
|
|
pos_type & i,
|
2003-01-08 09:03:32 +00:00
|
|
|
|
unsigned int & column,
|
2001-11-26 16:42:04 +00:00
|
|
|
|
value_type const c)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2001-07-17 09:41:34 +00:00
|
|
|
|
if (style.pass_thru) {
|
2003-03-15 15:56:07 +00:00
|
|
|
|
if (c != Paragraph::META_INSET) {
|
|
|
|
|
if (c != '\0')
|
|
|
|
|
os << c;
|
|
|
|
|
} else {
|
|
|
|
|
Inset const * inset = owner_->getInset(i);
|
|
|
|
|
inset->ascii(buf, os, 0);
|
|
|
|
|
}
|
2001-07-17 09:41:34 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-11 15:01:29 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// Two major modes: LaTeX or plain
|
|
|
|
|
// Handle here those cases common to both modes
|
|
|
|
|
// and then split to handle the two modes separately.
|
|
|
|
|
switch (c) {
|
|
|
|
|
case Paragraph::META_INSET: {
|
|
|
|
|
Inset * inset = owner_->getInset(i);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
// FIXME: remove this check
|
|
|
|
|
if (!inset)
|
|
|
|
|
break;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-03-12 19:16:42 +00:00
|
|
|
|
// FIXME: move this to InsetNewline::latex
|
|
|
|
|
if (inset->lyxCode() == Inset::NEWLINE_CODE) {
|
|
|
|
|
// newlines are handled differently here than
|
|
|
|
|
// the default in simpleTeXSpecialChars().
|
|
|
|
|
if (!style.newline_allowed) {
|
|
|
|
|
os << '\n';
|
|
|
|
|
} else {
|
|
|
|
|
if (open_font) {
|
|
|
|
|
column += running_font.latexWriteEndChanges(os, basefont, basefont);
|
|
|
|
|
open_font = false;
|
|
|
|
|
}
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont = owner_->getLayoutFont(bparams, outerfont);
|
2003-03-12 19:16:42 +00:00
|
|
|
|
running_font = basefont;
|
|
|
|
|
|
|
|
|
|
if (font.family() == LyXFont::TYPEWRITER_FAMILY)
|
|
|
|
|
os << '~';
|
|
|
|
|
|
2003-05-23 09:23:03 +00:00
|
|
|
|
if (runparams.moving_arg)
|
2003-03-12 19:16:42 +00:00
|
|
|
|
os << "\\protect ";
|
|
|
|
|
|
|
|
|
|
os << "\\\\\n";
|
|
|
|
|
}
|
|
|
|
|
texrow.newline();
|
2003-05-07 21:27:29 +00:00
|
|
|
|
texrow.start(owner_->id(), i + 1);
|
2003-03-12 19:16:42 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (inset->isTextInset()) {
|
|
|
|
|
column += Changes::latexMarkChange(os, running_change,
|
|
|
|
|
Change::UNCHANGED);
|
|
|
|
|
running_change = Change::UNCHANGED;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool close = false;
|
|
|
|
|
int const len = os.tellp();
|
|
|
|
|
//ostream::pos_type const len = os.tellp();
|
|
|
|
|
if ((inset->lyxCode() == Inset::GRAPHICS_CODE
|
|
|
|
|
|| inset->lyxCode() == Inset::MATH_CODE
|
|
|
|
|
|| inset->lyxCode() == Inset::URL_CODE)
|
|
|
|
|
&& running_font.isRightToLeft()) {
|
|
|
|
|
os << "\\L{";
|
|
|
|
|
close = true;
|
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-07-23 21:03:38 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
|
#warning Bug: we can have an empty font change here!
|
|
|
|
|
// if there has just been a font change, we are going to close it
|
|
|
|
|
// right now, which means stupid latex code like \textsf{}. AFAIK,
|
|
|
|
|
// this does not harm dvi output. A minor bug, thus (JMarc)
|
|
|
|
|
#endif
|
2003-02-08 19:18:01 +00:00
|
|
|
|
// some insets cannot be inside a font change command
|
|
|
|
|
if (open_font && inset->noFontChange()) {
|
|
|
|
|
column +=running_font.
|
|
|
|
|
latexWriteEndChanges(os,
|
|
|
|
|
basefont,
|
|
|
|
|
basefont);
|
|
|
|
|
open_font = false;
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont = owner_->getLayoutFont(bparams, outerfont);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
running_font = basefont;
|
|
|
|
|
}
|
2002-07-23 21:03:38 +00:00
|
|
|
|
|
2003-05-23 08:59:47 +00:00
|
|
|
|
int tmp = inset->latex(buf, os, runparams);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (close)
|
|
|
|
|
os << '}';
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (tmp) {
|
|
|
|
|
for (int j = 0; j < tmp; ++j) {
|
|
|
|
|
texrow.newline();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
2003-05-07 21:27:29 +00:00
|
|
|
|
texrow.start(owner_->id(), i + 1);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
} else {
|
|
|
|
|
column += int(os.tellp()) - len;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
// And now for the special cases within each mode
|
2001-08-03 18:28:11 +00:00
|
|
|
|
|
|
|
|
|
switch (c) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
case '\\':
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\textbackslash{}";
|
|
|
|
|
column += 15;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-04-22 21:38:53 +00:00
|
|
|
|
case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>':
|
2002-06-24 20:28:12 +00:00
|
|
|
|
case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>':
|
2002-04-22 21:38:53 +00:00
|
|
|
|
case '<EFBFBD>': case '<EFBFBD>':
|
2001-09-27 09:52:06 +00:00
|
|
|
|
if ((bparams.inputenc == "latin1" ||
|
|
|
|
|
bparams.inputenc == "latin9") ||
|
2001-08-03 18:28:11 +00:00
|
|
|
|
(bparams.inputenc == "auto" &&
|
2001-09-27 09:52:06 +00:00
|
|
|
|
(font.language()->encoding()->LatexName()
|
|
|
|
|
== "latin1" ||
|
|
|
|
|
font.language()->encoding()->LatexName()
|
|
|
|
|
== "latin9"))) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\ensuremath{"
|
|
|
|
|
<< c
|
|
|
|
|
<< '}';
|
|
|
|
|
column += 13;
|
|
|
|
|
} else {
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '|': case '<': case '>':
|
|
|
|
|
// In T1 encoding, these characters exist
|
|
|
|
|
if (lyxrc.fontenc == "T1") {
|
|
|
|
|
os << c;
|
|
|
|
|
//... but we should avoid ligatures
|
|
|
|
|
if ((c == '>' || c == '<')
|
|
|
|
|
&& i <= size() - 2
|
|
|
|
|
&& getChar(i + 1) == c) {
|
|
|
|
|
//os << "\\textcompwordmark{}";
|
|
|
|
|
// Jean-Marc, have a look at
|
|
|
|
|
// this. I<>think this works
|
|
|
|
|
// equally well:
|
|
|
|
|
os << "\\,{}";
|
|
|
|
|
// Lgb
|
|
|
|
|
column += 19;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
// Typewriter font also has them
|
|
|
|
|
if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
|
|
|
|
os << c;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
// Otherwise, we use what LaTeX
|
|
|
|
|
// provides us.
|
|
|
|
|
switch (c) {
|
|
|
|
|
case '<':
|
|
|
|
|
os << "\\textless{}";
|
|
|
|
|
column += 10;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
break;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '>':
|
|
|
|
|
os << "\\textgreater{}";
|
|
|
|
|
column += 13;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
break;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '|':
|
|
|
|
|
os << "\\textbar{}";
|
2001-06-25 00:06:33 +00:00
|
|
|
|
column += 9;
|
|
|
|
|
break;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '-': // "--" in Typewriter mode -> "-{}-"
|
|
|
|
|
if (i <= size() - 2
|
|
|
|
|
&& getChar(i + 1) == '-'
|
|
|
|
|
&& font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
|
|
|
|
os << "-{}";
|
2001-06-25 00:06:33 +00:00
|
|
|
|
column += 2;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
} else {
|
|
|
|
|
os << '-';
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
case '\"':
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\char`\\\"{}";
|
|
|
|
|
column += 9;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '<EFBFBD>':
|
|
|
|
|
if (bparams.inputenc == "default") {
|
|
|
|
|
os << "\\pounds{}";
|
|
|
|
|
column += 8;
|
|
|
|
|
} else {
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '$': case '&':
|
|
|
|
|
case '%': case '#': case '{':
|
|
|
|
|
case '}': case '_':
|
|
|
|
|
os << '\\' << c;
|
|
|
|
|
column += 1;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '~':
|
|
|
|
|
os << "\\textasciitilde{}";
|
|
|
|
|
column += 16;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '^':
|
|
|
|
|
os << "\\textasciicircum{}";
|
|
|
|
|
column += 17;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
case '*': case '[': case ']':
|
|
|
|
|
// avoid being mistaken for optional arguments
|
|
|
|
|
os << '{' << c << '}';
|
|
|
|
|
column += 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
|
// Blanks are printed before font switching.
|
|
|
|
|
// Sure? I am not! (try nice-latex)
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// I am sure it's correct. LyX might be smarter
|
|
|
|
|
// in the future, but for now, nothing wrong is
|
|
|
|
|
// written. (Asger)
|
2001-08-03 18:28:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-23 09:59:01 +00:00
|
|
|
|
// I assume this is hack treating typewriter as verbatim
|
|
|
|
|
if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
|
|
|
|
if (c != '\0') {
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-27 11:57:57 +00:00
|
|
|
|
// LyX, LaTeX etc.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
|
// FIXME: if we have "LaTeX" with a font
|
|
|
|
|
// change in the middle (before the 'T', then
|
|
|
|
|
// the "TeX" part is still special cased.
|
|
|
|
|
// Really we should only operate this on
|
|
|
|
|
// "words" for some definition of word
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-27 11:57:57 +00:00
|
|
|
|
size_t pnr = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-11-27 11:57:57 +00:00
|
|
|
|
for (; pnr < phrases_nr; ++pnr) {
|
2002-07-20 16:42:15 +00:00
|
|
|
|
if (isTextAt(special_phrases[pnr].phrase, i)) {
|
|
|
|
|
os << special_phrases[pnr].macro;
|
|
|
|
|
i += special_phrases[pnr].phrase.length() - 1;
|
|
|
|
|
column += special_phrases[pnr].macro.length() - 1;
|
2001-11-27 11:57:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pnr == phrases_nr && c != '\0') {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-20 16:42:15 +00:00
|
|
|
|
void Paragraph::Pimpl::validate(LaTeXFeatures & features,
|
|
|
|
|
LyXLayout const & layout) const
|
|
|
|
|
{
|
|
|
|
|
BufferParams const & bparams = features.bufferParams();
|
|
|
|
|
|
|
|
|
|
// check the params.
|
|
|
|
|
if (params.lineTop() || params.lineBottom())
|
|
|
|
|
features.require("lyxline");
|
|
|
|
|
if (!params.spacing().isDefault())
|
|
|
|
|
features.require("setspace");
|
|
|
|
|
|
|
|
|
|
// then the layouts
|
|
|
|
|
features.useLayout(layout.name());
|
|
|
|
|
|
|
|
|
|
// then the fonts
|
|
|
|
|
Language const * doc_language = bparams.language;
|
|
|
|
|
|
|
|
|
|
FontList::const_iterator fcit = fontlist.begin();
|
|
|
|
|
FontList::const_iterator fend = fontlist.end();
|
|
|
|
|
for (; fcit != fend; ++fcit) {
|
|
|
|
|
if (fcit->font().noun() == LyXFont::ON) {
|
|
|
|
|
lyxerr[Debug::LATEX] << "font.noun: "
|
|
|
|
|
<< fcit->font().noun()
|
|
|
|
|
<< endl;
|
|
|
|
|
features.require("noun");
|
|
|
|
|
lyxerr[Debug::LATEX] << "Noun enabled. Font: "
|
|
|
|
|
<< fcit->font().stateText(0)
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
switch (fcit->font().color()) {
|
|
|
|
|
case LColor::none:
|
|
|
|
|
case LColor::inherit:
|
|
|
|
|
case LColor::ignore:
|
|
|
|
|
// probably we should put here all interface colors used for
|
|
|
|
|
// font displaying! For now I just add this ones I know of (Jug)
|
|
|
|
|
case LColor::latex:
|
|
|
|
|
case LColor::note:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
features.require("color");
|
|
|
|
|
lyxerr[Debug::LATEX] << "Color enabled. Font: "
|
|
|
|
|
<< fcit->font().stateText(0)
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Language const * language = fcit->font().language();
|
|
|
|
|
if (language->babel() != doc_language->babel() &&
|
|
|
|
|
language != ignore_language &&
|
|
|
|
|
language != latex_language)
|
|
|
|
|
{
|
|
|
|
|
features.useLanguage(language);
|
|
|
|
|
lyxerr[Debug::LATEX] << "Found language "
|
|
|
|
|
<< language->babel() << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!params.leftIndent().zero())
|
|
|
|
|
features.require("ParagraphLeftIndent");
|
|
|
|
|
|
|
|
|
|
// then the insets
|
2002-08-11 15:03:52 +00:00
|
|
|
|
InsetList::iterator icit = owner_->insetlist.begin();
|
|
|
|
|
InsetList::iterator iend = owner_->insetlist.end();
|
2002-07-20 16:42:15 +00:00
|
|
|
|
for (; icit != iend; ++icit) {
|
2003-05-29 01:13:18 +00:00
|
|
|
|
if (icit->inset) {
|
|
|
|
|
icit->inset->validate(features);
|
2002-07-20 16:42:15 +00:00
|
|
|
|
if (layout.needprotect &&
|
2003-05-29 01:13:18 +00:00
|
|
|
|
icit->inset->lyxCode() == Inset::FOOT_CODE)
|
2002-07-20 16:42:15 +00:00
|
|
|
|
features.require("NeedLyXFootnoteCode");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// then the contents
|
|
|
|
|
for (pos_type i = 0; i < size() ; ++i) {
|
|
|
|
|
for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
|
|
|
|
|
if (!special_phrases[pnr].builtin
|
|
|
|
|
&& isTextAt(special_phrases[pnr].phrase, i)) {
|
|
|
|
|
features.require(special_phrases[pnr].phrase);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-10 15:21:07 +00:00
|
|
|
|
}
|
2002-07-20 16:42:15 +00:00
|
|
|
|
}
|