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"
|
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"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
|
|
|
|
#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
|
|
|
|
|
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-09-06 12:36:58 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
2003-11-25 17:23:36 +00:00
|
|
|
|
#include "support/textutils.h"
|
|
|
|
|
#include "support/tostr.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include <boost/tuple/tuple.hpp>
|
2003-11-28 15:53:34 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <stack>
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::pos_type;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::contains;
|
|
|
|
|
using lyx::support::subst;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
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
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::Paragraph()
|
2003-11-13 13:43:44 +00:00
|
|
|
|
: y(0), height(0), 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)
|
|
|
|
|
: y(0), height(0), 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
|
|
|
|
{
|
|
|
|
|
itemdepth = 0;
|
|
|
|
|
// this is because of the dummy layout of the paragraphs that
|
|
|
|
|
// follow footnotes
|
2003-11-13 13:43:44 +00:00
|
|
|
|
layout_ = par.layout();
|
2003-05-25 08:49:48 +00:00
|
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
|
// copy everything behind the break-position to the new paragraph
|
2003-11-13 13:43:44 +00:00
|
|
|
|
insetlist = par.insetlist;
|
2002-08-14 22:15:18 +00:00
|
|
|
|
InsetList::iterator it = insetlist.begin();
|
|
|
|
|
InsetList::iterator end = insetlist.end();
|
|
|
|
|
for (; it != end; ++it) {
|
2003-06-16 11:49:38 +00:00
|
|
|
|
// currently we hold Inset*, not InsetBase*
|
2003-07-25 21:20:24 +00:00
|
|
|
|
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
|
2001-06-29 09:58:56 +00:00
|
|
|
|
}
|
2001-05-08 10:50:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
void Paragraph::operator=(Paragraph const & par)
|
2003-06-04 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
// needed as we will destroy the pimpl_ before copying it
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (&par != this)
|
2003-06-04 07:14:05 +00:00
|
|
|
|
return;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
|
|
|
|
|
lyxerr << "Paragraph::operator=()" << endl;
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
text_ = par.text_;
|
2003-09-16 14:08:05 +00:00
|
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
|
delete pimpl_;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
pimpl_ = new Pimpl(*par.pimpl_, this);
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
itemdepth = par.itemdepth;
|
2003-06-04 07:14:05 +00:00
|
|
|
|
// this is because of the dummy layout of the paragraphs that
|
|
|
|
|
// follow footnotes
|
2003-11-13 13:43:44 +00:00
|
|
|
|
layout_ = par.layout();
|
2003-06-04 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
// copy everything behind the break-position to the new paragraph
|
2003-11-13 13:43:44 +00:00
|
|
|
|
insetlist = par.insetlist;
|
2003-06-04 07:14:05 +00:00
|
|
|
|
InsetList::iterator it = insetlist.begin();
|
|
|
|
|
InsetList::iterator end = insetlist.end();
|
|
|
|
|
for (; it != end; ++it) {
|
2003-07-25 21:20:24 +00:00
|
|
|
|
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
|
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) {
|
2001-05-08 13:28:44 +00:00
|
|
|
|
os << "\n\\begin_deeper ";
|
|
|
|
|
++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) {
|
2001-05-08 13:28:44 +00:00
|
|
|
|
os << "\n\\end_deeper ";
|
|
|
|
|
--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);
|
|
|
|
|
lyx::time_type const curtime(lyx::current_time());
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
int column = 0;
|
2001-11-26 16:42:04 +00:00
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
2000-01-24 18:34:46 +00:00
|
|
|
|
if (!i) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '\n';
|
1999-11-04 01:40:20 +00:00
|
|
|
|
column = 0;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change change = pimpl_->lookupChangeFull(i);
|
|
|
|
|
Changes::lyxMarkChange(os, column, curtime, running_change, change);
|
|
|
|
|
running_change = change;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
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
|
|
|
|
{
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld 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 {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\n\\begin_inset ";
|
2001-06-28 10:25:20 +00:00
|
|
|
|
inset->write(buf, os);
|
1999-12-07 00:44:53 +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 '\\':
|
|
|
|
|
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.
|
|
|
|
|
if (c != '\0')
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << c;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
// to make reading work properly
|
|
|
|
|
if (!size()) {
|
|
|
|
|
running_change = pimpl_->lookupChange(0);
|
|
|
|
|
Changes::lyxMarkChange(os, column, curtime,
|
|
|
|
|
Change(Change::UNCHANGED), running_change);
|
|
|
|
|
}
|
|
|
|
|
Changes::lyxMarkChange(os, column, curtime,
|
2003-03-03 21:15:49 +00:00
|
|
|
|
running_change, Change(Change::UNCHANGED));
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-04 19:52:35 +00:00
|
|
|
|
void Paragraph::eraseIntern(lyx::pos_type pos)
|
|
|
|
|
{
|
|
|
|
|
pimpl_->eraseIntern(pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-01 09:15:15 +00:00
|
|
|
|
bool Paragraph::erase(pos_type pos)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-05-01 09:15:15 +00:00
|
|
|
|
return pimpl_->erase(pos);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-29 09:40:49 +00:00
|
|
|
|
int Paragraph::erase(pos_type start, pos_type end)
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
return pimpl_->erase(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-11-04 12:01:15 +00:00
|
|
|
|
void Paragraph::insert(pos_type start, string const & str,
|
|
|
|
|
LyXFont const & font)
|
|
|
|
|
{
|
|
|
|
|
int size = str.size();
|
|
|
|
|
for (int i = 0 ; i < size ; ++i)
|
|
|
|
|
insertChar(start + i, str[i], font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
bool Paragraph::checkInsertChar(LyXFont &)
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::insertChar(pos_type pos, Paragraph::value_type c)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-07-28 12:51:24 +00:00
|
|
|
|
insertChar(pos, c, LyXFont(LyXFont::ALL_INHERIT));
|
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,
|
2003-02-08 19:18:01 +00:00
|
|
|
|
LyXFont const & font, Change change)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-02-08 19:18:01 +00:00
|
|
|
|
pimpl_->insertChar(pos, c, font, change);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
void Paragraph::insertInset(pos_type pos, InsetOld * inset)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-07-28 12:51:24 +00:00
|
|
|
|
insertInset(pos, inset, LyXFont(LyXFont::ALL_INHERIT));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2003-08-11 09:09:01 +00:00
|
|
|
|
void Paragraph::insertInset(pos_type pos, InsetOld * inset,
|
|
|
|
|
LyXFont const & font, Change change)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-02-08 19:18:01 +00:00
|
|
|
|
pimpl_->insertInset(pos, inset, font, change);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-18 10:52:29 +00:00
|
|
|
|
bool Paragraph::insetAllowed(InsetOld_code code)
|
2000-04-10 14:29:05 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
//lyxerr << "Paragraph::InsertInsetAllowed" << endl;
|
|
|
|
|
if (pimpl_->inset_owner)
|
2001-07-19 08:52:59 +00:00
|
|
|
|
return pimpl_->inset_owner->insetAllowed(code);
|
2000-04-10 14:29:05 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * Paragraph::getInset(pos_type pos)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos < size());
|
2002-08-14 22:15:18 +00:00
|
|
|
|
return insetlist.get(pos);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld const * Paragraph::getInset(pos_type pos) const
|
1999-11-22 16:19:48 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos < size());
|
2002-08-11 15:03:52 +00:00
|
|
|
|
return insetlist.get(pos);
|
1999-11-22 16:19:48 +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
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
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
|
|
|
|
|
2003-07-29 10:00:51 +00:00
|
|
|
|
lyx::pos_type Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const
|
2003-07-27 10:42:11 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(pos <= size());
|
2003-07-27 10:42:11 +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)
|
2003-07-27 10:42:11 +00:00
|
|
|
|
if (cit->pos() >= pos)
|
|
|
|
|
return cit->pos();
|
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;
|
2003-07-27 10:42:11 +00:00
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
|
// Gets uninstantiated font setting at position 0
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont const Paragraph::getFirstFontSettings() 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
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
|
return LyXFont(LyXFont::ALL_INHERIT);
|
|
|
|
|
}
|
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);
|
|
|
|
|
font.realize(bparams.getLyXTextClass().defaultfont());
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-15 00:49:11 +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);
|
2003-07-27 21:59:06 +00:00
|
|
|
|
tmpfont.realize(bparams.getLyXTextClass().defaultfont());
|
|
|
|
|
return tmpfont;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-15 00:49:11 +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);
|
2003-07-27 21:59:06 +00:00
|
|
|
|
tmpfont.realize(bparams.getLyXTextClass().defaultfont());
|
|
|
|
|
return tmpfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the height of the highest font in range
|
2003-09-16 13:43:30 +00:00
|
|
|
|
LyXFont_size
|
2001-11-26 16:42:04 +00:00
|
|
|
|
Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
|
2003-09-16 13:43:30 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
unsigned int i = std::distance(beg, it);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
int Paragraph::stripLeadingSpaces()
|
2000-05-26 16:13:01 +00:00
|
|
|
|
{
|
2003-06-07 17:45:43 +00:00
|
|
|
|
if (isFreeSpacing())
|
2000-05-26 16:13:01 +00:00
|
|
|
|
return 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-05-26 16:13:01 +00:00
|
|
|
|
int i = 0;
|
2002-08-10 15:21:07 +00:00
|
|
|
|
while (!empty() && (isNewline(0) || isLineSeparator(0))) {
|
2003-02-08 19:18:01 +00:00
|
|
|
|
pimpl_->eraseIntern(0);
|
2001-04-27 07:19:08 +00:00
|
|
|
|
++i;
|
2000-05-26 16:13:01 +00:00
|
|
|
|
}
|
2001-04-27 07:19:08 +00:00
|
|
|
|
|
2000-05-26 16:13:01 +00:00
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
Paragraph::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
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return params().align();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
string 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
|
2001-06-25 00:06:33 +00:00
|
|
|
|
string 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
|
|
|
|
|
return _("Senseless with this layout!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::setLabelWidthString(string 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
params().labelWidthString(string());
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
int 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;
|
2000-11-21 15:46:13 +00:00
|
|
|
|
char previous_char = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
char 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
|
2003-07-25 21:20:24 +00:00
|
|
|
|
int Paragraph::getPositionOfInset(InsetOld 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()) {
|
|
|
|
|
InsetOld * inset = insetlist.begin()->inset;
|
|
|
|
|
if (inset->lyxCode() == InsetOld::BIBTEX_CODE)
|
|
|
|
|
return static_cast<InsetBibitem *>(inset);
|
|
|
|
|
}
|
2002-08-23 09:05:32 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
|
// unwanted space
|
2003-09-19 07:25:36 +00:00
|
|
|
|
|
|
|
|
|
bool noTrivlistCentering(UpdatableInset const * inset)
|
|
|
|
|
{
|
|
|
|
|
if (inset && inset->owner()) {
|
|
|
|
|
InsetOld::Code const code = inset->owner()->lyxCode();
|
|
|
|
|
return code == InsetOld::FLOAT_CODE ||
|
|
|
|
|
code == InsetOld::WRAP_CODE;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
UpdatableInset const * inset)
|
|
|
|
|
{
|
|
|
|
|
string output = suffix + "{";
|
|
|
|
|
if (noTrivlistCentering(inset))
|
|
|
|
|
output += correction(env);
|
|
|
|
|
else
|
|
|
|
|
output += env;
|
|
|
|
|
return output + "}";
|
|
|
|
|
}
|
2003-09-21 23:00:47 +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,
|
2002-07-01 14:31:57 +00:00
|
|
|
|
ostream & os, 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";
|
|
|
|
|
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;
|
|
|
|
|
UpdatableInset const * const inset = pimpl_->inset_owner;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
|
|
|
|
output = corrected_env("\\begin", "flushleft", inset);
|
|
|
|
|
else
|
|
|
|
|
output = corrected_env("\\begin", "flushright", inset);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_RIGHT: {
|
|
|
|
|
string output;
|
|
|
|
|
UpdatableInset const * const inset = pimpl_->inset_owner;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
|
|
|
|
output = corrected_env("\\begin", "flushright", inset);
|
|
|
|
|
else
|
|
|
|
|
output = corrected_env("\\begin", "flushleft", inset);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_CENTER: {
|
|
|
|
|
string output;
|
|
|
|
|
output = corrected_env("\\begin", "center", pimpl_->inset_owner);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
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
|
|
|
|
|
int Paragraph::endTeXParParams(BufferParams const & bparams,
|
2002-07-01 14:31:57 +00:00
|
|
|
|
ostream & os, 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;
|
|
|
|
|
UpdatableInset const * const inset = pimpl_->inset_owner;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
|
|
|
|
output = corrected_env("\\par\\end", "flushleft", inset);
|
|
|
|
|
else
|
|
|
|
|
output = corrected_env("\\par\\end", "flushright", inset);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_RIGHT: {
|
|
|
|
|
string output;
|
|
|
|
|
UpdatableInset const * const inset = pimpl_->inset_owner;
|
|
|
|
|
if (getParLanguage(bparams)->babel() != "hebrew")
|
|
|
|
|
output = corrected_env("\\par\\end", "flushright", inset);
|
|
|
|
|
else
|
|
|
|
|
output = corrected_env("\\par\\end", "flushleft", inset);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
2002-01-19 20:24:04 +00:00
|
|
|
|
break;
|
2003-09-19 07:25:36 +00:00
|
|
|
|
} case LYX_ALIGN_CENTER: {
|
|
|
|
|
string output;
|
|
|
|
|
output = corrected_env("\\par\\end", "center", pimpl_->inset_owner);
|
|
|
|
|
os << output;
|
|
|
|
|
column += output.size();
|
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,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
ostream & os, TexRow & texrow,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-10-07 18:44:17 +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
|
|
|
|
|
// any environment other then "Standard" to be valid!
|
|
|
|
|
bool asdefault =
|
|
|
|
|
(inInset() && inInset()->forceDefaultParagraphs(inInset()));
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2001-05-09 09:14:50 +00:00
|
|
|
|
LyXFont basefont;
|
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) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << '[';
|
2001-06-27 14:10:35 +00:00
|
|
|
|
++column;
|
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
|
|
|
|
}
|
|
|
|
|
|
2003-05-23 09:23:03 +00:00
|
|
|
|
bool moving_arg = runparams.moving_arg;
|
|
|
|
|
moving_arg |= style->needprotect;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
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;
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type running_change = 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)
|
2003-05-23 09:23:03 +00:00
|
|
|
|
column += startTeXParParams(bparams, os, moving_arg);
|
2002-01-19 20:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
2000-01-20 01:41:55 +00:00
|
|
|
|
++column;
|
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) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
column += running_font.latexWriteEndChanges(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;
|
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-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)
|
2002-07-01 14:31:57 +00:00
|
|
|
|
column += startTeXParParams(bparams, os,
|
2003-05-23 09:23:03 +00:00
|
|
|
|
moving_arg);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
value_type c = getChar(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Fully instantiated font
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont 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
|
|
|
|
|
|
|
|
|
// Spaces at end of font change are simulated to be
|
|
|
|
|
// outside font change, i.e. we write "\textXX{text} "
|
1999-11-04 01:40:20 +00:00
|
|
|
|
// rather than "\textXX{text }". (Asger)
|
2001-08-03 18:28:11 +00:00
|
|
|
|
if (open_font && c == ' ' && i <= size() - 2) {
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont const & next_font = getFont(bparams, i + 1, outerfont);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (next_font != running_font && next_font != font) {
|
2001-08-03 18:28:11 +00:00
|
|
|
|
font = next_font;
|
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// We end font definition before blanks
|
2002-04-11 13:35:03 +00:00
|
|
|
|
if (open_font &&
|
|
|
|
|
(font != running_font ||
|
|
|
|
|
font.language() != running_font.language()))
|
|
|
|
|
{
|
2000-03-06 02:42:40 +00:00
|
|
|
|
column += running_font.latexWriteEndChanges(os,
|
2000-02-03 19:51:27 +00:00
|
|
|
|
basefont,
|
2003-03-09 12:37:22 +00:00
|
|
|
|
(i == body_pos-1) ? basefont : font);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
running_font = basefont;
|
|
|
|
|
open_font = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Blanks are printed before start of fontswitch
|
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
|
2003-03-09 12:37:22 +00:00
|
|
|
|
if (i != body_pos - 1) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
pimpl_->simpleTeXBlanks(os, texrow, i,
|
2002-06-24 20:28:12 +00:00
|
|
|
|
column, font, *style);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Do we need to change font?
|
2002-04-11 13:35:03 +00:00
|
|
|
|
if ((font != running_font ||
|
|
|
|
|
font.language() != running_font.language()) &&
|
2003-03-09 12:37:22 +00:00
|
|
|
|
i != body_pos - 1)
|
2002-04-11 13:35:03 +00:00
|
|
|
|
{
|
2000-03-06 02:42:40 +00:00
|
|
|
|
column += font.latexWriteStartChanges(os, basefont,
|
|
|
|
|
last_font);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
running_font = font;
|
|
|
|
|
open_font = true;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type change = pimpl_->lookupChange(i);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
column += Changes::latexMarkChange(os, running_change, change);
|
|
|
|
|
running_change = change;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams rp = runparams;
|
2003-05-23 09:23:03 +00:00
|
|
|
|
rp.moving_arg = moving_arg;
|
2003-05-23 08:59:47 +00:00
|
|
|
|
rp.free_spacing = style->free_spacing;
|
2003-03-12 19:16:42 +00:00
|
|
|
|
pimpl_->simpleTeXSpecialChars(buf, bparams,
|
2003-05-22 22:44:30 +00:00
|
|
|
|
os, texrow, runparams,
|
2003-03-12 19:16:42 +00:00
|
|
|
|
font, running_font,
|
2003-04-15 00:49:11 +00:00
|
|
|
|
basefont, outerfont, open_font,
|
2003-03-12 19:16:42 +00:00
|
|
|
|
running_change,
|
|
|
|
|
*style, i, column, c);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
column += Changes::latexMarkChange(os,
|
|
|
|
|
running_change, Change::UNCHANGED);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
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,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
next_->getFont(bparams,
|
2003-04-15 00:11:03 +00:00
|
|
|
|
0, outerfont));
|
2001-04-27 07:19:08 +00:00
|
|
|
|
} else {
|
2000-03-17 10:14:46 +00:00
|
|
|
|
running_font.latexWriteEndChanges(os, basefont,
|
2002-03-21 17:27:08 +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
|
|
|
|
|
running_font.latexWriteEndChanges(os, basefont, basefont);
|
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
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()) {
|
2000-03-06 02:42:40 +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) {
|
2003-05-23 09:23:03 +00:00
|
|
|
|
column += endTeXParParams(bparams, os, moving_arg);
|
2002-01-08 14:24:49 +00:00
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
1999-10-07 18:44:17 +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 {
|
|
|
|
|
|
|
|
|
|
// checks, if newcol chars should be put into this line
|
|
|
|
|
// writes newline, if necessary.
|
|
|
|
|
void sgmlLineBreak(ostream & os, string::size_type & colcount,
|
|
|
|
|
string::size_type newcol)
|
|
|
|
|
{
|
|
|
|
|
colcount += newcol;
|
|
|
|
|
if (colcount > lyxrc.ascii_linelen) {
|
|
|
|
|
os << "\n";
|
|
|
|
|
colcount = newcol; // assume write after this call
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum PAR_TAG {
|
|
|
|
|
NONE=0,
|
|
|
|
|
TT = 1,
|
|
|
|
|
SF = 2,
|
|
|
|
|
BF = 4,
|
|
|
|
|
IT = 8,
|
|
|
|
|
SL = 16,
|
|
|
|
|
EM = 32
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string tag_name(PAR_TAG const & pt) {
|
|
|
|
|
switch (pt) {
|
|
|
|
|
case NONE: return "!-- --";
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle internal paragraph parsing -- layout already processed.
|
|
|
|
|
void Paragraph::simpleLinuxDocOnePar(Buffer const & buf,
|
|
|
|
|
ostream & os,
|
|
|
|
|
LyXFont const & outerfont,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-10-30 08:47:16 +00:00
|
|
|
|
lyx::depth_type /*depth*/) const
|
|
|
|
|
{
|
|
|
|
|
LyXLayout_ptr const & style = layout();
|
|
|
|
|
|
|
|
|
|
string::size_type char_line_count = 5; // Heuristic choice ;-)
|
|
|
|
|
|
|
|
|
|
// gets paragraph main font
|
|
|
|
|
LyXFont font_old;
|
|
|
|
|
bool desc_on;
|
|
|
|
|
if (style->labeltype == LABEL_MANUAL) {
|
|
|
|
|
font_old = style->labelfont;
|
|
|
|
|
desc_on = true;
|
|
|
|
|
} else {
|
|
|
|
|
font_old = style->font;
|
|
|
|
|
desc_on = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LyXFont::FONT_FAMILY family_type = LyXFont::ROMAN_FAMILY;
|
|
|
|
|
LyXFont::FONT_SERIES series_type = LyXFont::MEDIUM_SERIES;
|
|
|
|
|
LyXFont::FONT_SHAPE shape_type = LyXFont::UP_SHAPE;
|
|
|
|
|
bool is_em = false;
|
|
|
|
|
|
|
|
|
|
stack<PAR_TAG> tag_state;
|
|
|
|
|
// parsing main loop
|
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
|
|
|
|
|
|
|
|
|
PAR_TAG tag_close = NONE;
|
|
|
|
|
list < PAR_TAG > tag_open;
|
|
|
|
|
|
|
|
|
|
LyXFont const font = getFont(buf.params(), i, outerfont);
|
|
|
|
|
|
|
|
|
|
if (font_old.family() != font.family()) {
|
|
|
|
|
switch (family_type) {
|
|
|
|
|
case LyXFont::SANS_FAMILY:
|
|
|
|
|
tag_close |= SF;
|
|
|
|
|
break;
|
|
|
|
|
case LyXFont::TYPEWRITER_FAMILY:
|
|
|
|
|
tag_close |= TT;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
family_type = font.family();
|
|
|
|
|
|
|
|
|
|
switch (family_type) {
|
|
|
|
|
case LyXFont::SANS_FAMILY:
|
|
|
|
|
tag_open.push_back(SF);
|
|
|
|
|
break;
|
|
|
|
|
case LyXFont::TYPEWRITER_FAMILY:
|
|
|
|
|
tag_open.push_back(TT);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (font_old.series() != font.series()) {
|
|
|
|
|
switch (series_type) {
|
|
|
|
|
case LyXFont::BOLD_SERIES:
|
|
|
|
|
tag_close |= BF;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
series_type = font.series();
|
|
|
|
|
|
|
|
|
|
switch (series_type) {
|
|
|
|
|
case LyXFont::BOLD_SERIES:
|
|
|
|
|
tag_open.push_back(BF);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (font_old.shape() != font.shape()) {
|
|
|
|
|
switch (shape_type) {
|
|
|
|
|
case LyXFont::ITALIC_SHAPE:
|
|
|
|
|
tag_close |= IT;
|
|
|
|
|
break;
|
|
|
|
|
case LyXFont::SLANTED_SHAPE:
|
|
|
|
|
tag_close |= SL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shape_type = font.shape();
|
|
|
|
|
|
|
|
|
|
switch (shape_type) {
|
|
|
|
|
case LyXFont::ITALIC_SHAPE:
|
|
|
|
|
tag_open.push_back(IT);
|
|
|
|
|
break;
|
|
|
|
|
case LyXFont::SLANTED_SHAPE:
|
|
|
|
|
tag_open.push_back(SL);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// handle <em> tag
|
|
|
|
|
if (font_old.emph() != font.emph()) {
|
|
|
|
|
if (font.emph() == LyXFont::ON) {
|
|
|
|
|
tag_open.push_back(EM);
|
|
|
|
|
is_em = true;
|
|
|
|
|
}
|
|
|
|
|
else if (is_em) {
|
|
|
|
|
tag_close |= EM;
|
|
|
|
|
is_em = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list < PAR_TAG > temp;
|
|
|
|
|
while (!tag_state.empty() && tag_close) {
|
|
|
|
|
PAR_TAG k = tag_state.top();
|
|
|
|
|
tag_state.pop();
|
|
|
|
|
os << "</" << tag_name(k) << '>';
|
|
|
|
|
if (tag_close & k)
|
|
|
|
|
reset(tag_close,k);
|
|
|
|
|
else
|
|
|
|
|
temp.push_back(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(list< PAR_TAG >::const_iterator j = temp.begin();
|
|
|
|
|
j != temp.end(); ++j) {
|
|
|
|
|
tag_state.push(*j);
|
|
|
|
|
os << '<' << tag_name(*j) << '>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(list< PAR_TAG >::const_iterator j = tag_open.begin();
|
|
|
|
|
j != tag_open.end(); ++j) {
|
|
|
|
|
tag_state.push(*j);
|
|
|
|
|
os << '<' << tag_name(*j) << '>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char c = getChar(i);
|
|
|
|
|
|
2003-11-28 15:53:34 +00:00
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
if (c == Paragraph::META_INSET) {
|
2003-12-01 13:35:49 +00:00
|
|
|
|
getInset(i)->linuxdoc(buf, os, runparams);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
font_old = font;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (style->latexparam() == "CDATA") {
|
|
|
|
|
// "TeX"-Mode on == > SGML-Mode on.
|
|
|
|
|
if (c != '\0')
|
|
|
|
|
os << c;
|
|
|
|
|
++char_line_count;
|
|
|
|
|
} else {
|
|
|
|
|
bool ws;
|
|
|
|
|
string str;
|
|
|
|
|
boost::tie(ws, str) = sgml::escapeChar(c);
|
|
|
|
|
if (ws && !isFreeSpacing()) {
|
|
|
|
|
// in freespacing mode, spaces are
|
|
|
|
|
// non-breaking characters
|
2003-12-01 13:35:49 +00:00
|
|
|
|
if (desc_on) { // if char is ' ' then...
|
2003-10-30 08:47:16 +00:00
|
|
|
|
++char_line_count;
|
|
|
|
|
sgmlLineBreak(os, char_line_count, 6);
|
|
|
|
|
os << "</tag>";
|
|
|
|
|
desc_on = false;
|
|
|
|
|
} else {
|
|
|
|
|
sgmlLineBreak(os, char_line_count, 1);
|
|
|
|
|
os << c;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
os << str;
|
|
|
|
|
char_line_count += str.length();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
font_old = font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (!tag_state.empty()) {
|
|
|
|
|
os << "</" << tag_name(tag_state.top()) << '>';
|
|
|
|
|
tag_state.pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// resets description flag correctly
|
|
|
|
|
if (desc_on) {
|
|
|
|
|
// <tag> not closed...
|
|
|
|
|
sgmlLineBreak(os, char_line_count, 6);
|
|
|
|
|
os << "</tag>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
|
|
|
|
ostream & os,
|
|
|
|
|
LyXFont const & outerfont,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-11-25 17:23:36 +00:00
|
|
|
|
lyx::depth_type depth,
|
|
|
|
|
bool labelid) 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
|
|
|
|
LyXLayout_ptr const & defaultstyle =
|
|
|
|
|
buf.params().getLyXTextClass().defaultLayout();
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
int char_line_count = depth;
|
2003-11-25 17:23:36 +00:00
|
|
|
|
bool label_closed = true;
|
|
|
|
|
bool para_closed = true;
|
|
|
|
|
|
|
|
|
|
if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
|
|
|
|
|
string ls = "";
|
|
|
|
|
Counters & counters = buf.params().getLyXTextClass().counters();
|
|
|
|
|
if (!style->free_spacing)
|
|
|
|
|
os << string(depth,' ');
|
|
|
|
|
if (!style->labeltag().empty()) {
|
|
|
|
|
os << "<" << style->labeltag() << ">\n";
|
|
|
|
|
label_closed = false;
|
|
|
|
|
} else {
|
|
|
|
|
if (!defaultstyle->latexparam().empty()) {
|
|
|
|
|
counters.step("para");
|
|
|
|
|
ls = tostr(counters.value("para"));
|
|
|
|
|
ls = " id=\""
|
|
|
|
|
+ subst(defaultstyle->latexparam(), "#", ls) + '"';
|
|
|
|
|
}
|
|
|
|
|
os << "<" << style->itemtag() << ">\n"
|
|
|
|
|
<< string(depth, ' ') << "<"
|
|
|
|
|
<< defaultstyle->latexname() << ls << ">\n";
|
|
|
|
|
para_closed = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
|
|
|
|
// parsing main loop
|
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
|
|
|
|
LyXFont font = getFont(buf.params(), i, outerfont);
|
|
|
|
|
|
|
|
|
|
// handle <emphasis> tag
|
|
|
|
|
if (font_old.emph() != font.emph()) {
|
|
|
|
|
if (font.emph() == LyXFont::ON) {
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "]]>";
|
|
|
|
|
os << "<emphasis>";
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "<![CDATA[";
|
|
|
|
|
emph_flag = true;
|
|
|
|
|
} else if (i) {
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "]]>";
|
|
|
|
|
os << "</emphasis>";
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "<![CDATA[";
|
|
|
|
|
emph_flag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isInset(i)) {
|
|
|
|
|
InsetOld const * inset = getInset(i);
|
|
|
|
|
// don't print the inset in position 0 if desc_on == 3 (label)
|
2003-11-25 17:23:36 +00:00
|
|
|
|
//if (i || desc_on != 3) {
|
|
|
|
|
if (!labelid) {
|
2003-10-30 08:47:16 +00:00
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "]]>";
|
2003-10-31 18:45:43 +00:00
|
|
|
|
inset->docbook(buf, os, runparams);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "<![CDATA[";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
char c = getChar(i);
|
|
|
|
|
bool ws;
|
|
|
|
|
string str;
|
|
|
|
|
boost::tie(ws, str) = sgml::escapeChar(c);
|
|
|
|
|
|
|
|
|
|
if (style->pass_thru) {
|
|
|
|
|
os << c;
|
|
|
|
|
} else if (isFreeSpacing() || c != ' ') {
|
|
|
|
|
os << str;
|
2003-11-25 17:23:36 +00:00
|
|
|
|
} else if (!style->labeltag().empty() && !label_closed) {
|
2003-10-30 08:47:16 +00:00
|
|
|
|
++char_line_count;
|
2003-11-25 17:23:36 +00:00
|
|
|
|
os << "\n</" << style->labeltag() << "><"
|
|
|
|
|
<< style->itemtag() << "><"
|
|
|
|
|
<< defaultstyle->latexname() << ">";
|
|
|
|
|
label_closed = true;
|
|
|
|
|
para_closed = false;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
} else {
|
|
|
|
|
os << ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
font_old = font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (emph_flag) {
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "]]>";
|
|
|
|
|
os << "</emphasis>";
|
|
|
|
|
if (style->latexparam() == "CDATA")
|
|
|
|
|
os << "<![CDATA[";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// resets description flag correctly
|
2003-11-25 17:23:36 +00:00
|
|
|
|
if (!label_closed) {
|
2003-10-30 08:47:16 +00:00
|
|
|
|
// <term> not closed...
|
2003-11-25 17:23:36 +00:00
|
|
|
|
os << "</" << style->labeltag() << ">\n<"
|
|
|
|
|
<< style->itemtag() << "><"
|
|
|
|
|
<< defaultstyle->latexname() << "> ";
|
|
|
|
|
}
|
|
|
|
|
if (!para_closed) {
|
|
|
|
|
os << "\n" << string(depth, ' ') << "</"
|
|
|
|
|
<< defaultstyle->latexname() << ">\n";
|
2003-10-30 08:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
if (style->free_spacing)
|
|
|
|
|
os << '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 12:12:33 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/// return true if the char is a meta-character for an inset
|
|
|
|
|
inline
|
|
|
|
|
bool IsInsetChar(char c)
|
|
|
|
|
{
|
|
|
|
|
return (c == Paragraph::META_INSET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isHfill(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2003-03-11 15:01:29 +00:00
|
|
|
|
return IsInsetChar(getChar(pos))
|
2003-07-25 21:20:24 +00:00
|
|
|
|
&& getInset(pos)->lyxCode() == InsetOld::HFILL_CODE;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isInset(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return IsInsetChar(getChar(pos));
|
1999-11-15 12:01:38 +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
|
|
|
|
{
|
2003-03-12 19:16:42 +00:00
|
|
|
|
return IsInsetChar(getChar(pos))
|
2003-07-25 21:20:24 +00:00
|
|
|
|
&& getInset(pos)->lyxCode() == InsetOld::NEWLINE_CODE;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isSeparator(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return IsSeparatorChar(getChar(pos));
|
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);
|
|
|
|
|
return IsLineSeparatorChar(c)
|
2002-03-15 15:28:25 +00:00
|
|
|
|
|| (IsInsetChar(c) && getInset(pos) &&
|
2002-03-21 17:27:08 +00:00
|
|
|
|
getInset(pos)->isLineSeparator());
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
bool Paragraph::isKomma(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return IsKommaChar(getChar(pos));
|
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
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
|
value_type const c = getChar(pos);
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (IsLetterChar(c))
|
|
|
|
|
return true;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (isInset(pos))
|
2001-11-13 14:47:35 +00:00
|
|
|
|
return getInset(pos)->isLetter();
|
1999-11-15 12:01:38 +00:00
|
|
|
|
// We want to pass the ' and escape chars to ispell
|
2000-11-21 15:46:13 +00:00
|
|
|
|
string const extra = lyxrc.isp_esc_chars + '\'';
|
2001-11-13 14:47:35 +00:00
|
|
|
|
return contains(extra, c);
|
1999-11-15 12:01:38 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
bool Paragraph::isWord(pos_type pos) const
|
1999-11-15 12:01:38 +00:00
|
|
|
|
{
|
2003-09-16 12:12:33 +00:00
|
|
|
|
unsigned char const c = getChar(pos);
|
|
|
|
|
return !(IsSeparatorChar(c)
|
|
|
|
|
|| IsKommaChar(c)
|
|
|
|
|
|| IsInsetChar(c));
|
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())
|
2001-08-11 18:31:14 +00:00
|
|
|
|
return getFirstFontSettings().language();
|
2003-04-16 08:12:22 +00:00
|
|
|
|
#warning FIXME we should check the prev par as well (Lgb)
|
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
|
2002-05-05 16:33:19 +00:00
|
|
|
|
&& getParLanguage(bparams)->RightToLeft()
|
|
|
|
|
&& !(inInset() && inInset()->owner() &&
|
2003-07-25 21:20:24 +00:00
|
|
|
|
inInset()->owner()->lyxCode() == InsetOld::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
|
|
|
|
{
|
2001-11-26 16:42:04 +00:00
|
|
|
|
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
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool Paragraph::isMultiLingual(BufferParams const & bparams)
|
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
|
2003-10-31 18:45:43 +00:00
|
|
|
|
string const Paragraph::asString(Buffer const & buffer,
|
|
|
|
|
bool label) const
|
|
|
|
|
{
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams runparams;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
return asString(buffer, runparams, label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const Paragraph::asString(Buffer const & buffer,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-10-31 18:45:43 +00:00
|
|
|
|
bool label) const
|
2000-05-19 16:46:01 +00:00
|
|
|
|
{
|
2003-06-17 15:33:49 +00:00
|
|
|
|
#if 0
|
2000-05-19 16:46:01 +00:00
|
|
|
|
string s;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (label && !params().labelString().empty())
|
|
|
|
|
s += params().labelString() + ' ';
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
for (pos_type i = 0; i < size(); ++i) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
value_type c = getChar(i);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
if (IsPrintable(c))
|
|
|
|
|
s += c;
|
|
|
|
|
else if (c == META_INSET &&
|
2003-07-25 21:20:24 +00:00
|
|
|
|
getInset(i)->lyxCode() == InsetOld::MATH_CODE) {
|
2003-10-29 12:18:08 +00:00
|
|
|
|
ostringstream os;
|
2003-11-05 12:06:20 +00:00
|
|
|
|
getInset(i)->plaintext(buffer, os, runparams);
|
2003-10-29 12:18:08 +00:00
|
|
|
|
s += subst(STRCONV(os.str()),'\n',' ');
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s;
|
2003-06-17 15:33:49 +00:00
|
|
|
|
#else
|
|
|
|
|
// This should really be done by the caller and not here.
|
2003-10-31 18:45:43 +00:00
|
|
|
|
string ret = asString(buffer, runparams, 0, size(), label);
|
2003-06-17 15:33:49 +00:00
|
|
|
|
return subst(ret, '\n', ' ');
|
|
|
|
|
#endif
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
2000-05-20 21:37:05 +00:00
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
string 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
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const runparams;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
return asString(buffer, runparams, beg, end, label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const Paragraph::asString(Buffer const & buffer,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-10-31 18:45:43 +00:00
|
|
|
|
pos_type beg, pos_type end, bool label) const
|
|
|
|
|
{
|
2003-03-11 15:01:29 +00:00
|
|
|
|
ostringstream os;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
2001-09-12 10:41:25 +00:00
|
|
|
|
if (beg == 0 && label && !params().labelString().empty())
|
2003-03-11 15:01:29 +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);
|
2000-05-20 21:37:05 +00:00
|
|
|
|
if (IsPrintable(c))
|
2003-03-11 15:01:29 +00:00
|
|
|
|
os << c;
|
2003-03-13 10:30:28 +00:00
|
|
|
|
else if (c == META_INSET)
|
2003-11-05 12:06:20 +00:00
|
|
|
|
getInset(i)->plaintext(buffer, os, runparams);
|
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
|
|
|
|
|
|
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
|
void Paragraph::setInsetOwner(UpdatableInset * inset)
|
2000-06-23 15:02:46 +00:00
|
|
|
|
{
|
2003-06-04 07:14:05 +00:00
|
|
|
|
pimpl_->inset_owner = inset;
|
2002-08-11 15:03:52 +00:00
|
|
|
|
InsetList::iterator it = insetlist.begin();
|
|
|
|
|
InsetList::iterator end = insetlist.end();
|
2003-03-13 10:30:28 +00:00
|
|
|
|
for (; it != end; ++it)
|
2003-05-29 01:13:18 +00:00
|
|
|
|
if (it->inset)
|
2003-06-04 07:14:05 +00:00
|
|
|
|
it->inset->setOwner(inset);
|
2000-06-23 15:02:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-29 10:39:08 +00:00
|
|
|
|
void Paragraph::setContentsFromPar(Paragraph const & par)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
|
|
|
|
pimpl_->setContentsFromPar(par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::trackChanges(Change::Type type)
|
|
|
|
|
{
|
|
|
|
|
pimpl_->trackChanges(type);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::untrackChanges()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->untrackChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Paragraph::cleanChanges()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->cleanChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type Paragraph::lookupChange(lyx::pos_type pos) const
|
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(!size() || pos < size());
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return pimpl_->lookupChange(pos);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const
|
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(!size() || pos < size());
|
2003-02-08 19:18:01 +00:00
|
|
|
|
return pimpl_->lookupChangeFull(pos);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Paragraph::isChangeEdited(pos_type start, pos_type end) const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->isChangeEdited(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-03-04 19:52:35 +00:00
|
|
|
|
void Paragraph::setChange(lyx::pos_type pos, Change::Type type)
|
|
|
|
|
{
|
|
|
|
|
pimpl_->setChange(pos, type);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::markErased()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->markErased();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::acceptChange(pos_type start, pos_type end)
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->acceptChange(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void Paragraph::rejectChange(pos_type start, pos_type end)
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->rejectChange(start, end);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-09-16 14:08:05 +00:00
|
|
|
|
Paragraph::value_type Paragraph::getChar(pos_type pos) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-09-16 14:08:05 +00:00
|
|
|
|
// This is in the critical path!
|
|
|
|
|
pos_type const siz = text_.size();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-10-29 12:18:08 +00:00
|
|
|
|
BOOST_ASSERT(0 <= pos);
|
|
|
|
|
BOOST_ASSERT(pos <= siz);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-09-16 14:08:05 +00:00
|
|
|
|
if (pos == siz) {
|
|
|
|
|
lyxerr << "getChar() on pos " << pos << " in par id "
|
|
|
|
|
<< id() << " of size " << siz
|
|
|
|
|
<< " is a bit silly !" << endl;
|
2003-10-24 15:04:17 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
2003-09-16 14:08:05 +00:00
|
|
|
|
return '\0';
|
|
|
|
|
}
|
2002-08-10 15:21:07 +00:00
|
|
|
|
|
2003-09-16 14:08:05 +00:00
|
|
|
|
return text_[pos];
|
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
|
|
|
|
{
|
2003-06-04 16:14:36 +00:00
|
|
|
|
/*
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * inset = inInset();
|
|
|
|
|
if (inset && inset->lyxCode() == InsetOld::ENVIRONMENT_CODE)
|
2003-05-19 07:12:09 +00:00
|
|
|
|
return static_cast<InsetEnvironment*>(inset)->layout();
|
2003-06-04 16:14:36 +00:00
|
|
|
|
*/
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-04 07:14:05 +00:00
|
|
|
|
UpdatableInset * 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void Paragraph::clearContents()
|
|
|
|
|
{
|
2003-09-16 14:08:05 +00:00
|
|
|
|
text_.clear();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 14:08:05 +00:00
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
|
void Paragraph::setChar(pos_type pos, value_type c)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-09-16 14:08:05 +00:00
|
|
|
|
text_[pos] = c;
|
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
|
2003-08-11 09:09:01 +00:00
|
|
|
|
// other way we can always add a function to InsetOld too.
|
2001-11-29 16:29:30 +00:00
|
|
|
|
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
|
2003-07-31 13:38:06 +00:00
|
|
|
|
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
|
2001-11-29 16:29:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
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;
|
|
|
|
|
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
|
2003-07-31 13:38:06 +00:00
|
|
|
|
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
|
2003-06-07 17:45:43 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-10-24 09:45:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RowList::iterator Paragraph::getRow(pos_type pos)
|
|
|
|
|
{
|
|
|
|
|
RowList::iterator rit = rows.end();
|
|
|
|
|
RowList::iterator const begin = rows.begin();
|
|
|
|
|
|
|
|
|
|
for (--rit; rit != begin && rit->pos() > pos; --rit)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
return rit;
|
|
|
|
|
}
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char Paragraph::transformChar(unsigned char c, pos_type pos) const
|
|
|
|
|
{
|
|
|
|
|
if (!Encodings::is_arabic(c))
|
|
|
|
|
if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && IsDigit(c))
|
|
|
|
|
return c + (0xb0 - '0');
|
|
|
|
|
else
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
unsigned char const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
|
|
|
|
|
unsigned char next_char = ' ';
|
|
|
|
|
|
|
|
|
|
for (pos_type i = pos + 1, end = size(); i < end; ++i) {
|
|
|
|
|
unsigned char const par_char = getChar(i);
|
|
|
|
|
if (!Encodings::IsComposeChar_arabic(par_char)) {
|
|
|
|
|
next_char = par_char;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Encodings::is_arabic(next_char)) {
|
|
|
|
|
if (Encodings::is_arabic(prev_char) &&
|
|
|
|
|
!Encodings::is_arabic_special(prev_char))
|
|
|
|
|
return Encodings::TransformChar(c, Encodings::FORM_MEDIAL);
|
|
|
|
|
else
|
|
|
|
|
return Encodings::TransformChar(c, Encodings::FORM_INITIAL);
|
|
|
|
|
} else {
|
|
|
|
|
if (Encodings::is_arabic(prev_char) &&
|
|
|
|
|
!Encodings::is_arabic_special(prev_char))
|
|
|
|
|
return Encodings::TransformChar(c, Encodings::FORM_FINAL);
|
|
|
|
|
else
|
|
|
|
|
return Encodings::TransformChar(c, Encodings::FORM_ISOLATED);
|
|
|
|
|
}
|
|
|
|
|
}
|