2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file paragraph.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Dekel Tsur
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "paragraph.h"
|
|
|
|
|
#include "paragraph_pimpl.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2003-11-25 17:23:36 +00:00
|
|
|
|
#include "counters.h"
|
2000-07-04 20:32:37 +00:00
|
|
|
|
#include "encoding.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "debug.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
|
#include "gettext.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "language.h"
|
2005-01-24 17:12:19 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-09-16 15:45:13 +00:00
|
|
|
|
#include "lyxfont.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "lyxrow.h"
|
2007-01-15 16:58:14 +00:00
|
|
|
|
#include "messages.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2007-03-18 10:59:16 +00:00
|
|
|
|
#include "output_latex.h"
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
|
|
|
|
|
|
#include "rowpainter.h"
|
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include "sgml.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "texrow.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "vspace.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
|
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
|
#include "insets/insetbibitem.h"
|
2002-08-23 09:05:32 +00:00
|
|
|
|
#include "insets/insetoptarg.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
2003-11-25 17:23:36 +00:00
|
|
|
|
#include "support/textutils.h"
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2006-08-13 22:54:59 +00:00
|
|
|
|
#include "support/unicode.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
|
2003-11-28 15:53:34 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
2005-11-07 11:28:11 +00:00
|
|
|
|
#include <algorithm>
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include <list>
|
|
|
|
|
#include <stack>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
2004-01-28 16:21:29 +00:00
|
|
|
|
using std::distance;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
using std::list;
|
|
|
|
|
using std::stack;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::ostringstream;
|
2001-11-27 10:34:16 +00:00
|
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
|
namespace lyx {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
|
using support::contains;
|
|
|
|
|
using support::rsplit;
|
|
|
|
|
using support::subst;
|
2006-12-19 14:27:38 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::Paragraph()
|
2004-11-30 01:59:49 +00:00
|
|
|
|
: begin_of_body_(0), pimpl_(new Paragraph::Pimpl(this))
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
itemdepth = 0;
|
2002-03-07 10:51:45 +00:00
|
|
|
|
params().clear();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
Paragraph::Paragraph(Paragraph const & par)
|
2006-12-29 23:54:48 +00:00
|
|
|
|
: itemdepth(par.itemdepth), insetlist(par.insetlist),
|
2006-12-19 14:27:38 +00:00
|
|
|
|
layout_(par.layout_),
|
|
|
|
|
text_(par.text_), begin_of_body_(par.begin_of_body_),
|
|
|
|
|
pimpl_(new Paragraph::Pimpl(*par.pimpl_, this))
|
2001-05-08 10:50:09 +00:00
|
|
|
|
{
|
2004-03-19 16:36:52 +00:00
|
|
|
|
//lyxerr << "Paragraph::Paragraph(Paragraph const&)" << endl;
|
2002-08-14 22:15:18 +00:00
|
|
|
|
InsetList::iterator it = insetlist.begin();
|
|
|
|
|
InsetList::iterator end = insetlist.end();
|
2004-01-26 10:13:15 +00:00
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
it->inset = it->inset->clone().release();
|
2001-05-08 10:50:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-19 16:36:52 +00:00
|
|
|
|
Paragraph & Paragraph::operator=(Paragraph const & par)
|
2003-06-04 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
// needed as we will destroy the pimpl_ before copying it
|
2004-03-19 16:36:52 +00:00
|
|
|
|
if (&par != this) {
|
|
|
|
|
itemdepth = par.itemdepth;
|
|
|
|
|
|
|
|
|
|
insetlist = par.insetlist;
|
|
|
|
|
InsetList::iterator it = insetlist.begin();
|
|
|
|
|
InsetList::iterator end = insetlist.end();
|
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
it->inset = it->inset->clone().release();
|
|
|
|
|
|
|
|
|
|
layout_ = par.layout();
|
|
|
|
|
text_ = par.text_;
|
|
|
|
|
begin_of_body_ = par.begin_of_body_;
|
|
|
|
|
|
|
|
|
|
delete pimpl_;
|
|
|
|
|
pimpl_ = new Pimpl(*par.pimpl_, this);
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
2003-06-04 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::~Paragraph()
|
2001-05-08 10:50:09 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
delete pimpl_;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
//
|
2001-06-25 00:06:33 +00:00
|
|
|
|
//lyxerr << "Paragraph::paragraph_id = "
|
|
|
|
|
// << Paragraph::paragraph_id << endl;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void Paragraph::write(Buffer const & buf, ostream & os,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
BufferParams const & bparams,
|
2002-08-26 09:31:09 +00:00
|
|
|
|
depth_type & dth) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-05-08 13:28:44 +00:00
|
|
|
|
// The beginning or end of a deeper (i.e. nested) area?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (dth != params().depth()) {
|
|
|
|
|
if (params().depth() > dth) {
|
|
|
|
|
while (params().depth() > dth) {
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\begin_deeper";
|
2001-05-08 13:28:44 +00:00
|
|
|
|
++dth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2001-05-08 13:28:44 +00:00
|
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
while (params().depth() < dth) {
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\end_deeper";
|
2001-05-08 13:28:44 +00:00
|
|
|
|
--dth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-08 13:28:44 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-05-08 13:28:44 +00:00
|
|
|
|
// First write the layout
|
2003-07-28 15:17:11 +00:00
|
|
|
|
os << "\n\\begin_layout " << layout()->name() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-03-12 06:53:49 +00:00
|
|
|
|
params().write(os);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-06 14:07:14 +00:00
|
|
|
|
LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change running_change = Change(Change::UNCHANGED);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
int column = 0;
|
2006-03-11 13:31:41 +00:00
|
|
|
|
for (pos_type i = 0; i <= size(); ++i) {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change change = pimpl_->lookupChange(i);
|
2006-10-26 19:00:28 +00:00
|
|
|
|
Changes::lyxMarkChange(os, column, running_change, change);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
running_change = change;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2006-03-11 13:31:41 +00:00
|
|
|
|
if (i == size())
|
|
|
|
|
break;
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Write font changes
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont font2 = getFontSettings(bparams, i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2 != font1) {
|
2001-08-11 18:31:14 +00:00
|
|
|
|
font2.lyxWriteChanges(font1, os);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
font1 = font2;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
value_type const c = getChar(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
switch (c) {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
case META_INSET:
|
2000-02-22 00:36:17 +00:00
|
|
|
|
{
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase const * inset = getInset(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
|
if (inset->directWrite()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// international char, let it write
|
|
|
|
|
// code directly so it's shorter in
|
|
|
|
|
// the file
|
2001-06-28 10:25:20 +00:00
|
|
|
|
inset->write(buf, os);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2005-01-06 16:52:08 +00:00
|
|
|
|
if (i)
|
|
|
|
|
os << '\n';
|
|
|
|
|
os << "\\begin_inset ";
|
2001-06-28 10:25:20 +00:00
|
|
|
|
inset->write(buf, os);
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\end_inset\n\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
}
|
2000-02-22 00:36:17 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
case '\\':
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\backslash\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
break;
|
|
|
|
|
case '.':
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (i + 1 < size() && getChar(i + 1) == ' ') {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << ".\n";
|
1999-11-04 01:40:20 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
} else
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '.';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if ((column > 70 && c == ' ')
|
2000-02-29 02:19:17 +00:00
|
|
|
|
|| column > 79) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
}
|
|
|
|
|
// this check is to amend a bug. LyX sometimes
|
|
|
|
|
// inserts '\0' this could cause problems.
|
2006-08-13 22:54:59 +00:00
|
|
|
|
if (c != '\0') {
|
|
|
|
|
std::vector<char> tmp = ucs4_to_utf8(c);
|
|
|
|
|
tmp.push_back('\0');
|
|
|
|
|
os << &tmp[0];
|
|
|
|
|
} else
|
2001-06-25 00:06:33 +00:00
|
|
|
|
lyxerr << "ERROR (Paragraph::writeFile):"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
" NULL char in structure." << endl;
|
2000-01-24 18:34:46 +00:00
|
|
|
|
++column;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2003-07-27 21:39:54 +00:00
|
|
|
|
os << "\n\\end_layout\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2002-07-20 16:42:15 +00:00
|
|
|
|
pimpl_->validate(features, *layout());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 17:05:20 +00:00
|
|
|
|
bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
|
2003-03-04 19:52:35 +00:00
|
|
|
|
{
|
2006-10-21 17:05:20 +00:00
|
|
|
|
return pimpl_->eraseChar(pos, trackChanges);
|
2003-03-04 19:52:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 14:36:08 +00:00
|
|
|
|
int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-10-22 14:36:08 +00:00
|
|
|
|
return pimpl_->eraseChars(start, end, trackChanges);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void Paragraph::insert(pos_type start, docstring const & str,
|
2006-10-21 08:18:29 +00:00
|
|
|
|
LyXFont const & font, Change const & change)
|
2003-11-04 12:01:15 +00:00
|
|
|
|
{
|
2005-07-16 12:02:31 +00:00
|
|
|
|
for (size_t i = 0, n = str.size(); i != n ; ++i)
|
2006-10-20 11:44:58 +00:00
|
|
|
|
insertChar(start + i, str[i], font, change);
|
2003-11-04 12:01:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
|
2006-10-21 08:18:29 +00:00
|
|
|
|
bool trackChanges)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-10-20 11:44:58 +00:00
|
|
|
|
pimpl_->insertChar(pos, c, Change(trackChanges ?
|
|
|
|
|
Change::INSERTED : Change::UNCHANGED));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
|
2006-10-21 08:18:29 +00:00
|
|
|
|
LyXFont const & font, bool trackChanges)
|
2006-10-20 11:44:58 +00:00
|
|
|
|
{
|
|
|
|
|
pimpl_->insertChar(pos, c, Change(trackChanges ?
|
|
|
|
|
Change::INSERTED : Change::UNCHANGED));
|
|
|
|
|
setFont(pos, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
|
2006-10-20 11:44:58 +00:00
|
|
|
|
LyXFont const & font, Change const & change)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2004-08-05 15:14:29 +00:00
|
|
|
|
pimpl_->insertChar(pos, c, change);
|
|
|
|
|
setFont(pos, font);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 08:18:29 +00:00
|
|
|
|
void Paragraph::insertInset(pos_type pos, InsetBase * inset,
|
|
|
|
|
Change const & change)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2004-08-05 15:14:29 +00:00
|
|
|
|
pimpl_->insertInset(pos, inset, change);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
|
void Paragraph::insertInset(pos_type pos, InsetBase * inset,
|
2006-10-21 08:18:29 +00:00
|
|
|
|
LyXFont const & font, Change const & change)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2004-08-05 15:14:29 +00:00
|
|
|
|
pimpl_->insertInset(pos, inset, change);
|
|
|
|
|
setFont(pos, font);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-25 19:13:07 +00:00
|
|
|
|
bool Paragraph::insetAllowed(InsetBase_code code)
|
2000-04-10 14:29:05 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
return !pimpl_->inset_owner || pimpl_->inset_owner->insetAllowed(code);
|
2000-04-10 14:29:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Gets uninstantiated font setting at position.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
pos_type pos) const
|
2001-04-04 21:47:26 +00:00
|
|
|
|
{
|
2004-02-20 11:00:41 +00:00
|
|
|
|
if (pos > size()) {
|
|
|
|
|
lyxerr << " pos: " << pos << " size: " << size() << endl;
|
|
|
|
|
BOOST_ASSERT(pos <= size());
|
|
|
|
|
}
|
2002-03-13 18:23:38 +00:00
|
|
|
|
|
|
|
|
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
|
|
|
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
2003-07-28 12:51:24 +00:00
|
|
|
|
for (; cit != end; ++cit)
|
2002-03-13 23:13:35 +00:00
|
|
|
|
if (cit->pos() >= pos)
|
2002-03-13 18:23:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-03-11 15:01:29 +00:00
|
|
|
|
if (cit != end)
|
2003-07-28 12:51:24 +00:00
|
|
|
|
return cit->font();
|
2001-07-27 12:03:36 +00:00
|
|
|
|
|
2003-07-28 12:51:24 +00:00
|
|
|
|
if (pos == size() && !empty())
|
|
|
|
|
return getFontSettings(bparams, pos - 1);
|
|
|
|
|
|
|
|
|
|
return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-28 12:51:24 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
FontSpan Paragraph::fontSpan(pos_type pos) const
|
2003-07-27 10:42:11 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos <= size());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pos_type start = 0;
|
2003-07-27 10:42:11 +00:00
|
|
|
|
|
|
|
|
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
|
|
|
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
2005-06-10 14:55:01 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
2005-11-07 11:28:11 +00:00
|
|
|
|
if (cit->pos() >= pos) {
|
|
|
|
|
if (pos >= beginOfBody())
|
|
|
|
|
return FontSpan(std::max(start, beginOfBody()),
|
|
|
|
|
cit->pos());
|
|
|
|
|
else
|
2006-04-05 23:56:29 +00:00
|
|
|
|
return FontSpan(start,
|
|
|
|
|
std::min(beginOfBody() - 1,
|
2005-11-07 11:28:11 +00:00
|
|
|
|
cit->pos()));
|
|
|
|
|
}
|
2005-06-10 14:55:01 +00:00
|
|
|
|
start = cit->pos() + 1;
|
|
|
|
|
}
|
2003-07-28 12:51:24 +00:00
|
|
|
|
|
2003-07-27 10:42:11 +00:00
|
|
|
|
// This should not happen, but if so, we take no chances.
|
2003-08-07 11:59:09 +00:00
|
|
|
|
//lyxerr << "Paragraph::getEndPosOfFontSpan: This should not happen!"
|
|
|
|
|
// << endl;
|
2005-07-18 12:13:32 +00:00
|
|
|
|
return FontSpan(pos, pos);
|
2003-07-27 10:42:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
|
// Gets uninstantiated font setting at position 0
|
2006-02-05 13:20:16 +00:00
|
|
|
|
LyXFont const Paragraph::getFirstFontSettings(BufferParams const & bparams) const
|
2000-03-17 10:14:46 +00:00
|
|
|
|
{
|
2002-08-10 15:21:07 +00:00
|
|
|
|
if (!empty() && !pimpl_->fontlist.empty())
|
2001-11-27 10:34:16 +00:00
|
|
|
|
return pimpl_->fontlist[0].font();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-02-05 13:20:16 +00:00
|
|
|
|
return LyXFont(LyXFont::ALL_INHERIT, bparams.language);
|
2000-03-17 10:14:46 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Gets the fully instantiated font at a given position in a paragraph
|
|
|
|
|
// This is basically the same function as LyXText::GetFont() in text2.C.
|
|
|
|
|
// The difference is that this one is used for generating the LaTeX file,
|
|
|
|
|
// and thus cosmetic "improvements" are disallowed: This has to deliver
|
|
|
|
|
// the true picture of the buffer. (Asger)
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
|
|
|
|
|
LyXFont const & outerfont) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos >= 0);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
LyXLayout_ptr const & lout = layout();
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
pos_type const body_pos = beginOfBody();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
LyXFont layoutfont;
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (pos < body_pos)
|
2002-06-24 20:28:12 +00:00
|
|
|
|
layoutfont = lout->labelfont;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
else
|
2002-06-24 20:28:12 +00:00
|
|
|
|
layoutfont = lout->font;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-10-21 16:15:14 +00:00
|
|
|
|
LyXFont font = getFontSettings(bparams, pos);
|
|
|
|
|
font.realize(layoutfont);
|
|
|
|
|
font.realize(outerfont);
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
|
font.realize(bparams.getFont());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-21 16:15:14 +00:00
|
|
|
|
return font;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
LyXFont const Paragraph::getLabelFont
|
|
|
|
|
(BufferParams const & bparams, LyXFont const & outerfont) const
|
2001-08-03 18:28:11 +00:00
|
|
|
|
{
|
2003-07-28 12:51:24 +00:00
|
|
|
|
LyXFont tmpfont = layout()->labelfont;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
tmpfont.setLanguage(getParLanguage(bparams));
|
2003-04-15 00:49:11 +00:00
|
|
|
|
tmpfont.realize(outerfont);
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
|
tmpfont.realize(bparams.getFont());
|
2003-07-27 21:59:06 +00:00
|
|
|
|
return tmpfont;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
LyXFont const Paragraph::getLayoutFont
|
|
|
|
|
(BufferParams const & bparams, LyXFont const & outerfont) const
|
2001-08-03 18:28:11 +00:00
|
|
|
|
{
|
2003-07-28 12:51:24 +00:00
|
|
|
|
LyXFont tmpfont = layout()->font;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
tmpfont.setLanguage(getParLanguage(bparams));
|
2003-04-15 00:49:11 +00:00
|
|
|
|
tmpfont.realize(outerfont);
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
|
tmpfont.realize(bparams.getFont());
|
2003-07-27 21:59:06 +00:00
|
|
|
|
return tmpfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the height of the highest font in range
|
2004-11-30 01:59:49 +00:00
|
|
|
|
LyXFont_size Paragraph::highestFontInRange
|
|
|
|
|
(pos_type startpos, pos_type endpos, LyXFont_size def_size) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (pimpl_->fontlist.empty())
|
2001-07-31 12:57:06 +00:00
|
|
|
|
return def_size;
|
2000-07-15 23:51:46 +00:00
|
|
|
|
|
2002-03-13 18:23:38 +00:00
|
|
|
|
Pimpl::FontList::const_iterator end_it = pimpl_->fontlist.begin();
|
2003-10-27 11:44:10 +00:00
|
|
|
|
Pimpl::FontList::const_iterator const end = pimpl_->fontlist.end();
|
2002-03-13 18:23:38 +00:00
|
|
|
|
for (; end_it != end; ++end_it) {
|
2002-03-13 23:13:35 +00:00
|
|
|
|
if (end_it->pos() >= endpos)
|
2002-03-13 18:23:38 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (end_it != end)
|
2000-06-20 12:49:14 +00:00
|
|
|
|
++end_it;
|
|
|
|
|
|
2002-03-13 18:23:38 +00:00
|
|
|
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
|
|
|
|
for (; cit != end; ++cit) {
|
2002-03-13 23:13:35 +00:00
|
|
|
|
if (cit->pos() >= startpos)
|
2002-03-13 18:23:38 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
for (; cit != end_it; ++cit) {
|
2001-07-12 11:11:10 +00:00
|
|
|
|
LyXFont::FONT_SIZE size = cit->font().size();
|
2001-07-31 12:57:06 +00:00
|
|
|
|
if (size == LyXFont::INHERIT_SIZE)
|
|
|
|
|
size = def_size;
|
2000-06-20 12:49:14 +00:00
|
|
|
|
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
|
|
|
|
|
maxsize = size;
|
1999-11-04 01:40:20 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return maxsize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::value_type
|
2001-12-18 15:29:54 +00:00
|
|
|
|
Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
|
2001-02-11 09:58:20 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
value_type c = getChar(pos);
|
2001-02-11 09:58:20 +00:00
|
|
|
|
if (!lyxrc.rtl_support)
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
value_type uc = c;
|
|
|
|
|
switch (c) {
|
|
|
|
|
case '(':
|
|
|
|
|
uc = ')';
|
|
|
|
|
break;
|
|
|
|
|
case ')':
|
|
|
|
|
uc = '(';
|
|
|
|
|
break;
|
|
|
|
|
case '[':
|
|
|
|
|
uc = ']';
|
|
|
|
|
break;
|
|
|
|
|
case ']':
|
|
|
|
|
uc = '[';
|
|
|
|
|
break;
|
|
|
|
|
case '{':
|
|
|
|
|
uc = '}';
|
|
|
|
|
break;
|
|
|
|
|
case '}':
|
|
|
|
|
uc = '{';
|
|
|
|
|
break;
|
|
|
|
|
case '<':
|
|
|
|
|
uc = '>';
|
|
|
|
|
break;
|
|
|
|
|
case '>':
|
|
|
|
|
uc = '<';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
|
2001-02-11 09:58:20 +00:00
|
|
|
|
return uc;
|
|
|
|
|
else
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-04 21:47:26 +00:00
|
|
|
|
|
2001-12-18 15:29:54 +00:00
|
|
|
|
void Paragraph::setFont(pos_type pos, LyXFont const & font)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos <= size());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// First, reduce font against layout/label font
|
2003-10-14 13:01:49 +00:00
|
|
|
|
// Update: The setCharFont() routine in text2.C already
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// reduces font, so we don't need to do that here. (Asger)
|
|
|
|
|
// No need to simplify this because it will disappear
|
|
|
|
|
// in a new kernel. (Asger)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Next search font table
|
2000-01-11 01:59:00 +00:00
|
|
|
|
|
2002-03-13 18:23:38 +00:00
|
|
|
|
Pimpl::FontList::iterator beg = pimpl_->fontlist.begin();
|
|
|
|
|
Pimpl::FontList::iterator it = beg;
|
|
|
|
|
Pimpl::FontList::iterator endit = pimpl_->fontlist.end();
|
|
|
|
|
for (; it != endit; ++it) {
|
2002-03-13 23:13:35 +00:00
|
|
|
|
if (it->pos() >= pos)
|
2002-03-13 18:23:38 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2005-07-15 22:10:25 +00:00
|
|
|
|
size_t const i = distance(beg, it);
|
2002-03-13 18:23:38 +00:00
|
|
|
|
bool notfound = (it == endit);
|
2000-06-20 12:49:14 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (!notfound && pimpl_->fontlist[i].font() == font)
|
2000-06-20 12:49:14 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool begin = pos == 0 || notfound ||
|
2002-03-13 18:23:38 +00:00
|
|
|
|
(i > 0 && pimpl_->fontlist[i - 1].pos() == pos - 1);
|
2000-06-20 12:49:14 +00:00
|
|
|
|
// Is position pos is a beginning of a font block?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
|
2000-06-20 12:49:14 +00:00
|
|
|
|
// Is position pos is the end of a font block?
|
|
|
|
|
if (begin && end) { // A single char block
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (i + 1 < pimpl_->fontlist.size() &&
|
|
|
|
|
pimpl_->fontlist[i + 1].font() == font) {
|
2000-06-20 12:49:14 +00:00
|
|
|
|
// Merge the singleton block with the next block
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
|
|
|
|
|
if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
|
2002-08-11 16:27:10 +00:00
|
|
|
|
pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i - 1);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
} else if (i > 0 && pimpl_->fontlist[i - 1].font() == font) {
|
2000-06-20 12:49:14 +00:00
|
|
|
|
// Merge the singleton block with the previous block
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->fontlist[i - 1].pos(pos);
|
|
|
|
|
pimpl_->fontlist.erase(pimpl_->fontlist.begin() + i);
|
2000-06-20 12:49:14 +00:00
|
|
|
|
} else
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->fontlist[i].font(font);
|
2000-06-20 12:49:14 +00:00
|
|
|
|
} else if (begin) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (i > 0 && pimpl_->fontlist[i - 1].font() == font)
|
|
|
|
|
pimpl_->fontlist[i - 1].pos(pos);
|
2000-06-20 12:49:14 +00:00
|
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
|
|
|
|
|
Pimpl::FontTable(pos, font));
|
2000-06-20 12:49:14 +00:00
|
|
|
|
} else if (end) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->fontlist[i].pos(pos - 1);
|
|
|
|
|
if (!(i + 1 < pimpl_->fontlist.size() &&
|
|
|
|
|
pimpl_->fontlist[i + 1].font() == font))
|
|
|
|
|
pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
|
|
|
|
|
Pimpl::FontTable(pos, font));
|
2000-06-20 12:49:14 +00:00
|
|
|
|
} else { // The general case. The block is splitted into 3 blocks
|
2002-03-21 17:27:08 +00:00
|
|
|
|
pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Pimpl::FontTable(pos - 1, pimpl_->fontlist[i].font()));
|
|
|
|
|
pimpl_->fontlist.insert(pimpl_->fontlist.begin() + i + 1,
|
|
|
|
|
Pimpl::FontTable(pos, font));
|
1999-11-04 01:40:20 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-09 00:56:42 +00:00
|
|
|
|
|
2003-04-29 10:56:15 +00:00
|
|
|
|
void Paragraph::makeSameLayout(Paragraph const & par)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-04-29 10:56:15 +00:00
|
|
|
|
layout(par.layout());
|
2001-06-29 09:58:56 +00:00
|
|
|
|
// move to pimpl?
|
2003-04-29 10:56:15 +00:00
|
|
|
|
params() = par.params();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-21 21:11:27 +00:00
|
|
|
|
bool Paragraph::stripLeadingSpaces(bool trackChanges)
|
2000-05-26 16:13:01 +00:00
|
|
|
|
{
|
2003-06-07 17:45:43 +00:00
|
|
|
|
if (isFreeSpacing())
|
2007-02-20 08:34:04 +00:00
|
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-01-14 18:27:27 +00:00
|
|
|
|
int pos = 0;
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
while (pos < size() && (isNewline(pos) || isLineSeparator(pos))) {
|
|
|
|
|
if (eraseChar(pos, trackChanges))
|
|
|
|
|
++count;
|
|
|
|
|
else
|
|
|
|
|
++pos;
|
2000-05-26 16:13:01 +00:00
|
|
|
|
}
|
2001-04-27 07:19:08 +00:00
|
|
|
|
|
2007-02-20 08:34:04 +00:00
|
|
|
|
return count > 0 || pos > 0;
|
2000-05-26 16:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-04-29 10:56:15 +00:00
|
|
|
|
bool Paragraph::hasSameLayout(Paragraph const & par) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return par.layout() == layout() && params().sameLayout(par.params());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
depth_type Paragraph::getDepth() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return params().depth();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
depth_type Paragraph::getMaxDepthAfter() const
|
2002-02-28 15:07:11 +00:00
|
|
|
|
{
|
2003-03-11 16:38:37 +00:00
|
|
|
|
if (layout()->isEnvironment())
|
2002-02-28 15:07:11 +00:00
|
|
|
|
return params().depth() + 1;
|
|
|
|
|
else
|
|
|
|
|
return params().depth();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-11 16:38:37 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
char Paragraph::getAlign() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-12-17 10:11:28 +00:00
|
|
|
|
if (params().align() == LYX_ALIGN_LAYOUT)
|
|
|
|
|
return layout()->align;
|
|
|
|
|
else
|
|
|
|
|
return params().align();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
docstring const & Paragraph::getLabelstring() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return params().labelString();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// the next two functions are for the manual labels
|
2006-10-20 19:26:23 +00:00
|
|
|
|
docstring const Paragraph::getLabelWidthString() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (!params().labelWidthString().empty())
|
|
|
|
|
return params().labelWidthString();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
2006-10-20 19:26:23 +00:00
|
|
|
|
return _("Senseless with this layout!");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
void Paragraph::setLabelWidthString(docstring const & s)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
params().labelWidthString(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-15 16:58:14 +00:00
|
|
|
|
docstring const Paragraph::translateIfPossible(docstring const & s,
|
|
|
|
|
BufferParams const & bparams) const
|
|
|
|
|
{
|
|
|
|
|
if (!support::isAscii(s) || s.empty()) {
|
|
|
|
|
// This must be a user defined layout. We cannot translate
|
|
|
|
|
// this, since gettext accepts only ascii keys.
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
// Probably standard layout, try to translate
|
|
|
|
|
Messages & m = getMessages(getParLanguage(bparams)->code());
|
|
|
|
|
return m.get(to_ascii(s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring Paragraph::expandLabel(LyXLayout_ptr const & layout,
|
|
|
|
|
BufferParams const & bparams, bool process_appendix) const
|
|
|
|
|
{
|
|
|
|
|
LyXTextClass const & tclass = bparams.getLyXTextClass();
|
|
|
|
|
|
|
|
|
|
docstring fmt;
|
|
|
|
|
if (process_appendix && params().appendix())
|
|
|
|
|
fmt = translateIfPossible(layout->labelstring_appendix(),
|
|
|
|
|
bparams);
|
|
|
|
|
else
|
|
|
|
|
fmt = translateIfPossible(layout->labelstring(), bparams);
|
|
|
|
|
|
|
|
|
|
// handle 'inherited level parts' in 'fmt',
|
|
|
|
|
// i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
|
|
|
|
|
size_t const i = fmt.find('@', 0);
|
|
|
|
|
if (i != docstring::npos) {
|
|
|
|
|
size_t const j = fmt.find('@', i + 1);
|
|
|
|
|
if (j != docstring::npos) {
|
|
|
|
|
docstring parent(fmt, i + 1, j - i - 1);
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
docstring label = expandLabel(tclass[to_utf8(parent)], bparams);
|
|
|
|
|
fmt = docstring(fmt, 0, i) + label + docstring(fmt, j + 1, docstring::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tclass.counters().counterLabel(fmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
|
2001-04-04 21:47:26 +00:00
|
|
|
|
{
|
2002-03-02 16:39:54 +00:00
|
|
|
|
layout(new_layout);
|
2006-10-20 19:26:23 +00:00
|
|
|
|
params().labelWidthString(docstring());
|
2001-06-25 00:06:33 +00:00
|
|
|
|
params().align(LYX_ALIGN_LAYOUT);
|
|
|
|
|
params().spacing(Spacing(Spacing::Default));
|
2001-04-04 21:47:26 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2004-03-24 17:06:17 +00:00
|
|
|
|
pos_type Paragraph::beginOfBody() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-11-13 13:43:44 +00:00
|
|
|
|
return begin_of_body_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::setBeginOfBody()
|
|
|
|
|
{
|
|
|
|
|
if (layout()->labeltype != LABEL_MANUAL) {
|
|
|
|
|
begin_of_body_ = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-02-14 00:41:44 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
// Unroll the first two cycles of the loop
|
|
|
|
|
// and remember the previous character to
|
2003-10-17 10:31:47 +00:00
|
|
|
|
// remove unnecessary getChar() calls
|
2001-11-26 16:42:04 +00:00
|
|
|
|
pos_type i = 0;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
pos_type end = size();
|
|
|
|
|
if (i < end && !isNewline(i)) {
|
1999-11-04 01:40:20 +00:00
|
|
|
|
++i;
|
2006-10-22 10:15:23 +00:00
|
|
|
|
char_type previous_char = 0;
|
|
|
|
|
char_type temp = 0;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (i < end) {
|
|
|
|
|
previous_char = text_[i];
|
2003-03-12 19:16:42 +00:00
|
|
|
|
if (!isNewline(i)) {
|
1999-11-04 01:40:20 +00:00
|
|
|
|
++i;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
while (i < end && previous_char != ' ') {
|
|
|
|
|
temp = text_[i];
|
2003-03-12 19:16:42 +00:00
|
|
|
|
if (isNewline(i))
|
|
|
|
|
break;
|
|
|
|
|
++i;
|
|
|
|
|
previous_char = temp;
|
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
begin_of_body_ = i;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// returns -1 if inset not found
|
2004-01-26 10:13:15 +00:00
|
|
|
|
int Paragraph::getPositionOfInset(InsetBase const * inset) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// Find the entry.
|
2003-05-29 01:13:18 +00:00
|
|
|
|
InsetList::const_iterator it = insetlist.begin();
|
|
|
|
|
InsetList::const_iterator end = insetlist.end();
|
2003-02-17 15:16:14 +00:00
|
|
|
|
for (; it != end; ++it)
|
2003-05-29 01:13:18 +00:00
|
|
|
|
if (it->inset == inset)
|
|
|
|
|
return it->pos;
|
2000-01-11 01:59:00 +00:00
|
|
|
|
return -1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-17 15:16:14 +00:00
|
|
|
|
|
2003-05-27 22:41:04 +00:00
|
|
|
|
InsetBibitem * Paragraph::bibitem() const
|
2003-02-17 15:16:14 +00:00
|
|
|
|
{
|
2003-11-25 11:17:27 +00:00
|
|
|
|
if (!insetlist.empty()) {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase * inset = insetlist.begin()->inset;
|
2005-05-05 18:33:50 +00:00
|
|
|
|
if (inset->lyxCode() == InsetBase::BIBITEM_CODE)
|
2003-11-25 11:17:27 +00:00
|
|
|
|
return static_cast<InsetBibitem *>(inset);
|
|
|
|
|
}
|
2002-08-23 09:05:32 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
bool Paragraph::forceDefaultParagraphs() const
|
|
|
|
|
{
|
2005-11-17 08:41:56 +00:00
|
|
|
|
return inInset() && inInset()->forceDefaultParagraphs(0);
|
2004-04-08 15:03:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 07:25:36 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
// paragraphs inside floats need different alignment tags to avoid
|
2004-01-28 16:21:29 +00:00
|
|
|
|
// unwanted space
|
2003-09-19 07:25:36 +00:00
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
bool noTrivlistCentering(InsetBase::Code code)
|
2003-09-19 07:25:36 +00:00
|
|
|
|
{
|
2004-04-08 15:03:33 +00:00
|
|
|
|
return code == InsetBase::FLOAT_CODE || code == InsetBase::WRAP_CODE;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string correction(string const & orig)
|
|
|
|
|
{
|
|
|
|
|
if (orig == "flushleft")
|
|
|
|
|
return "raggedright";
|
|
|
|
|
if (orig == "flushright")
|
|
|
|
|
return "raggedleft";
|
|
|
|
|
if (orig == "center")
|
|
|
|
|
return "centering";
|
|
|
|
|
return orig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const corrected_env(string const & suffix, string const & env,
|
2004-04-08 15:03:33 +00:00
|
|
|
|
InsetBase::Code code)
|
2003-09-19 07:25:36 +00:00
|
|
|
|
{
|
|
|
|
|
string output = suffix + "{";
|
2004-04-08 15:03:33 +00:00
|
|
|
|
if (noTrivlistCentering(code))
|
2003-09-19 07:25:36 +00:00
|
|
|
|
output += correction(env);
|
|
|
|
|
else
|
|
|
|
|
output += env;
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output += "}";
|
|
|
|
|
if (suffix == "\\begin")
|
|
|
|
|
output += "\n";
|
|
|
|
|
return output;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
}
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2006-12-08 18:20:38 +00:00
|
|
|
|
|
2007-02-25 13:20:29 +00:00
|
|
|
|
void adjust_row_column(string const & str, TexRow & texrow, int & column)
|
2006-12-08 18:20:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (!contains(str, "\n"))
|
2007-02-25 13:20:29 +00:00
|
|
|
|
column += str.size();
|
2006-12-08 18:20:38 +00:00
|
|
|
|
else {
|
|
|
|
|
string tmp;
|
2007-02-25 13:20:29 +00:00
|
|
|
|
texrow.newline();
|
|
|
|
|
column = rsplit(str, tmp, '\n').size();
|
2006-12-08 18:20:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2002-08-15 07:53:46 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
// This could go to ParagraphParameters if we want to
|
|
|
|
|
int Paragraph::startTeXParParams(BufferParams const & bparams,
|
2007-02-25 13:20:29 +00:00
|
|
|
|
odocstream & os, TexRow & texrow,
|
|
|
|
|
bool moving_arg) const
|
2002-01-19 20:24:04 +00:00
|
|
|
|
{
|
|
|
|
|
int column = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
if (params().noindent()) {
|
|
|
|
|
os << "\\noindent ";
|
|
|
|
|
column += 10;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-01 14:31:57 +00:00
|
|
|
|
switch (params().align()) {
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
|
if (moving_arg) {
|
|
|
|
|
os << "\\protect";
|
2004-05-17 11:28:31 +00:00
|
|
|
|
column += 8;
|
2002-07-01 14:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-08-10 15:21:07 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
switch (params().align()) {
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
case LYX_ALIGN_LEFT: {
|
|
|
|
|
string output;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
2004-04-08 15:03:33 +00:00
|
|
|
|
output = corrected_env("\\begin", "flushleft", ownerCode());
|
2003-09-19 07:25:36 +00:00
|
|
|
|
else
|
2004-04-08 15:03:33 +00:00
|
|
|
|
output = corrected_env("\\begin", "flushright", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_RIGHT: {
|
|
|
|
|
string output;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
2004-04-08 15:03:33 +00:00
|
|
|
|
output = corrected_env("\\begin", "flushright", ownerCode());
|
2003-09-19 07:25:36 +00:00
|
|
|
|
else
|
2004-04-08 15:03:33 +00:00
|
|
|
|
output = corrected_env("\\begin", "flushleft", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_CENTER: {
|
|
|
|
|
string output;
|
2004-04-08 15:03:33 +00:00
|
|
|
|
output = corrected_env("\\begin", "center", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-09-19 07:25:36 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
return column;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-15 07:53:46 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
// This could go to ParagraphParameters if we want to
|
2007-02-25 13:20:29 +00:00
|
|
|
|
int Paragraph::endTeXParParams(BufferParams const & bparams,
|
|
|
|
|
odocstream & os, TexRow & texrow,
|
|
|
|
|
bool moving_arg) const
|
2002-01-19 20:24:04 +00:00
|
|
|
|
{
|
|
|
|
|
int column = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-01 14:31:57 +00:00
|
|
|
|
switch (params().align()) {
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
|
if (moving_arg) {
|
|
|
|
|
os << "\\protect";
|
|
|
|
|
column = 8;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-08-10 15:21:07 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
switch (params().align()) {
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
case LYX_ALIGN_LEFT: {
|
|
|
|
|
string output;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output = corrected_env("\n\\par\\end", "flushleft", ownerCode());
|
2003-09-19 07:25:36 +00:00
|
|
|
|
else
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output = corrected_env("\n\\par\\end", "flushright", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_RIGHT: {
|
|
|
|
|
string output;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output = corrected_env("\n\\par\\end", "flushright", ownerCode());
|
2003-09-19 07:25:36 +00:00
|
|
|
|
else
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output = corrected_env("\n\\par\\end", "flushleft", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_CENTER: {
|
|
|
|
|
string output;
|
2006-12-04 07:27:49 +00:00
|
|
|
|
output = corrected_env("\n\\par\\end", "center", ownerCode());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(output);
|
2007-02-25 13:20:29 +00:00
|
|
|
|
adjust_row_column(output, texrow, column);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2003-09-19 07:25:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
return column;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// This one spits out the text of the paragraph
|
2003-08-28 07:41:31 +00:00
|
|
|
|
bool Paragraph::simpleTeXOnePar(Buffer const & buf,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
BufferParams const & bparams,
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont const & outerfont,
|
2006-10-19 16:51:30 +00:00
|
|
|
|
odocstream & os, TexRow & texrow,
|
2004-05-17 11:28:31 +00:00
|
|
|
|
OutputParams const & runparams) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::LATEX) << "SimpleTeXOnePar... " << this << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
bool return_value = false;
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
LyXLayout_ptr style;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-01-08 14:24:49 +00:00
|
|
|
|
// well we have to check if we are in an inset with unlimited
|
2003-10-06 14:10:59 +00:00
|
|
|
|
// length (all in one row) if that is true then we don't allow
|
2002-01-08 14:24:49 +00:00
|
|
|
|
// any special options in the paragraph and also we don't allow
|
2007-01-17 21:22:19 +00:00
|
|
|
|
// any environment other than the default layout of the text class
|
|
|
|
|
// to be valid!
|
2004-04-08 15:03:33 +00:00
|
|
|
|
bool asdefault = forceDefaultParagraphs();
|
2002-01-08 14:24:49 +00:00
|
|
|
|
|
|
|
|
|
if (asdefault) {
|
2002-07-21 21:21:06 +00:00
|
|
|
|
style = bparams.getLyXTextClass().defaultLayout();
|
2002-01-08 14:24:49 +00:00
|
|
|
|
} else {
|
2002-06-24 20:28:12 +00:00
|
|
|
|
style = layout();
|
2002-01-08 14:24:49 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-01-07 17:58:36 +00:00
|
|
|
|
// Current base font for all inherited font changes, without any
|
|
|
|
|
// change caused by an individual character, except for the language:
|
|
|
|
|
// It is set to the language of the first character.
|
|
|
|
|
// As long as we are in the label, this font is the base font of the
|
2007-01-07 18:40:06 +00:00
|
|
|
|
// label. Before the first body character it is set to the base font
|
2007-01-07 17:58:36 +00:00
|
|
|
|
// of the body.
|
2001-05-09 09:14:50 +00:00
|
|
|
|
LyXFont basefont;
|
2005-02-08 13:18:05 +00:00
|
|
|
|
|
2005-01-24 17:12:19 +00:00
|
|
|
|
// output change tracking marks only if desired,
|
|
|
|
|
// if dvipost is installed,
|
|
|
|
|
// and with dvi/ps (other formats don't work)
|
2006-10-06 18:53:35 +00:00
|
|
|
|
bool const output = bparams.outputChanges
|
2005-01-24 17:12:19 +00:00
|
|
|
|
&& runparams.flavor == OutputParams::LATEX
|
2007-02-09 23:52:22 +00:00
|
|
|
|
&& LaTeXFeatures::isAvailable("dvipost");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// Maybe we have to create a optional argument.
|
2003-11-13 13:43:44 +00:00
|
|
|
|
pos_type body_pos = beginOfBody();
|
2003-01-08 09:03:32 +00:00
|
|
|
|
unsigned int column = 0;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (body_pos > 0) {
|
2004-08-13 23:30:26 +00:00
|
|
|
|
// the optional argument is kept in curly brackets in
|
|
|
|
|
// case it contains a ']'
|
|
|
|
|
os << "[{";
|
|
|
|
|
column += 2;
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont = getLabelFont(bparams, outerfont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont = getLayoutFont(bparams, outerfont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Which font is currently active?
|
2000-03-06 02:42:40 +00:00
|
|
|
|
LyXFont running_font(basefont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Do we have an open font change?
|
|
|
|
|
bool open_font = false;
|
|
|
|
|
|
2006-10-23 16:25:29 +00:00
|
|
|
|
Change::Type runningChangeType = Change::UNCHANGED;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-05-07 21:27:29 +00:00
|
|
|
|
texrow.start(id(), 0);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
// if the paragraph is empty, the loop will not be entered at all
|
2002-08-10 15:21:07 +00:00
|
|
|
|
if (empty()) {
|
2002-06-24 20:28:12 +00:00
|
|
|
|
if (style->isCommand()) {
|
2002-01-19 20:24:04 +00:00
|
|
|
|
os << '{';
|
|
|
|
|
++column;
|
|
|
|
|
}
|
|
|
|
|
if (!asdefault)
|
2007-02-25 13:20:29 +00:00
|
|
|
|
column += startTeXParParams(bparams, os, texrow,
|
2004-11-15 13:39:06 +00:00
|
|
|
|
runparams.moving_arg);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
Add machinery to output arbitrary unicode characters with LaTeX commands
read from a text file.
* src/encoding.[Ch]
(Encoding::latexChar): New, output a character to LaTeX
(Encoding::validate): New, add needed preamble stuff for a character
(Encodings::read): Read new unicodesymbols file
(Encodings::isCombiningChar): New, is a character a combining char?
* src/paragraph_pimpl.C
(isEncoding): Delete, no longer needed
(getEncoding): New, get the real encoding of a font
(Paragraph::Pimpl::latexSurrogatePair): New, output a surrogate pair
to LaTeX
(Paragraph::Pimpl::simpleTeXBlanks): Use latexSurrogatePair if needed
(Paragraph::Pimpl::simpleTeXSpecialChars): Ditto, and replace several
hardcoded characters with a call of encoding.latexChar()
(Paragraph::Pimpl::validate): replace several hardcoded characters
with a call of encoding.validate()
* src/support/debugstream.h
(basic_debugstream::disable): New, disable the stream completely
(basic_debugstream::enable): New, reenable the stream
* src/lyx_main.[Ch]: Adjust to changes above
* src/paragraph.C: Ditto
* lib/unicodesymbols: New file with UCS4 -> LaTeX command mapping.
It is far from complete yet, but contains most accents on latin
characters.
* lib/Makefile.am: add lib/unicodesymbols
* development/scons/scons_manifest.py: ditto
* development/tools/unicodesymbols.py: Helper script to update
lib/unicodesymbols with new symbols
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16920 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-28 21:27:45 +00:00
|
|
|
|
// Computed only once per paragraph since bparams.encoding() is expensive
|
|
|
|
|
Encoding const & doc_encoding = bparams.encoding();
|
2007-03-18 10:59:16 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// First char in paragraph or after label?
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (i == body_pos) {
|
|
|
|
|
if (body_pos > 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (open_font) {
|
2007-01-09 19:25:40 +00:00
|
|
|
|
column += running_font.latexWriteEndChanges(
|
2007-03-18 10:59:16 +00:00
|
|
|
|
os, basefont, basefont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
open_font = false;
|
|
|
|
|
}
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont = getLayoutFont(bparams, outerfont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
running_font = basefont;
|
2007-02-09 23:52:22 +00:00
|
|
|
|
|
|
|
|
|
column += Changes::latexMarkChange(os,
|
|
|
|
|
runningChangeType, Change::UNCHANGED, output);
|
|
|
|
|
runningChangeType = Change::UNCHANGED;
|
|
|
|
|
|
2004-08-13 23:30:26 +00:00
|
|
|
|
os << "}] ";
|
|
|
|
|
column +=3;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
if (style->isCommand()) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << '{';
|
2000-01-20 01:41:55 +00:00
|
|
|
|
++column;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-01-19 20:24:04 +00:00
|
|
|
|
if (!asdefault)
|
2007-02-25 13:20:29 +00:00
|
|
|
|
column += startTeXParParams(bparams, os,
|
|
|
|
|
texrow,
|
2004-11-15 13:39:06 +00:00
|
|
|
|
runparams.moving_arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-02-09 23:52:22 +00:00
|
|
|
|
Change::Type changeType = pimpl_->lookupChange(i).type;
|
|
|
|
|
|
|
|
|
|
// do not output text which is marked deleted
|
|
|
|
|
// if change tracking output is disabled
|
|
|
|
|
if (!output && changeType == Change::DELETED) {
|
|
|
|
|
runningChangeType = changeType;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++column;
|
|
|
|
|
|
|
|
|
|
column += Changes::latexMarkChange(os, runningChangeType,
|
|
|
|
|
changeType, output);
|
|
|
|
|
runningChangeType = changeType;
|
|
|
|
|
|
2007-03-18 10:59:16 +00:00
|
|
|
|
value_type const c = getChar(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Fully instantiated font
|
2007-03-18 10:59:16 +00:00
|
|
|
|
LyXFont const font = getFont(bparams, i, outerfont);
|
2001-04-27 07:19:08 +00:00
|
|
|
|
|
2002-04-11 13:35:03 +00:00
|
|
|
|
LyXFont const last_font = running_font;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-02-12 20:51:00 +00:00
|
|
|
|
// Do we need to close the previous font?
|
2002-04-11 13:35:03 +00:00
|
|
|
|
if (open_font &&
|
|
|
|
|
(font != running_font ||
|
|
|
|
|
font.language() != running_font.language()))
|
|
|
|
|
{
|
2007-01-09 19:25:40 +00:00
|
|
|
|
column += running_font.latexWriteEndChanges(
|
|
|
|
|
os, basefont,
|
2007-03-18 10:59:16 +00:00
|
|
|
|
(i == body_pos-1) ? basefont : font);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
running_font = basefont;
|
|
|
|
|
open_font = false;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-18 10:59:16 +00:00
|
|
|
|
// Switch file encoding if necessary
|
|
|
|
|
int const count = switchEncoding(os, bparams,
|
|
|
|
|
*(runparams.encoding),
|
|
|
|
|
*(font.language()->encoding()));
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
column += count;
|
|
|
|
|
runparams.encoding = font.language()->encoding();
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-11 23:52:07 +00:00
|
|
|
|
// Do we need to change font?
|
|
|
|
|
if ((font != running_font ||
|
|
|
|
|
font.language() != running_font.language()) &&
|
|
|
|
|
i != body_pos - 1)
|
|
|
|
|
{
|
2007-03-18 10:59:16 +00:00
|
|
|
|
column += font.latexWriteStartChanges(os, basefont,
|
|
|
|
|
last_font);
|
2007-02-11 23:52:07 +00:00
|
|
|
|
running_font = font;
|
|
|
|
|
open_font = true;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
|
if (c == ' ') {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Do not print the separation of the optional argument
|
2007-03-13 20:06:04 +00:00
|
|
|
|
// if style->pass_thru is false. This works because
|
|
|
|
|
// simpleTeXSpecialChars ignores spaces if
|
|
|
|
|
// style->pass_thru is false.
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (i != body_pos - 1) {
|
Add machinery to output arbitrary unicode characters with LaTeX commands
read from a text file.
* src/encoding.[Ch]
(Encoding::latexChar): New, output a character to LaTeX
(Encoding::validate): New, add needed preamble stuff for a character
(Encodings::read): Read new unicodesymbols file
(Encodings::isCombiningChar): New, is a character a combining char?
* src/paragraph_pimpl.C
(isEncoding): Delete, no longer needed
(getEncoding): New, get the real encoding of a font
(Paragraph::Pimpl::latexSurrogatePair): New, output a surrogate pair
to LaTeX
(Paragraph::Pimpl::simpleTeXBlanks): Use latexSurrogatePair if needed
(Paragraph::Pimpl::simpleTeXSpecialChars): Ditto, and replace several
hardcoded characters with a call of encoding.latexChar()
(Paragraph::Pimpl::validate): replace several hardcoded characters
with a call of encoding.validate()
* src/support/debugstream.h
(basic_debugstream::disable): New, disable the stream completely
(basic_debugstream::enable): New, reenable the stream
* src/lyx_main.[Ch]: Adjust to changes above
* src/paragraph.C: Ditto
* lib/unicodesymbols: New file with UCS4 -> LaTeX command mapping.
It is far from complete yet, but contains most accents on latin
characters.
* lib/Makefile.am: add lib/unicodesymbols
* development/scons/scons_manifest.py: ditto
* development/tools/unicodesymbols.py: Helper script to update
lib/unicodesymbols with new symbols
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16920 a592a061-630c-0410-9148-cb99ea01b6c8
2007-01-28 21:27:45 +00:00
|
|
|
|
if (pimpl_->simpleTeXBlanks(bparams,
|
|
|
|
|
doc_encoding, os, texrow,
|
|
|
|
|
i, column, font, *style))
|
|
|
|
|
// A surrogate pair was output. We
|
|
|
|
|
// must not call simpleTeXSpecialChars
|
|
|
|
|
// in this iteration, since
|
|
|
|
|
// simpleTeXBlanks incremented i, and
|
|
|
|
|
// simpleTeXSpecialChars would output
|
|
|
|
|
// the combining character again.
|
|
|
|
|
continue;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-09 23:52:22 +00:00
|
|
|
|
OutputParams rp = runparams;
|
|
|
|
|
rp.free_spacing = style->free_spacing;
|
|
|
|
|
rp.local_font = &font;
|
|
|
|
|
rp.intitle = style->intitle;
|
|
|
|
|
pimpl_->simpleTeXSpecialChars(buf, bparams, doc_encoding, os,
|
2007-03-13 19:46:56 +00:00
|
|
|
|
texrow, rp, running_font,
|
2007-02-09 23:52:22 +00:00
|
|
|
|
basefont, outerfont, open_font,
|
|
|
|
|
runningChangeType, *style, i, column, c);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we have an open font definition, we have to close it
|
|
|
|
|
if (open_font) {
|
2001-07-27 12:03:36 +00:00
|
|
|
|
#ifdef FIXED_LANGUAGE_END_DETECTION
|
2001-04-27 07:19:08 +00:00
|
|
|
|
if (next_) {
|
|
|
|
|
running_font
|
|
|
|
|
.latexWriteEndChanges(os, basefont,
|
2007-03-18 10:59:16 +00:00
|
|
|
|
next_->getFont(bparams, 0, outerfont));
|
2001-04-27 07:19:08 +00:00
|
|
|
|
} else {
|
2000-03-17 10:14:46 +00:00
|
|
|
|
running_font.latexWriteEndChanges(os, basefont,
|
2007-03-18 10:59:16 +00:00
|
|
|
|
basefont);
|
2001-04-27 07:19:08 +00:00
|
|
|
|
}
|
2001-07-27 12:03:36 +00:00
|
|
|
|
#else
|
|
|
|
|
#ifdef WITH_WARNINGS
|
2001-09-09 22:02:19 +00:00
|
|
|
|
//#warning For now we ALWAYS have to close the foreign font settings if they are
|
|
|
|
|
//#warning there as we start another \selectlanguage with the next paragraph if
|
|
|
|
|
//#warning we are in need of this. This should be fixed sometime (Jug)
|
2001-07-27 12:03:36 +00:00
|
|
|
|
#endif
|
2007-03-18 10:59:16 +00:00
|
|
|
|
running_font.latexWriteEndChanges(os, basefont, basefont);
|
2001-07-27 12:03:36 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-09 23:52:22 +00:00
|
|
|
|
column += Changes::latexMarkChange(os,
|
|
|
|
|
runningChangeType, Change::UNCHANGED, output);
|
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
|
// Needed if there is an optional argument but no contents.
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (body_pos > 0 && body_pos == size()) {
|
2005-04-11 15:09:54 +00:00
|
|
|
|
os << "}]~";
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return_value = false;
|
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2002-01-08 14:24:49 +00:00
|
|
|
|
if (!asdefault) {
|
2007-02-25 13:20:29 +00:00
|
|
|
|
column += endTeXParParams(bparams, os, texrow,
|
|
|
|
|
runparams.moving_arg);
|
2002-01-08 14:24:49 +00:00
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::LATEX) << "SimpleTeXOnePar...done " << this << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return return_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
enum PAR_TAG {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
PAR_NONE=0,
|
2003-10-30 08:47:16 +00:00
|
|
|
|
TT = 1,
|
|
|
|
|
SF = 2,
|
|
|
|
|
BF = 4,
|
|
|
|
|
IT = 8,
|
|
|
|
|
SL = 16,
|
|
|
|
|
EM = 32
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string tag_name(PAR_TAG const & pt) {
|
|
|
|
|
switch (pt) {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
case PAR_NONE: return "!-- --";
|
2003-10-30 08:47:16 +00:00
|
|
|
|
case TT: return "tt";
|
|
|
|
|
case SF: return "sf";
|
|
|
|
|
case BF: return "bf";
|
|
|
|
|
case IT: return "it";
|
|
|
|
|
case SL: return "sl";
|
|
|
|
|
case EM: return "em";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void operator|=(PAR_TAG & p1, PAR_TAG const & p2)
|
|
|
|
|
{
|
|
|
|
|
p1 = static_cast<PAR_TAG>(p1 | p2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void reset(PAR_TAG & p1, PAR_TAG const & p2)
|
|
|
|
|
{
|
|
|
|
|
p1 = static_cast<PAR_TAG>(p1 & ~p2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // anon
|
|
|
|
|
|
|
|
|
|
|
2004-10-30 13:05:31 +00:00
|
|
|
|
bool Paragraph::emptyTag() const
|
|
|
|
|
{
|
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
|
|
|
|
if (isInset(i)) {
|
|
|
|
|
InsetBase const * inset = getInset(i);
|
|
|
|
|
InsetBase::Code lyx_code = inset->lyxCode();
|
2005-01-06 15:40:49 +00:00
|
|
|
|
if (lyx_code != InsetBase::TOC_CODE &&
|
|
|
|
|
lyx_code != InsetBase::INCLUDE_CODE &&
|
|
|
|
|
lyx_code != InsetBase::GRAPHICS_CODE &&
|
|
|
|
|
lyx_code != InsetBase::ERT_CODE &&
|
|
|
|
|
lyx_code != InsetBase::FLOAT_CODE &&
|
2004-10-30 13:05:31 +00:00
|
|
|
|
lyx_code != InsetBase::TABULAR_CODE) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2005-01-06 15:40:49 +00:00
|
|
|
|
value_type c = getChar(i);
|
|
|
|
|
if (c != ' ' && c != '\t')
|
2004-10-30 13:05:31 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-02 11:25:20 +00:00
|
|
|
|
string Paragraph::getID(Buffer const & buf, OutputParams const & runparams) const
|
2004-05-14 15:47:35 +00:00
|
|
|
|
{
|
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
|
|
|
|
if (isInset(i)) {
|
|
|
|
|
InsetBase const * inset = getInset(i);
|
|
|
|
|
InsetBase::Code lyx_code = inset->lyxCode();
|
|
|
|
|
if (lyx_code == InsetBase::LABEL_CODE) {
|
2004-10-29 23:08:04 +00:00
|
|
|
|
string const id = static_cast<InsetCommand const *>(inset)->getContents();
|
2006-10-22 11:13:18 +00:00
|
|
|
|
return "id='" + to_utf8(sgml::cleanID(buf, runparams, from_utf8(id))) + "'";
|
2004-05-14 15:47:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
pos_type Paragraph::getFirstWord(Buffer const & buf, odocstream & os, OutputParams const & runparams) const
|
2004-10-24 23:53:42 +00:00
|
|
|
|
{
|
|
|
|
|
pos_type i;
|
|
|
|
|
for (i = 0; i < size(); ++i) {
|
|
|
|
|
if (isInset(i)) {
|
|
|
|
|
InsetBase const * inset = getInset(i);
|
|
|
|
|
inset->docbook(buf, os, runparams);
|
|
|
|
|
} else {
|
2005-01-06 15:40:49 +00:00
|
|
|
|
value_type c = getChar(i);
|
2004-10-24 23:53:42 +00:00
|
|
|
|
if (c == ' ')
|
|
|
|
|
break;
|
2006-10-21 11:38:43 +00:00
|
|
|
|
os << sgml::escapeChar(c);
|
|
|
|
|
}
|
2004-10-24 23:53:42 +00:00
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
|
|
|
|
bool Paragraph::onlyText(Buffer const & buf, LyXFont const & outerfont, pos_type initial) const
|
|
|
|
|
{
|
|
|
|
|
LyXFont font_old;
|
|
|
|
|
|
|
|
|
|
for (pos_type i = initial; i < size(); ++i) {
|
|
|
|
|
LyXFont font = getFont(buf.params(), i, outerfont);
|
|
|
|
|
if (isInset(i))
|
|
|
|
|
return false;
|
2005-01-06 15:40:49 +00:00
|
|
|
|
if (i != initial && font != font_old)
|
2004-10-30 22:14:02 +00:00
|
|
|
|
return false;
|
|
|
|
|
font_old = font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
2006-10-19 21:00:33 +00:00
|
|
|
|
odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2004-10-24 23:53:42 +00:00
|
|
|
|
LyXFont const & outerfont,
|
|
|
|
|
pos_type initial) const
|
2003-10-30 08:47:16 +00:00
|
|
|
|
{
|
|
|
|
|
bool emph_flag = false;
|
|
|
|
|
|
|
|
|
|
LyXLayout_ptr const & style = layout();
|
2003-12-01 13:35:49 +00:00
|
|
|
|
LyXFont font_old =
|
|
|
|
|
style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
if (style->pass_thru && !onlyText(buf, outerfont, initial))
|
2004-10-30 22:14:02 +00:00
|
|
|
|
os << "]]>";
|
2005-01-06 15:40:49 +00:00
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
// parsing main loop
|
2004-10-24 23:53:42 +00:00
|
|
|
|
for (pos_type i = initial; i < size(); ++i) {
|
2003-10-30 08:47:16 +00:00
|
|
|
|
LyXFont font = getFont(buf.params(), i, outerfont);
|
|
|
|
|
|
|
|
|
|
// handle <emphasis> tag
|
|
|
|
|
if (font_old.emph() != font.emph()) {
|
|
|
|
|
if (font.emph() == LyXFont::ON) {
|
|
|
|
|
os << "<emphasis>";
|
|
|
|
|
emph_flag = true;
|
2004-10-24 23:53:42 +00:00
|
|
|
|
} else if (i != initial) {
|
2003-10-30 08:47:16 +00:00
|
|
|
|
os << "</emphasis>";
|
|
|
|
|
emph_flag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isInset(i)) {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase const * inset = getInset(i);
|
2004-05-14 15:47:35 +00:00
|
|
|
|
inset->docbook(buf, os, runparams);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
} else {
|
2005-01-06 15:40:49 +00:00
|
|
|
|
value_type c = getChar(i);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
2004-10-24 23:53:42 +00:00
|
|
|
|
if (style->pass_thru)
|
2006-10-19 21:00:33 +00:00
|
|
|
|
os.put(c);
|
2004-10-24 23:53:42 +00:00
|
|
|
|
else
|
2006-10-21 11:38:43 +00:00
|
|
|
|
os << sgml::escapeChar(c);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
font_old = font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (emph_flag) {
|
|
|
|
|
os << "</emphasis>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (style->free_spacing)
|
|
|
|
|
os << '\n';
|
2005-01-06 15:40:49 +00:00
|
|
|
|
if (style->pass_thru && !onlyText(buf, outerfont, initial))
|
2004-10-30 22:14:02 +00:00
|
|
|
|
os << "<![CDATA[";
|
2003-10-30 08:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isNewline(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2004-10-05 10:11:42 +00:00
|
|
|
|
return isInset(pos)
|
2004-08-15 16:52:44 +00:00
|
|
|
|
&& getInset(pos)->lyxCode() == InsetBase::NEWLINE_CODE;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isLineSeparator(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2002-02-13 10:37:28 +00:00
|
|
|
|
value_type const c = getChar(pos);
|
2006-04-08 09:09:57 +00:00
|
|
|
|
return isLineSeparatorChar(c)
|
2005-07-18 12:57:08 +00:00
|
|
|
|
|| (c == Paragraph::META_INSET && getInset(pos) &&
|
2002-03-21 17:27:08 +00:00
|
|
|
|
getInset(pos)->isLineSeparator());
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Used by the spellchecker
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isLetter(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (isInset(pos))
|
2001-11-13 14:47:35 +00:00
|
|
|
|
return getInset(pos)->isLetter();
|
2004-11-18 14:58:54 +00:00
|
|
|
|
else {
|
|
|
|
|
value_type const c = getChar(pos);
|
2006-04-08 09:09:57 +00:00
|
|
|
|
return isLetterChar(c) || isDigit(c);
|
2004-11-18 14:58:54 +00:00
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
|
Language const *
|
2002-03-21 17:27:08 +00:00
|
|
|
|
Paragraph::getParLanguage(BufferParams const & bparams) const
|
2000-03-17 10:14:46 +00:00
|
|
|
|
{
|
2003-07-27 21:59:06 +00:00
|
|
|
|
if (!empty())
|
2006-02-05 13:20:16 +00:00
|
|
|
|
return getFirstFontSettings(bparams).language();
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2003-04-16 08:12:22 +00:00
|
|
|
|
#warning FIXME we should check the prev par as well (Lgb)
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#endif
|
2003-07-27 21:59:06 +00:00
|
|
|
|
return bparams.language;
|
2000-03-17 10:14:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
|
2000-03-17 10:14:46 +00:00
|
|
|
|
{
|
2000-07-21 18:47:54 +00:00
|
|
|
|
return lyxrc.rtl_support
|
2006-04-09 00:26:19 +00:00
|
|
|
|
&& getParLanguage(bparams)->rightToLeft()
|
2004-04-08 15:03:33 +00:00
|
|
|
|
&& ownerCode() != InsetBase::ERT_CODE;
|
2000-03-17 10:14:46 +00:00
|
|
|
|
}
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::changeLanguage(BufferParams const & bparams,
|
2003-04-15 00:11:03 +00:00
|
|
|
|
Language const * from, Language const * to)
|
2000-02-22 00:36:17 +00:00
|
|
|
|
{
|
2006-11-12 17:02:43 +00:00
|
|
|
|
// change language including dummy font change at the end
|
|
|
|
|
for (pos_type i = 0; i <= size(); ++i) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont font = getFontSettings(bparams, i);
|
2000-04-10 21:40:13 +00:00
|
|
|
|
if (font.language() == from) {
|
|
|
|
|
font.setLanguage(to);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
setFont(i, font);
|
2000-04-10 21:40:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-22 00:36:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
2004-02-25 12:00:53 +00:00
|
|
|
|
bool Paragraph::isMultiLingual(BufferParams const & bparams) const
|
2000-02-22 00:36:17 +00:00
|
|
|
|
{
|
2000-10-10 12:36:36 +00:00
|
|
|
|
Language const * doc_language = bparams.language;
|
2002-03-13 18:23:38 +00:00
|
|
|
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
|
|
|
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-03-13 18:23:38 +00:00
|
|
|
|
for (; cit != end; ++cit)
|
2001-08-11 18:31:14 +00:00
|
|
|
|
if (cit->font().language() != ignore_language &&
|
|
|
|
|
cit->font().language() != latex_language &&
|
2003-07-31 13:38:06 +00:00
|
|
|
|
cit->font().language() != doc_language)
|
2000-04-10 21:40:13 +00:00
|
|
|
|
return true;
|
|
|
|
|
return false;
|
2000-02-22 00:36:17 +00:00
|
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert the paragraph to a string.
|
|
|
|
|
// Used for building the table of contents
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const Paragraph::asString(Buffer const & buffer, bool label) const
|
2003-10-31 18:45:43 +00:00
|
|
|
|
{
|
2007-01-19 16:23:13 +00:00
|
|
|
|
return asString(buffer, 0, size(), label);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
2000-05-20 21:37:05 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const Paragraph::asString(Buffer const & buffer,
|
2002-11-08 01:08:27 +00:00
|
|
|
|
pos_type beg, pos_type end, bool label) const
|
2000-05-20 21:37:05 +00:00
|
|
|
|
{
|
2003-10-31 18:45:43 +00:00
|
|
|
|
|
2007-01-19 16:23:13 +00:00
|
|
|
|
odocstringstream os;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
2001-09-12 10:41:25 +00:00
|
|
|
|
if (beg == 0 && label && !params().labelString().empty())
|
2006-10-20 19:26:23 +00:00
|
|
|
|
os << params().labelString() << ' ';
|
2000-05-20 21:37:05 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
for (pos_type i = beg; i < end; ++i) {
|
2003-09-09 09:47:59 +00:00
|
|
|
|
value_type const c = getUChar(buffer.params(), i);
|
2006-04-08 09:09:57 +00:00
|
|
|
|
if (isPrintable(c))
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os.put(c);
|
2003-03-13 10:30:28 +00:00
|
|
|
|
else if (c == META_INSET)
|
2007-01-19 16:23:13 +00:00
|
|
|
|
getInset(i)->textString(buffer, os);
|
2000-05-20 21:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return os.str();
|
2000-05-20 21:37:05 +00:00
|
|
|
|
}
|
2000-06-23 15:02:46 +00:00
|
|
|
|
|
|
|
|
|
|
2005-07-15 22:10:25 +00:00
|
|
|
|
void Paragraph::setInsetOwner(InsetBase * inset)
|
2000-06-23 15:02:46 +00:00
|
|
|
|
{
|
2003-06-04 07:14:05 +00:00
|
|
|
|
pimpl_->inset_owner = inset;
|
2000-06-23 15:02:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-08 22:21:57 +00:00
|
|
|
|
Change const & Paragraph::lookupChange(pos_type pos) const
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
2006-03-11 13:31:41 +00:00
|
|
|
|
BOOST_ASSERT(pos <= size());
|
2006-05-08 20:30:52 +00:00
|
|
|
|
return pimpl_->lookupChange(pos);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool Paragraph::isChanged(pos_type start, pos_type end) const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->isChanged(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-24 21:16:46 +00:00
|
|
|
|
bool Paragraph::isMergedOnEndOfParDeletion(bool trackChanges) const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->isMergedOnEndOfParDeletion(trackChanges);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 07:12:48 +00:00
|
|
|
|
void Paragraph::setChange(Change const & change)
|
2003-03-04 19:52:35 +00:00
|
|
|
|
{
|
2006-10-19 07:12:48 +00:00
|
|
|
|
pimpl_->setChange(change);
|
2003-03-04 19:52:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void Paragraph::setChange(pos_type pos, Change const & change)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
2006-10-19 07:12:48 +00:00
|
|
|
|
pimpl_->setChange(pos, change);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2007-01-23 21:53:16 +00:00
|
|
|
|
void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start, pos_type end)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
2007-01-23 21:53:16 +00:00
|
|
|
|
return pimpl_->acceptChanges(bparams, start, end);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2007-01-23 21:53:16 +00:00
|
|
|
|
void Paragraph::rejectChanges(BufferParams const & bparams, pos_type start, pos_type end)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
2007-01-23 21:53:16 +00:00
|
|
|
|
return pimpl_->rejectChanges(bparams, start, end);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
int Paragraph::id() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->id_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
LyXLayout_ptr const & Paragraph::layout() const
|
2002-03-02 16:39:54 +00:00
|
|
|
|
{
|
|
|
|
|
return layout_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
void Paragraph::layout(LyXLayout_ptr const & new_layout)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2002-03-02 16:39:54 +00:00
|
|
|
|
layout_ = new_layout;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-07-15 22:10:25 +00:00
|
|
|
|
InsetBase * Paragraph::inInset() const
|
2001-02-16 09:25:43 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return pimpl_->inset_owner;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
InsetBase::Code Paragraph::ownerCode() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->inset_owner
|
|
|
|
|
? pimpl_->inset_owner->lyxCode() : InsetBase::NO_CODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
ParagraphParameters & Paragraph::params()
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->params;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-17 13:01:41 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
ParagraphParameters const & Paragraph::params() const
|
2001-02-16 09:25:43 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return pimpl_->params;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
2001-07-17 13:01:41 +00:00
|
|
|
|
|
2001-11-29 16:29:30 +00:00
|
|
|
|
bool Paragraph::isFreeSpacing() const
|
|
|
|
|
{
|
2003-06-07 17:45:43 +00:00
|
|
|
|
if (layout()->free_spacing)
|
|
|
|
|
return true;
|
|
|
|
|
|
2001-11-29 16:29:30 +00:00
|
|
|
|
// for now we just need this, later should we need this in some
|
2004-01-26 10:13:15 +00:00
|
|
|
|
// other way we can always add a function to InsetBase too.
|
2004-04-08 15:03:33 +00:00
|
|
|
|
return ownerCode() == InsetBase::ERT_CODE;
|
2001-11-29 16:29:30 +00:00
|
|
|
|
}
|
2003-05-27 20:59:03 +00:00
|
|
|
|
|
|
|
|
|
|
2003-06-07 17:45:43 +00:00
|
|
|
|
bool Paragraph::allowEmpty() const
|
|
|
|
|
{
|
|
|
|
|
if (layout()->keepempty)
|
|
|
|
|
return true;
|
2004-04-08 15:03:33 +00:00
|
|
|
|
return ownerCode() == InsetBase::ERT_CODE;
|
2003-06-07 17:45:43 +00:00
|
|
|
|
}
|
2003-10-24 09:45:07 +00:00
|
|
|
|
|
|
|
|
|
|
2006-08-13 22:54:59 +00:00
|
|
|
|
char_type Paragraph::transformChar(char_type c, pos_type pos) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (!Encodings::is_arabic(c))
|
2007-03-26 08:24:38 +00:00
|
|
|
|
return c;
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
2006-04-09 02:30:40 +00:00
|
|
|
|
value_type const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
|
|
|
|
|
value_type next_char = ' ';
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
|
|
|
|
for (pos_type i = pos + 1, end = size(); i < end; ++i) {
|
2006-04-09 02:30:40 +00:00
|
|
|
|
value_type const par_char = getChar(i);
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (!Encodings::isComposeChar_arabic(par_char)) {
|
2003-10-27 12:41:26 +00:00
|
|
|
|
next_char = par_char;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Encodings::is_arabic(next_char)) {
|
|
|
|
|
if (Encodings::is_arabic(prev_char) &&
|
|
|
|
|
!Encodings::is_arabic_special(prev_char))
|
2006-04-09 00:26:19 +00:00
|
|
|
|
return Encodings::transformChar(c, Encodings::FORM_MEDIAL);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
else
|
2006-04-09 00:26:19 +00:00
|
|
|
|
return Encodings::transformChar(c, Encodings::FORM_INITIAL);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (Encodings::is_arabic(prev_char) &&
|
|
|
|
|
!Encodings::is_arabic_special(prev_char))
|
2006-04-09 00:26:19 +00:00
|
|
|
|
return Encodings::transformChar(c, Encodings::FORM_FINAL);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
else
|
2006-04-09 00:26:19 +00:00
|
|
|
|
return Encodings::transformChar(c, Encodings::FORM_ISOLATED);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 07:24:11 +00:00
|
|
|
|
bool Paragraph::hfillExpansion(Row const & row, pos_type pos) const
|
|
|
|
|
{
|
|
|
|
|
if (!isHfill(pos))
|
|
|
|
|
return false;
|
|
|
|
|
|
2007-01-07 10:25:45 +00:00
|
|
|
|
BOOST_ASSERT(pos >= row.pos() && pos < row.endpos());
|
|
|
|
|
|
|
|
|
|
// expand at the end of a row only if there is another hfill on the same row
|
|
|
|
|
if (pos == row.endpos() - 1) {
|
|
|
|
|
for (pos_type i = row.pos(); i < pos; i++) {
|
|
|
|
|
if (isHfill(i))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2006-10-21 07:24:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-07 10:42:10 +00:00
|
|
|
|
// expand at the beginning of a row only if it is the first row of a paragraph
|
2007-01-07 10:25:45 +00:00
|
|
|
|
if (pos == row.pos()) {
|
2007-01-07 10:42:10 +00:00
|
|
|
|
return pos == 0;
|
2007-01-07 10:25:45 +00:00
|
|
|
|
}
|
2006-10-21 07:24:11 +00:00
|
|
|
|
|
2007-01-07 10:25:45 +00:00
|
|
|
|
// do not expand in some labels
|
2006-10-21 07:24:11 +00:00
|
|
|
|
if (layout()->margintype != MARGIN_MANUAL && pos < beginOfBody())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// if there is anything between the first char of the row and
|
2007-01-07 10:25:45 +00:00
|
|
|
|
// the specified position that is neither a newline nor an hfill,
|
|
|
|
|
// the hfill will be expanded, otherwise it won't
|
2007-01-07 10:42:10 +00:00
|
|
|
|
for (pos_type i = row.pos(); i < pos; i++) {
|
|
|
|
|
if (!isNewline(i) && !isHfill(i))
|
|
|
|
|
return true;
|
2007-01-07 10:25:45 +00:00
|
|
|
|
}
|
2007-01-07 10:42:10 +00:00
|
|
|
|
return false;
|
2006-10-21 07:24:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
|
bool Paragraph::checkBiblio(bool track_changes)
|
|
|
|
|
{
|
|
|
|
|
// Add bibitem insets if necessary
|
|
|
|
|
if (layout()->labeltype != LABEL_BIBLIO)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool hasbibitem = !insetlist.empty()
|
|
|
|
|
// Insist on it being in pos 0
|
|
|
|
|
&& getChar(0) == Paragraph::META_INSET
|
|
|
|
|
&& insetlist.begin()->inset->lyxCode() == InsetBase::BIBITEM_CODE;
|
|
|
|
|
|
|
|
|
|
if (hasbibitem)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
InsetBibitem * inset(new InsetBibitem(InsetCommandParams("bibitem")));
|
|
|
|
|
insertInset(0, static_cast<InsetBase *>(inset),
|
|
|
|
|
Change(track_changes ? Change::INSERTED : Change::UNCHANGED));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|