2002-09-12 14:58:06 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file paragraph_funcs.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-21 17:35:24 +00:00
|
|
|
|
*
|
2002-09-12 14:58:06 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-08-21 17:35:24 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-12 14:58:06 +00:00
|
|
|
|
*/
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "paragraph_funcs.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
#include "debug.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "encoding.h"
|
2003-03-12 11:52:23 +00:00
|
|
|
|
#include "gettext.h"
|
2003-03-03 21:15:49 +00:00
|
|
|
|
#include "language.h"
|
2004-11-30 01:59:49 +00:00
|
|
|
|
#include "lyxrow.h"
|
2004-03-25 09:16:36 +00:00
|
|
|
|
#include "lyxtext.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "paragraph_pimpl.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
#include "pariterator.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"
|
2003-07-27 15:09:13 +00:00
|
|
|
|
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include "support/filetools.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-10-30 08:47:16 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
using lyx::pos_type;
|
2004-11-24 21:53:46 +00:00
|
|
|
|
using lyx::pit_type;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
using lyx::support::ascii_lowercase;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::bformat;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
using lyx::support::compare_ascii_no_case;
|
|
|
|
|
using lyx::support::compare_no_case;
|
|
|
|
|
using lyx::support::contains;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
using lyx::support::split;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::subst;
|
|
|
|
|
|
2003-11-03 17:47:28 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
using std::vector;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
using std::ostream;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
using std::pair;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2003-07-31 13:12:21 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
bool moveItem(Paragraph & from, Paragraph & to,
|
2005-04-26 11:12:20 +00:00
|
|
|
|
BufferParams const & params, pos_type i, pos_type j,
|
|
|
|
|
Change change = Change(Change::INSERTED));
|
2005-02-24 13:17:45 +00:00
|
|
|
|
|
|
|
|
|
bool moveItem(Paragraph & from, Paragraph & to,
|
|
|
|
|
BufferParams const & params, pos_type i, pos_type j,
|
|
|
|
|
Change change)
|
2003-07-31 13:12:21 +00:00
|
|
|
|
{
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph::value_type const tmpchar = from.getChar(i);
|
2003-07-31 13:12:21 +00:00
|
|
|
|
LyXFont tmpfont = from.getFontSettings(params, i);
|
|
|
|
|
|
|
|
|
|
if (tmpchar == Paragraph::META_INSET) {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase * tmpinset = 0;
|
2003-07-31 13:12:21 +00:00
|
|
|
|
if (from.getInset(i)) {
|
|
|
|
|
// the inset is not in a paragraph anymore
|
|
|
|
|
tmpinset = from.insetlist.release(i);
|
2004-03-27 13:24:16 +00:00
|
|
|
|
from.insetlist.erase(i);
|
2003-07-31 13:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-27 13:24:16 +00:00
|
|
|
|
if (!to.insetAllowed(tmpinset->lyxCode())) {
|
|
|
|
|
delete tmpinset;
|
2003-07-31 13:12:21 +00:00
|
|
|
|
return false;
|
2004-03-27 13:24:16 +00:00
|
|
|
|
}
|
|
|
|
|
if (tmpinset)
|
2005-02-24 13:17:45 +00:00
|
|
|
|
to.insertInset(j, tmpinset, tmpfont, change);
|
2003-07-31 13:12:21 +00:00
|
|
|
|
} else {
|
2005-02-24 13:17:45 +00:00
|
|
|
|
to.insertChar(j, tmpchar, tmpfont, change);
|
2003-07-31 13:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-06 10:02:40 +00:00
|
|
|
|
void breakParagraph(BufferParams const & bparams,
|
2004-11-24 21:53:46 +00:00
|
|
|
|
ParagraphList & pars, pit_type par_offset, pos_type pos, int flag)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2003-03-04 19:52:35 +00:00
|
|
|
|
// create a new paragraph, and insert into the list
|
2004-03-25 09:16:36 +00:00
|
|
|
|
ParagraphList::iterator tmp =
|
2006-03-23 20:11:06 +00:00
|
|
|
|
pars.insert(boost::next(pars.begin(), par_offset + 1),
|
|
|
|
|
Paragraph());
|
2004-08-13 20:26:26 +00:00
|
|
|
|
|
|
|
|
|
Paragraph & par = pars[par_offset];
|
2003-03-04 21:40:36 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
// we will invalidate the row cache
|
|
|
|
|
par.rows().clear();
|
|
|
|
|
|
2002-08-21 15:39:54 +00:00
|
|
|
|
// without doing that we get a crash when typing <Return> at the
|
|
|
|
|
// end of a paragraph
|
|
|
|
|
tmp->layout(bparams.getLyXTextClass().defaultLayout());
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// remember to set the inset_owner
|
2004-08-13 20:26:26 +00:00
|
|
|
|
tmp->setInsetOwner(par.inInset());
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
if (bparams.tracking_changes)
|
|
|
|
|
tmp->trackChanges();
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// this is an idea for a more userfriendly layout handling, I will
|
|
|
|
|
// see what the users say
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// layout stays the same with latex-environments
|
|
|
|
|
if (flag) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
tmp->layout(par.layout());
|
|
|
|
|
tmp->setLabelWidthString(par.params().labelWidthString());
|
2006-04-03 18:28:13 +00:00
|
|
|
|
tmp->params().depth(par.params().depth());
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
bool const isempty = (par.allowEmpty() && par.empty());
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (!isempty && (par.size() > pos || par.empty() || flag == 2)) {
|
|
|
|
|
tmp->layout(par.layout());
|
|
|
|
|
tmp->params().align(par.params().align());
|
|
|
|
|
tmp->setLabelWidthString(par.params().labelWidthString());
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
tmp->params().depth(par.params().depth());
|
|
|
|
|
tmp->params().noindent(par.params().noindent());
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// copy everything behind the break-position
|
|
|
|
|
// to the new paragraph
|
2002-11-07 00:37:09 +00:00
|
|
|
|
|
2004-03-28 19:13:11 +00:00
|
|
|
|
/* Note: if !keepempty, empty() == true, then we reach
|
|
|
|
|
* here with size() == 0. So pos_end becomes - 1. This
|
|
|
|
|
* doesn't cause problems because both loops below
|
|
|
|
|
* enforce pos <= pos_end and 0 <= pos
|
2002-11-07 00:37:09 +00:00
|
|
|
|
*/
|
2004-08-13 20:26:26 +00:00
|
|
|
|
pos_type pos_end = par.size() - 1;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2004-03-28 19:13:11 +00:00
|
|
|
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change::Type change = par.lookupChange(i).type;
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (moveItem(par, *tmp, bparams, i, j - pos)) {
|
2003-03-04 19:52:35 +00:00
|
|
|
|
tmp->setChange(j - pos, change);
|
2002-08-20 19:41:13 +00:00
|
|
|
|
++j;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
}
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
2003-07-31 13:12:21 +00:00
|
|
|
|
|
2004-03-28 19:13:11 +00:00
|
|
|
|
for (pos_type i = pos_end; i >= pos; --i)
|
2004-08-13 20:26:26 +00:00
|
|
|
|
par.eraseIntern(i);
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (pos) {
|
|
|
|
|
// Make sure that we keep the language when
|
|
|
|
|
// breaking paragrpah.
|
|
|
|
|
if (tmp->empty()) {
|
2006-02-05 13:20:16 +00:00
|
|
|
|
LyXFont changed = tmp->getFirstFontSettings(bparams);
|
2004-08-13 20:26:26 +00:00
|
|
|
|
LyXFont old = par.getFontSettings(bparams, par.size());
|
|
|
|
|
changed.setLanguage(old.language());
|
|
|
|
|
tmp->setFont(0, changed);
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-12 14:58:06 +00:00
|
|
|
|
return;
|
2004-08-13 20:26:26 +00:00
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
if (!isempty) {
|
|
|
|
|
par.params().clear();
|
|
|
|
|
par.layout(bparams.getLyXTextClass().defaultLayout());
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-12 14:58:06 +00:00
|
|
|
|
// layout stays the same with latex-environments
|
|
|
|
|
if (flag) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
par.layout(tmp->layout());
|
|
|
|
|
par.setLabelWidthString(tmp->params().labelWidthString());
|
|
|
|
|
par.params().depth(tmp->params().depth());
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
// subtle, but needed to get empty pars working right
|
|
|
|
|
if (bparams.tracking_changes) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (!par.size()) {
|
|
|
|
|
par.cleanChanges();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
} else if (!tmp->size()) {
|
|
|
|
|
tmp->cleanChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-06 10:02:40 +00:00
|
|
|
|
void breakParagraphConservative(BufferParams const & bparams,
|
2004-11-24 21:53:46 +00:00
|
|
|
|
ParagraphList & pars, pit_type par_offset, pos_type pos)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
|
|
|
|
// create a new paragraph
|
2006-03-23 20:11:06 +00:00
|
|
|
|
Paragraph & tmp = *pars.insert(boost::next(pars.begin(), par_offset + 1),
|
|
|
|
|
Paragraph());
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph & par = pars[par_offset];
|
|
|
|
|
|
2005-02-24 13:17:45 +00:00
|
|
|
|
if (bparams.tracking_changes)
|
|
|
|
|
tmp.trackChanges();
|
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
tmp.makeSameLayout(par);
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2003-04-29 14:05:54 +00:00
|
|
|
|
// When can pos > size()?
|
|
|
|
|
// I guess pos == size() is possible.
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (par.size() > pos) {
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// copy everything behind the break-position to the new
|
|
|
|
|
// paragraph
|
2004-08-13 20:26:26 +00:00
|
|
|
|
pos_type pos_end = par.size() - 1;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2005-02-24 13:17:45 +00:00
|
|
|
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change::Type change = par.lookupChange(i).type;
|
2005-02-24 13:17:45 +00:00
|
|
|
|
if (moveItem(par, tmp, bparams, i, j - pos, change))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
++j;
|
2005-02-24 13:17:45 +00:00
|
|
|
|
}
|
2006-03-11 13:31:41 +00:00
|
|
|
|
// Move over end-of-par change attr
|
2006-05-08 20:30:52 +00:00
|
|
|
|
tmp.setChange(tmp.size(), par.lookupChange(par.size()).type);
|
2006-03-11 13:31:41 +00:00
|
|
|
|
|
2005-04-26 11:12:20 +00:00
|
|
|
|
// If tracking changes, set all the text that is to be
|
|
|
|
|
// erased to Type::INSERTED.
|
|
|
|
|
for (pos_type k = pos_end; k >= pos; --k) {
|
2005-02-28 07:43:12 +00:00
|
|
|
|
if (bparams.tracking_changes)
|
|
|
|
|
par.setChange(k, Change::INSERTED);
|
|
|
|
|
par.erase(k);
|
|
|
|
|
}
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-06 10:02:40 +00:00
|
|
|
|
void mergeParagraph(BufferParams const & bparams,
|
2004-11-24 21:53:46 +00:00
|
|
|
|
ParagraphList & pars, pit_type par_offset)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph & next = pars[par_offset + 1];
|
|
|
|
|
Paragraph & par = pars[par_offset];
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
pos_type pos_end = next.size() - 1;
|
2004-08-13 20:26:26 +00:00
|
|
|
|
pos_type pos_insert = par.size();
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2006-03-16 06:54:08 +00:00
|
|
|
|
// What happens is the following. Later on, moveItem() will copy
|
|
|
|
|
// over characters from the next paragraph to be inserted into this
|
|
|
|
|
// position. Now, if the first char to be so copied is "red" (i.e.,
|
|
|
|
|
// marked deleted) and the paragraph break is marked "blue",
|
|
|
|
|
// insertChar will trigger (eventually, through record(), and see
|
|
|
|
|
// del() and erase() in changes.C) a "hard" character deletion.
|
|
|
|
|
// Which doesn't make sense of course at this pos, but the effect is
|
|
|
|
|
// to shorten the change range to which this para break belongs, by
|
|
|
|
|
// one. It will (should) remain "orphaned", having no CT info to it,
|
|
|
|
|
// and check() in changes.C will assert. Setting the para break
|
|
|
|
|
// forcibly to "black" prevents this scenario. -- MV 13.3.2006
|
|
|
|
|
par.setChange(par.size(), Change::UNCHANGED);
|
|
|
|
|
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change::Type cr = next.lookupChange(next.size()).type;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
// ok, now copy the paragraph
|
2005-02-24 13:17:45 +00:00
|
|
|
|
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change::Type change = next.lookupChange(i).type;
|
2005-02-24 13:17:45 +00:00
|
|
|
|
if (moveItem(next, par, bparams, i, pos_insert + j, change))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
++j;
|
2005-02-24 13:17:45 +00:00
|
|
|
|
}
|
2006-03-11 13:31:41 +00:00
|
|
|
|
// Move the change status of "carriage return" over
|
|
|
|
|
par.setChange(par.size(), cr);
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2006-03-23 20:11:06 +00:00
|
|
|
|
pars.erase(boost::next(pars.begin(), par_offset + 1));
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type depthHook(pit_type pit,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
ParagraphList const & pars, Paragraph::depth_type depth)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type newpit = pit;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (newpit != 0)
|
2003-04-16 08:12:22 +00:00
|
|
|
|
--newpit;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
while (newpit != 0 && pars[newpit].getDepth() > depth)
|
2003-04-16 08:12:22 +00:00
|
|
|
|
--newpit;
|
2003-04-14 18:35:29 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (pars[newpit].getDepth() > depth)
|
2003-04-16 08:12:22 +00:00
|
|
|
|
return pit;
|
|
|
|
|
|
|
|
|
|
return newpit;
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type outerHook(pit_type par_offset, ParagraphList const & pars)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph const & par = pars[par_offset];
|
|
|
|
|
|
|
|
|
|
if (par.getDepth() == 0)
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return pars.size();
|
2004-08-13 20:26:26 +00:00
|
|
|
|
return depthHook(par_offset, pars, Paragraph::depth_type(par.getDepth() - 1));
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph const & par = pars[par_offset];
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type dhook_offset = depthHook(par_offset, pars, par.getDepth());
|
2004-08-13 20:26:26 +00:00
|
|
|
|
|
|
|
|
|
Paragraph const & dhook = pars[dhook_offset];
|
|
|
|
|
|
|
|
|
|
return dhook_offset == par_offset
|
|
|
|
|
|| dhook.layout() != par.layout()
|
|
|
|
|
|| dhook.getDepth() != par.getDepth();
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
int getEndLabel(pit_type p, ParagraphList const & pars)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type pit = p;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
Paragraph::depth_type par_depth = pars[p].getDepth();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
while (pit != pit_type(pars.size())) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
LyXLayout_ptr const & layout = pars[pit].layout();
|
2003-04-14 18:35:29 +00:00
|
|
|
|
int const endlabeltype = layout->endlabeltype;
|
|
|
|
|
|
2002-08-20 19:41:13 +00:00
|
|
|
|
if (endlabeltype != END_LABEL_NO_LABEL) {
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (p + 1 == pit_type(pars.size()))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
return endlabeltype;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
Paragraph::depth_type const next_depth =
|
|
|
|
|
pars[p + 1].getDepth();
|
2002-08-20 19:41:13 +00:00
|
|
|
|
if (par_depth > next_depth ||
|
2004-03-25 09:16:36 +00:00
|
|
|
|
(par_depth == next_depth && layout != pars[p + 1].layout()))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
return endlabeltype;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (par_depth == 0)
|
|
|
|
|
break;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
pit = outerHook(pit, pars);
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (pit != pit_type(pars.size()))
|
2004-03-25 09:16:36 +00:00
|
|
|
|
par_depth = pars[pit].getDepth();
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
return END_LABEL_NO_LABEL;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
LyXFont const outerFont(pit_type par_offset, ParagraphList const & pars)
|
2003-03-12 11:52:23 +00:00
|
|
|
|
{
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph::depth_type par_depth = pars[par_offset].getDepth();
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont tmpfont(LyXFont::ALL_INHERIT);
|
2003-04-14 18:35:29 +00:00
|
|
|
|
|
|
|
|
|
// Resolve against environment font information
|
2004-11-24 21:53:46 +00:00
|
|
|
|
while (par_offset != pit_type(pars.size())
|
2004-03-27 01:18:51 +00:00
|
|
|
|
&& par_depth
|
|
|
|
|
&& !tmpfont.resolved()) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
par_offset = outerHook(par_offset, pars);
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (par_offset != pit_type(pars.size())) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
tmpfont.realize(pars[par_offset].layout()->font);
|
|
|
|
|
par_depth = pars[par_offset].getDepth();
|
2003-04-14 18:35:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-15 00:11:03 +00:00
|
|
|
|
return tmpfont;
|
|
|
|
|
}
|
2003-08-26 14:50:16 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-19 16:17:52 +00:00
|
|
|
|
/// return the number of InsetOptArg in a paragraph
|
|
|
|
|
int numberOfOptArgs(Paragraph const & par)
|
|
|
|
|
{
|
|
|
|
|
int num = 0;
|
2004-11-26 14:52:54 +00:00
|
|
|
|
|
2004-11-19 16:17:52 +00:00
|
|
|
|
InsetList::const_iterator it = par.insetlist.begin();
|
|
|
|
|
InsetList::const_iterator end = par.insetlist.end();
|
|
|
|
|
for (; it != end ; ++it) {
|
2004-11-26 14:52:54 +00:00
|
|
|
|
if (it->inset->lyxCode() == InsetBase::OPTARG_CODE)
|
2004-11-19 16:17:52 +00:00
|
|
|
|
++num;
|
|
|
|
|
}
|
|
|
|
|
return num;
|
|
|
|
|
}
|