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-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-03-25 09:16:36 +00:00
|
|
|
|
using lyx::par_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,
|
|
|
|
|
BufferParams const & params, pos_type i, pos_type j)
|
|
|
|
|
{
|
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)
|
|
|
|
|
to.insertInset(j, tmpinset, tmpfont);
|
2003-07-31 13:12:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (!to.checkInsertChar(tmpfont))
|
|
|
|
|
return false;
|
|
|
|
|
to.insertChar(j, tmpchar, tmpfont);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-06 10:02:40 +00:00
|
|
|
|
void breakParagraph(BufferParams const & bparams,
|
2004-08-13 20:26:26 +00:00
|
|
|
|
ParagraphList & pars, par_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 =
|
2004-08-13 20:26:26 +00:00
|
|
|
|
pars.insert(pars.begin() + par_offset + 1, Paragraph());
|
|
|
|
|
|
|
|
|
|
Paragraph & par = pars[par_offset];
|
2003-03-04 21:40:36 +00:00
|
|
|
|
|
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());
|
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) {
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Change::Type change = par.lookupChange(i);
|
|
|
|
|
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()) {
|
|
|
|
|
LyXFont changed = tmp->getFirstFontSettings();
|
|
|
|
|
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
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
par.params().clear();
|
2002-08-20 19:41:13 +00:00
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
par.layout(bparams.getLyXTextClass().defaultLayout());
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
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-08-13 20:26:26 +00:00
|
|
|
|
ParagraphList & pars, par_type par_offset, pos_type pos)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
|
|
|
|
// create a new paragraph
|
2004-08-13 20:26:26 +00:00
|
|
|
|
Paragraph & tmp = *pars.insert(pars.begin() + par_offset + 1, Paragraph());
|
|
|
|
|
Paragraph & par = pars[par_offset];
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2003-07-31 13:12:21 +00:00
|
|
|
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i)
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (moveItem(par, tmp, bparams, i, j - pos))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
++j;
|
2002-08-21 17:35:24 +00:00
|
|
|
|
|
2003-07-31 13:12:21 +00:00
|
|
|
|
for (pos_type k = pos_end; k >= pos; --k)
|
2004-08-13 20:26:26 +00:00
|
|
|
|
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-08-13 20:26:26 +00:00
|
|
|
|
ParagraphList & pars, par_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
|
|
|
|
|
|
|
|
|
// ok, now copy the paragraph
|
2003-07-31 13:12:21 +00:00
|
|
|
|
for (pos_type i = 0, j = 0; i <= pos_end; ++i)
|
2004-08-13 20:26:26 +00:00
|
|
|
|
if (moveItem(next, par, bparams, i, pos_insert + j))
|
2002-08-20 19:41:13 +00:00
|
|
|
|
++j;
|
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
pars.erase(pars.begin() + par_offset + 1);
|
2002-08-20 19:41:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
par_type depthHook(par_type pit,
|
|
|
|
|
ParagraphList const & pars, Paragraph::depth_type depth)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
par_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-08-13 20:26:26 +00:00
|
|
|
|
par_type outerHook(par_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-08-13 20:26:26 +00:00
|
|
|
|
bool isFirstInSequence(par_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];
|
|
|
|
|
|
|
|
|
|
par_type dhook_offset = depthHook(par_offset, pars, par.getDepth());
|
|
|
|
|
|
|
|
|
|
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-03-25 09:16:36 +00:00
|
|
|
|
int getEndLabel(par_type p, ParagraphList const & pars)
|
2002-08-20 19:41:13 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
par_type pit = p;
|
|
|
|
|
Paragraph::depth_type par_depth = pars[p].getDepth();
|
2004-03-27 01:18:51 +00:00
|
|
|
|
while (pit != par_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-03-27 01:18:51 +00:00
|
|
|
|
if (p + 1 == par_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-03-27 01:18:51 +00:00
|
|
|
|
if (pit != par_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-08-13 20:26:26 +00:00
|
|
|
|
LyXFont const outerFont(par_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-08-13 20:26:26 +00:00
|
|
|
|
while (par_offset != par_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);
|
|
|
|
|
if (par_offset != par_type(pars.size())) {
|
|
|
|
|
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-03-25 09:16:36 +00:00
|
|
|
|
par_type outerPar(Buffer const & buf, InsetBase const * inset)
|
2003-08-26 14:50:16 +00:00
|
|
|
|
{
|
2003-08-26 16:36:53 +00:00
|
|
|
|
ParIterator pit = const_cast<Buffer &>(buf).par_iterator_begin();
|
|
|
|
|
ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
|
2003-08-26 14:50:16 +00:00
|
|
|
|
for ( ; pit != end; ++pit) {
|
2003-12-03 18:17:20 +00:00
|
|
|
|
LyXText * text;
|
2003-08-27 13:32:26 +00:00
|
|
|
|
// the second '=' below is intentional
|
2003-12-03 18:17:20 +00:00
|
|
|
|
for (int i = 0; (text = inset->getText(i)); ++i)
|
|
|
|
|
if (&text->paragraphs() == &pit.plist())
|
2003-08-27 13:32:26 +00:00
|
|
|
|
return pit.outerPar();
|
|
|
|
|
|
2004-05-17 11:28:31 +00:00
|
|
|
|
InsetList::const_iterator ii = pit->insetlist.begin();
|
|
|
|
|
InsetList::const_iterator iend = pit->insetlist.end();
|
2003-08-26 14:50:16 +00:00
|
|
|
|
for ( ; ii != iend; ++ii)
|
|
|
|
|
if (ii->inset == inset)
|
|
|
|
|
return pit.outerPar();
|
|
|
|
|
}
|
2003-08-27 13:32:26 +00:00
|
|
|
|
lyxerr << "outerPar: should not happen" << endl;
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return buf.paragraphs().size(); // shut up compiler
|
2003-08-26 14:50:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-26 16:36:53 +00:00
|
|
|
|
|
2004-04-03 08:37:12 +00:00
|
|
|
|
/// return the range of pars [beg, end[ owning the range of y [ystart, yend]
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void getParsInRange(ParagraphList & pars, int ystart, int yend,
|
|
|
|
|
par_type & beg, par_type & end)
|
2003-11-10 18:15:55 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
BOOST_ASSERT(!pars.empty());
|
|
|
|
|
par_type const endpar = pars.size();
|
|
|
|
|
par_type const begpar = 0;
|
2003-11-10 18:15:55 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
for (beg = endpar - 1; beg != begpar && pars[beg].y > ystart; --beg)
|
2003-11-10 18:15:55 +00:00
|
|
|
|
;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
for (end = beg ; end != endpar && pars[end].y <= yend; ++end)
|
2003-11-10 18:15:55 +00:00
|
|
|
|
;
|
|
|
|
|
}
|