2001-06-25 00:06:33 +00:00
|
|
|
|
/* This file is part of
|
|
|
|
|
* ======================================================
|
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
|
|
|
|
*
|
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "paragraph_pimpl.h"
|
|
|
|
|
#include "texrow.h"
|
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
#include "encoding.h"
|
|
|
|
|
#include "lyxrc.h"
|
|
|
|
|
#include "debug.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
|
#include "support/LAssert.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
extern int tex_code_break_column;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialization of the counter for the paragraph id's,
|
|
|
|
|
unsigned int Paragraph::Pimpl::paragraph_id = 0;
|
|
|
|
|
|
|
|
|
|
// Initialize static member.
|
|
|
|
|
ShareContainer<LyXFont> Paragraph::Pimpl::FontTable::container;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph::Pimpl::Pimpl(Paragraph * owner)
|
|
|
|
|
: owner_(owner)
|
|
|
|
|
{
|
|
|
|
|
inset_owner = 0;
|
|
|
|
|
id_ = paragraph_id++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner,
|
|
|
|
|
bool same_ids)
|
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;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
if (same_ids)
|
|
|
|
|
id_ = p.id_;
|
|
|
|
|
else
|
|
|
|
|
id_ = paragraph_id++;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::clear()
|
|
|
|
|
{
|
|
|
|
|
text.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::setContentsFromPar(Paragraph const * par)
|
|
|
|
|
{
|
|
|
|
|
lyx::Assert(par);
|
|
|
|
|
text = par->pimpl_->text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph::value_type
|
|
|
|
|
Paragraph::Pimpl::getChar(Paragraph::size_type pos) const
|
|
|
|
|
{
|
|
|
|
|
lyx::Assert(pos <= size());
|
|
|
|
|
// This is stronger, and I belive that this is the assertion
|
|
|
|
|
// that we should really use. (Lgb)
|
|
|
|
|
//Assert(pos < size());
|
|
|
|
|
|
|
|
|
|
// Then this has no meaning. (Lgb)
|
|
|
|
|
if (!size() || pos == size()) return '\0';
|
|
|
|
|
|
|
|
|
|
return text[pos];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
|
2001-10-19 15:40:01 +00:00
|
|
|
|
Paragraph::value_type c)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
|
|
|
|
text[pos] = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
|
2001-10-19 15:40:01 +00:00
|
|
|
|
Paragraph::value_type c,
|
|
|
|
|
LyXFont const & font)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
|
|
|
|
lyx::Assert(pos <= size());
|
|
|
|
|
|
|
|
|
|
text.insert(text.begin() + pos, c);
|
|
|
|
|
|
|
|
|
|
// Update the font table.
|
|
|
|
|
FontTable search_font(pos, LyXFont());
|
2001-06-28 13:02:03 +00:00
|
|
|
|
for (FontList::iterator it = std::lower_bound(fontlist.begin(),
|
2001-10-19 15:40:01 +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
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
// Update the inset table.
|
|
|
|
|
InsetTable search_inset(pos, 0);
|
2001-06-28 13:02:03 +00:00
|
|
|
|
for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
|
2001-10-19 15:40:01 +00:00
|
|
|
|
owner_->insetlist.end(),
|
|
|
|
|
search_inset, matchIT());
|
2001-06-25 00:06:33 +00:00
|
|
|
|
it != owner_->insetlist.end(); ++it)
|
2001-10-19 15:40:01 +00:00
|
|
|
|
{
|
2001-07-12 11:11:10 +00:00
|
|
|
|
++it->pos;
|
2001-10-19 15:40:01 +00:00
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
owner_->setFont(pos, font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
|
|
|
|
|
Inset * inset, LyXFont const & font)
|
|
|
|
|
{
|
|
|
|
|
lyx::Assert(inset);
|
|
|
|
|
lyx::Assert(pos <= size());
|
|
|
|
|
|
|
|
|
|
insertChar(pos, META_INSET, font);
|
|
|
|
|
lyx::Assert(text[pos] == META_INSET);
|
|
|
|
|
|
|
|
|
|
// Add a new entry in the inset table.
|
|
|
|
|
InsetTable search_inset(pos, 0);
|
2001-06-28 13:02:03 +00:00
|
|
|
|
InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
|
|
|
|
|
owner_->insetlist.end(),
|
|
|
|
|
search_inset, matchIT());
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (it != owner_->insetlist.end() && it->pos == pos) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
lyxerr << "ERROR (Paragraph::InsertInset): "
|
2001-06-27 15:33:55 +00:00
|
|
|
|
"there is an inset in position: " << pos << std::endl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
} else {
|
|
|
|
|
owner_->insetlist.insert(it, InsetTable(pos, inset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inset_owner)
|
|
|
|
|
inset->setOwner(inset_owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::Pimpl::erase(Paragraph::size_type pos)
|
|
|
|
|
{
|
|
|
|
|
lyx::Assert(pos < size());
|
|
|
|
|
// if it is an inset, delete the inset entry
|
|
|
|
|
if (text[pos] == Paragraph::META_INSET) {
|
|
|
|
|
// find the entry
|
|
|
|
|
InsetTable search_inset(pos, 0);
|
|
|
|
|
InsetList::iterator it =
|
2001-06-28 13:02:03 +00:00
|
|
|
|
std::lower_bound(owner_->insetlist.begin(),
|
|
|
|
|
owner_->insetlist.end(),
|
|
|
|
|
search_inset, matchIT());
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (it != owner_->insetlist.end() && it->pos == pos) {
|
|
|
|
|
delete it->inset;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
owner_->insetlist.erase(it);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text.erase(text.begin() + pos);
|
|
|
|
|
|
|
|
|
|
// Erase entries in the tables.
|
|
|
|
|
FontTable search_font(pos, LyXFont());
|
|
|
|
|
|
|
|
|
|
FontList::iterator it =
|
2001-06-28 13:02:03 +00:00
|
|
|
|
std::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 &&
|
2001-06-25 00:06:33 +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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
// Update the inset table.
|
|
|
|
|
InsetTable search_inset(pos, 0);
|
|
|
|
|
InsetList::iterator lend = owner_->insetlist.end();
|
|
|
|
|
for (InsetList::iterator it =
|
2001-06-28 13:02:03 +00:00
|
|
|
|
std::upper_bound(owner_->insetlist.begin(),
|
|
|
|
|
lend,
|
|
|
|
|
search_inset, matchIT());
|
2001-06-25 00:06:33 +00:00
|
|
|
|
it != lend; ++it)
|
2001-07-12 11:11:10 +00:00
|
|
|
|
--it->pos;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
|
void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
|
|
|
|
|
Paragraph::size_type const i,
|
|
|
|
|
int & column, LyXFont const & font,
|
|
|
|
|
LyXLayout const & style)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2001-07-17 09:41:34 +00:00
|
|
|
|
if (style.pass_thru) return;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (column > tex_code_break_column
|
|
|
|
|
&& 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
|
|
|
|
|
&& !style.free_spacing
|
|
|
|
|
// In typewriter mode, we want to avoid
|
|
|
|
|
// ! . ? : at the end of a line
|
|
|
|
|
&& !(font.family() == LyXFont::TYPEWRITER_FAMILY
|
2001-07-06 19:56:32 +00:00
|
|
|
|
&& (getChar(i - 1) == '.'
|
|
|
|
|
|| getChar(i - 1) == '?'
|
|
|
|
|
|| getChar(i - 1) == ':'
|
|
|
|
|
|| getChar(i - 1) == '!'))) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (tex_code_break_column == 0) {
|
|
|
|
|
// in batchmode we need LaTeX to still
|
|
|
|
|
// see it as a space not as an extra '\n'
|
|
|
|
|
os << " %\n";
|
|
|
|
|
} else {
|
|
|
|
|
os << '\n';
|
|
|
|
|
}
|
|
|
|
|
texrow.newline();
|
|
|
|
|
texrow.start(owner_, i + 1);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-23 09:59:01 +00:00
|
|
|
|
bool Paragraph::Pimpl::isTextAt(string const & str, Paragraph::size_type pos)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i < str.length(); ++i) {
|
|
|
|
|
if (pos + i >= size())
|
|
|
|
|
return false;
|
|
|
|
|
if (str[i] != getChar(pos + i))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
|
|
|
|
|
BufferParams const & bparams,
|
2001-06-27 15:33:55 +00:00
|
|
|
|
std::ostream & os,
|
|
|
|
|
TexRow & texrow,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool moving_arg,
|
|
|
|
|
LyXFont & font,
|
|
|
|
|
LyXFont & running_font,
|
|
|
|
|
LyXFont & basefont,
|
|
|
|
|
bool & open_font,
|
|
|
|
|
LyXLayout const & style,
|
|
|
|
|
Paragraph::size_type & i,
|
|
|
|
|
int & column,
|
|
|
|
|
Paragraph::value_type const c)
|
|
|
|
|
{
|
2001-07-17 09:41:34 +00:00
|
|
|
|
if (style.pass_thru) {
|
|
|
|
|
if (c != '\0') os << c;
|
|
|
|
|
return;
|
|
|
|
|
}
|
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);
|
|
|
|
|
if (inset) {
|
|
|
|
|
bool close = false;
|
|
|
|
|
int const len = os.tellp();
|
|
|
|
|
//ostream::pos_type const len = os.tellp();
|
2001-06-28 10:25:20 +00:00
|
|
|
|
if ((inset->lyxCode() == Inset::GRAPHICS_CODE
|
|
|
|
|
|| inset->lyxCode() == Inset::MATH_CODE
|
|
|
|
|
|| inset->lyxCode() == Inset::URL_CODE)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
&& running_font.isRightToLeft()) {
|
|
|
|
|
os << "\\L{";
|
|
|
|
|
close = true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int tmp = inset->latex(buf, os, moving_arg,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
style.free_spacing);
|
|
|
|
|
|
|
|
|
|
if (close)
|
|
|
|
|
os << "}";
|
|
|
|
|
|
|
|
|
|
if (tmp) {
|
2001-09-29 22:22:01 +00:00
|
|
|
|
for (int j = 0; j < tmp; ++j) {
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
texrow.start(owner_, i + 1);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
} else {
|
|
|
|
|
column += int(os.tellp()) - len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Paragraph::META_NEWLINE:
|
|
|
|
|
if (open_font) {
|
|
|
|
|
column += running_font.latexWriteEndChanges(os,
|
|
|
|
|
basefont,
|
|
|
|
|
basefont);
|
|
|
|
|
open_font = false;
|
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
basefont = owner_->getLayoutFont(bparams);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
running_font = basefont;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Paragraph::META_HFILL:
|
|
|
|
|
os << "\\hfill{}";
|
|
|
|
|
column += 7;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
// And now for the special cases within each mode
|
2001-08-03 18:28:11 +00:00
|
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
|
case '\\':
|
|
|
|
|
os << "\\textbackslash{}";
|
|
|
|
|
column += 15;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>':
|
|
|
|
|
case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>': case '<EFBFBD>':
|
|
|
|
|
case '<EFBFBD>': 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;
|
|
|
|
|
|
|
|
|
|
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;
|
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;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
case '\"':
|
|
|
|
|
os << "\\char`\\\"{}";
|
|
|
|
|
column += 9;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '<EFBFBD>':
|
|
|
|
|
if (bparams.inputenc == "default") {
|
|
|
|
|
os << "\\pounds{}";
|
|
|
|
|
column += 8;
|
|
|
|
|
} else {
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '$': case '&':
|
|
|
|
|
case '%': case '#': case '{':
|
|
|
|
|
case '}': case '_':
|
|
|
|
|
os << '\\' << c;
|
|
|
|
|
column += 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '~':
|
|
|
|
|
os << "\\textasciitilde{}";
|
|
|
|
|
column += 16;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '^':
|
|
|
|
|
os << "\\textasciicircum{}";
|
|
|
|
|
column += 17;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
// I am sure it's correct. LyX might be smarter
|
|
|
|
|
// in the future, but for now, nothing wrong is
|
|
|
|
|
// written. (Asger)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTextAt("LyX", i)) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\LyX{}";
|
|
|
|
|
i += 2;
|
|
|
|
|
column += 5;
|
2001-11-23 09:59:01 +00:00
|
|
|
|
} else if (isTextAt("TeX", i)) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\TeX{}";
|
|
|
|
|
i += 2;
|
|
|
|
|
column += 5;
|
2001-11-23 09:59:01 +00:00
|
|
|
|
} else if (isTextAt("LaTeX2e", i)) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\LaTeXe{}";
|
|
|
|
|
i += 6;
|
|
|
|
|
column += 8;
|
2001-11-23 09:59:01 +00:00
|
|
|
|
} else if (isTextAt("LaTeX", i)) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
os << "\\LaTeX{}";
|
|
|
|
|
i += 4;
|
|
|
|
|
column += 7;
|
2001-11-23 09:59:01 +00:00
|
|
|
|
// do we really try to print out '\0' ?
|
2001-08-03 18:28:11 +00:00
|
|
|
|
} else if (c != '\0') {
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
|
|
|
|
|
BufferParams const & bparams,
|
2001-06-27 15:33:55 +00:00
|
|
|
|
std::ostream & os, TexRow & texrow)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2001-06-27 15:33:55 +00:00
|
|
|
|
lyxerr[Debug::LATEX] << "TeXDeeper... " << this << std::endl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * par = owner_;
|
|
|
|
|
|
|
|
|
|
while (par && par->params().depth() == owner_->params().depth()) {
|
|
|
|
|
if (textclasslist.Style(bparams.textclass,
|
|
|
|
|
par->layout).isEnvironment()) {
|
|
|
|
|
par = par->TeXEnvironment(buf, bparams,
|
|
|
|
|
os, texrow);
|
|
|
|
|
} else {
|
|
|
|
|
par = par->TeXOnePar(buf, bparams,
|
|
|
|
|
os, texrow, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-06-27 15:33:55 +00:00
|
|
|
|
lyxerr[Debug::LATEX] << "TeXDeeper...done " << par << std::endl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
return par;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
Paragraph * Paragraph::Pimpl::getParFromID(int id) const
|
|
|
|
|
{
|
2001-07-09 09:16:00 +00:00
|
|
|
|
InsetList::const_iterator cit = owner_->insetlist.begin();
|
2001-07-06 15:57:54 +00:00
|
|
|
|
InsetList::const_iterator lend = owner_->insetlist.end();
|
|
|
|
|
Paragraph * result;
|
2001-07-09 09:16:00 +00:00
|
|
|
|
for (; cit != lend; ++cit) {
|
2001-07-06 15:57:54 +00:00
|
|
|
|
if ((result = cit->inset->getParFromID(id)))
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
|
|
|
|
|
LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
|
|
|
|
|
BufferParams const & bparams) const
|
|
|
|
|
{
|
|
|
|
|
LyXFont tmpfont(font);
|
|
|
|
|
|
|
|
|
|
// check for environment font information
|
|
|
|
|
char par_depth = owner_->getDepth();
|
|
|
|
|
Paragraph const * par = owner_;
|
|
|
|
|
while (par && par->getDepth() && !tmpfont.resolved()) {
|
|
|
|
|
par = par->outerHook();
|
|
|
|
|
if (par) {
|
2001-08-11 18:31:14 +00:00
|
|
|
|
tmpfont.realize(textclasslist.
|
|
|
|
|
Style(bparams.textclass,
|
2001-11-23 09:59:01 +00:00
|
|
|
|
par->getLayout()).font
|
|
|
|
|
#ifdef INHERIT_LANGUAGE
|
|
|
|
|
, bparams.language
|
2001-08-11 18:31:14 +00:00
|
|
|
|
#endif
|
2001-11-23 09:59:01 +00:00
|
|
|
|
);
|
2001-08-03 18:28:11 +00:00
|
|
|
|
par_depth = par->getDepth();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-11 18:31:14 +00:00
|
|
|
|
tmpfont.realize(textclasslist.TextClass(bparams.textclass)
|
2001-11-23 09:59:01 +00:00
|
|
|
|
.defaultfont()
|
|
|
|
|
#ifdef INHERIT_LANGUAGE
|
|
|
|
|
, bparams.language
|
2001-08-11 18:31:14 +00:00
|
|
|
|
#endif
|
2001-11-23 09:59:01 +00:00
|
|
|
|
);
|
2001-08-03 18:28:11 +00:00
|
|
|
|
return tmpfont;
|
|
|
|
|
}
|