mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
get rid of ownerPar(), which was super slow; fix tabular crash due to recently introduced BOOST_ASSERTs
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8951 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2f298af791
commit
d194cfffa5
@ -316,14 +316,6 @@ LyXText * BufferView::getLyXText() const
|
||||
}
|
||||
|
||||
|
||||
Language const * BufferView::getParentLanguage(InsetOld * inset) const
|
||||
{
|
||||
Paragraph const & par = ownerPar(*buffer(), inset);
|
||||
return par.getFontSettings(buffer()->params(),
|
||||
par.getPositionOfInset(inset)).language();
|
||||
}
|
||||
|
||||
|
||||
void BufferView::haveSelection(bool sel)
|
||||
{
|
||||
pimpl_->workarea().haveSelection(sel);
|
||||
|
@ -108,9 +108,6 @@ public:
|
||||
/// return the lyxtext we are using
|
||||
LyXText * getLyXText() const;
|
||||
|
||||
/// return the parent language of the given inset
|
||||
Language const * getParentLanguage(InsetOld * inset) const;
|
||||
|
||||
/// simple replacing. Use the font of the first selected character
|
||||
void replaceSelectionWithString(std::string const & str);
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
2004-08-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* tabular.C (asciiBottomHLine, asciiPrintCell, asciiTopHLine): fix
|
||||
crash
|
||||
|
||||
* output_plaintext.C (asciiParagraph): set depth correctly
|
||||
|
||||
* outputparams.h: add member depth
|
||||
|
||||
* paragraph_funcs.C (ownerPar): remove.
|
||||
|
||||
* text2.C (setCounter): remove first_pit; comment out some
|
||||
non-working code that uses ownerPar
|
||||
|
||||
* BufferView.C (getParentLanguage): remove. Not used anymore, and
|
||||
uses ownerPar
|
||||
|
||||
2004-08-16 José Matos <jamatos@lyx.org>
|
||||
|
||||
* text.C (readParToken, readParagraph, read): report all unknown tokens.
|
||||
|
@ -1,3 +1,17 @@
|
||||
2004-08-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* insettabular.C (plaintext): do not use ownerPar to get the
|
||||
paragraph depth
|
||||
|
||||
* insettext.C (sanitizeEmptyText): remove. Not sure what it does,
|
||||
and it calls getParentLanguage (which calls ownerPar)
|
||||
(edit): do not call sanitizeEmptyText
|
||||
(priv_dispatch): remove code resetting font on empty inset, for
|
||||
the same reasons as above.
|
||||
|
||||
* insettabular.C (isRightToLeft): instead of using
|
||||
BufferView::getParentLanguage, use the data from the cursor
|
||||
|
||||
2004-08-15 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* pch.h: new file
|
||||
|
@ -376,6 +376,7 @@ void InsetTabular::edit(LCursor & cur, bool left)
|
||||
lyxerr << "InsetTabular::edit: " << this << endl;
|
||||
finishUndo();
|
||||
int cell;
|
||||
cur.push(*this);
|
||||
if (left) {
|
||||
if (isRightToLeft(cur))
|
||||
cell = tabular.getLastCellInRow(0);
|
||||
@ -391,7 +392,6 @@ void InsetTabular::edit(LCursor & cur, bool left)
|
||||
// this accesses the position cache before it is initialized
|
||||
//resetPos(cur);
|
||||
//cur.bv().fitCursor();
|
||||
cur.push(*this);
|
||||
cur.idx() = cell;
|
||||
}
|
||||
|
||||
@ -892,7 +892,7 @@ int InsetTabular::latex(Buffer const & buf, ostream & os,
|
||||
int InsetTabular::plaintext(Buffer const & buf, ostream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
int dp = runparams.linelen ? ownerPar(buf, this).params().depth() : 0;
|
||||
int dp = runparams.linelen ? runparams.depth : 0;
|
||||
return tabular.plaintext(buf, os, runparams, dp, false, 0);
|
||||
}
|
||||
|
||||
@ -1562,9 +1562,13 @@ void InsetTabular::cutSelection(LCursor & cur)
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::isRightToLeft(LCursor & cur)
|
||||
bool InsetTabular::isRightToLeft(LCursor & cur) const
|
||||
{
|
||||
return cur.bv().getParentLanguage(this)->RightToLeft();
|
||||
BOOST_ASSERT(cur.size() > 1);
|
||||
Paragraph const & parentpar = cur[cur.size() - 2].paragraph();
|
||||
LCursor::pos_type const parentpos = cur[cur.size() - 2].pos();
|
||||
return parentpar.getFontSettings(cur.bv().buffer()->params(),
|
||||
parentpos).language()->RightToLeft();
|
||||
}
|
||||
|
||||
|
||||
|
@ -180,7 +180,7 @@ private:
|
||||
///
|
||||
void cutSelection(LCursor & cur);
|
||||
///
|
||||
bool isRightToLeft(LCursor & cur);
|
||||
bool isRightToLeft(LCursor & cur) const;
|
||||
///
|
||||
void getSelection(LCursor & cur,
|
||||
int & rs, int & re, int & cs, int & ce) const;
|
||||
|
@ -273,18 +273,6 @@ string const InsetText::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::sanitizeEmptyText(BufferView & bv)
|
||||
{
|
||||
if (paragraphs().size() == 1
|
||||
&& paragraphs().begin()->empty()
|
||||
&& bv.getParentLanguage(this) != text_.current_font.language()) {
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLanguage(bv.getParentLanguage(this));
|
||||
text_.setFont(bv.cursor(), font, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetText::edit(LCursor & cur, bool left)
|
||||
{
|
||||
//lyxerr << "InsetText: edit left/right" << endl;
|
||||
@ -295,7 +283,6 @@ void InsetText::edit(LCursor & cur, bool left)
|
||||
text_.setCursor(cur.top(), par, pos);
|
||||
cur.clearSelection();
|
||||
finishUndo();
|
||||
sanitizeEmptyText(cur.bv());
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning can someone check if/when this is needed?
|
||||
#endif
|
||||
@ -321,16 +308,6 @@ void InsetText::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
bool was_empty = paragraphs().begin()->empty() && paragraphs().size() == 1;
|
||||
text_.dispatch(cur, cmd);
|
||||
|
||||
// If the action has deleted all text in the inset, we need
|
||||
// to change the language to the language of the surronding
|
||||
// text.
|
||||
// Why this cleverness? (Andre')
|
||||
if (!was_empty && paragraphs().begin()->empty() &&
|
||||
paragraphs().size() == 1) {
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLanguage(cur.bv().getParentLanguage(this));
|
||||
text_.setFont(cur, font, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,9 +150,6 @@ private:
|
||||
void updateLocal(LCursor &);
|
||||
///
|
||||
void init();
|
||||
// If the inset is empty set the language of the current font to the
|
||||
// language to the surronding text (if different).
|
||||
void sanitizeEmptyText(BufferView &);
|
||||
///
|
||||
void setCharFont(Buffer const &, int pos, LyXFont const & font);
|
||||
///
|
||||
|
@ -206,7 +206,9 @@ void asciiParagraph(Buffer const & buf,
|
||||
currlinelen += word.length();
|
||||
word.erase();
|
||||
}
|
||||
if (inset->plaintext(buf, os, runparams)) {
|
||||
OutputParams rp = runparams;
|
||||
rp.depth = par.params().depth();
|
||||
if (inset->plaintext(buf, os, rp)) {
|
||||
// to be sure it breaks paragraph
|
||||
currlinelen += runparams.linelen;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
OutputParams::OutputParams()
|
||||
: flavor(LATEX), nice(false), moving_arg(false),
|
||||
free_spacing(false), use_babel(false),
|
||||
mixed_content(false), linelen(0),
|
||||
mixed_content(false), linelen(0), depth(0),
|
||||
exportdata(new ExportData)
|
||||
{}
|
||||
|
||||
|
@ -75,10 +75,15 @@ struct OutputParams {
|
||||
*/
|
||||
bool mixed_content;
|
||||
|
||||
/** Line length to use with ascii export.
|
||||
/** Line length to use with plaintext export.
|
||||
*/
|
||||
lyx::size_type linelen;
|
||||
|
||||
/** The depth of the current paragraph, set for plaintext
|
||||
* export and used by InsetTabular
|
||||
*/
|
||||
int depth;
|
||||
|
||||
/** Export data filled in by the latex(), docbook() etc methods.
|
||||
This is a hack: Make it possible to add stuff to constant
|
||||
OutputParams instances.
|
||||
|
@ -340,29 +340,6 @@ par_type outerPar(Buffer const & buf, InsetBase const * inset)
|
||||
}
|
||||
|
||||
|
||||
Paragraph const & ownerPar(Buffer const & buf, InsetBase const * inset)
|
||||
{
|
||||
ParConstIterator pit = buf.par_iterator_begin();
|
||||
ParConstIterator end = buf.par_iterator_end();
|
||||
for ( ; pit != end; ++pit) {
|
||||
LyXText * text;
|
||||
// the second '=' below is intentional
|
||||
for (int i = 0; (text = inset->getText(i)); ++i)
|
||||
if (&text->paragraphs() == &pit.plist())
|
||||
return *pit;
|
||||
|
||||
InsetList::const_iterator ii = pit->insetlist.begin();
|
||||
InsetList::const_iterator iend = pit->insetlist.end();
|
||||
for ( ; ii != iend; ++ii)
|
||||
if (ii->inset == inset)
|
||||
return *pit;
|
||||
}
|
||||
lyxerr << "ownerPar: should not happen" << endl;
|
||||
BOOST_ASSERT(false);
|
||||
return buf.paragraphs().front(); // shut up compiler
|
||||
}
|
||||
|
||||
|
||||
/// return the range of pars [beg, end[ owning the range of y [ystart, yend]
|
||||
void getParsInRange(ParagraphList & pars, int ystart, int yend,
|
||||
par_type & beg, par_type & end)
|
||||
|
@ -61,9 +61,6 @@ LyXFont const outerFont(lyx::par_type par, ParagraphList const & plist);
|
||||
/// find outermost paragraph containing an inset
|
||||
lyx::par_type outerPar(Buffer const & buf, InsetBase const * inset);
|
||||
|
||||
/// find owning paragraph containing an inset
|
||||
Paragraph const & ownerPar(Buffer const & buf, InsetBase const * inset);
|
||||
|
||||
/// return the range of pars [beg, end[ owning the range of y [ystart, yend]
|
||||
void getParsInRange(ParagraphList & plist,
|
||||
int ystart, int yend,
|
||||
|
@ -2341,7 +2341,8 @@ int LyXTabular::asciiTopHLine(ostream & os, int row,
|
||||
}
|
||||
int column = column_of_cell(i);
|
||||
int len = clen[column];
|
||||
while (isPartOfMultiColumn(row, ++column))
|
||||
while (column < columns_ - 1
|
||||
&& isPartOfMultiColumn(row, ++column))
|
||||
len += clen[column] + 4;
|
||||
os << string(len, ch);
|
||||
if (topLine(i)) {
|
||||
@ -2388,7 +2389,8 @@ int LyXTabular::asciiBottomHLine(ostream & os, int row,
|
||||
}
|
||||
int column = column_of_cell(i);
|
||||
int len = clen[column];
|
||||
while (isPartOfMultiColumn(row, ++column))
|
||||
while (column < columns_ -1
|
||||
&& isPartOfMultiColumn(row, ++column))
|
||||
len += clen[column] + 4;
|
||||
os << string(len, ch);
|
||||
if (bottomLine(i)) {
|
||||
@ -2426,7 +2428,8 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
|
||||
|
||||
unsigned int len1 = sstr.str().length();
|
||||
unsigned int len2 = clen[column];
|
||||
while (isPartOfMultiColumn(row, ++column))
|
||||
while (column < columns_ -1
|
||||
&& isPartOfMultiColumn(row, ++column))
|
||||
len2 += clen[column] + 4;
|
||||
len2 -= len1;
|
||||
|
||||
|
25
src/text2.C
25
src/text2.C
@ -712,13 +712,12 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
BufferParams const & bufparams = buf.params();
|
||||
LyXTextClass const & textclass = bufparams.getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = par.layout();
|
||||
par_type first_pit = 0;
|
||||
Counters & counters = textclass.counters();
|
||||
|
||||
// Always reset
|
||||
par.itemdepth = 0;
|
||||
|
||||
if (pit == first_pit) {
|
||||
if (pit == 0) {
|
||||
par.params().appendix(par.params().startOfAppendix());
|
||||
} else {
|
||||
par.params().appendix(pars_[pit - 1].params().appendix());
|
||||
@ -729,7 +728,7 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
}
|
||||
|
||||
// Maybe we have to increment the item depth.
|
||||
incrementItemDepth(pars_, pit, first_pit);
|
||||
incrementItemDepth(pars_, pit, 0);
|
||||
}
|
||||
|
||||
// erase what was there before
|
||||
@ -774,7 +773,7 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
par.params().labelString(itemlabel);
|
||||
} else if (layout->labeltype == LABEL_ENUMERATE) {
|
||||
// Maybe we have to reset the enumeration counter.
|
||||
resetEnumCounterIfNeeded(pars_, pit, first_pit, counters);
|
||||
resetEnumCounterIfNeeded(pars_, pit, 0, counters);
|
||||
|
||||
// FIXME
|
||||
// Yes I know this is a really, really! bad solution
|
||||
@ -823,13 +822,25 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
in->lyxCode() == InsetBase::WRAP_CODE) {
|
||||
isOK = true;
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning replace this code by something that works
|
||||
// This code does not work because we have currently no way to move up
|
||||
// in the hierarchy of insets (JMarc 16/08/2004)
|
||||
#endif
|
||||
#if 0
|
||||
/* I think this code is supposed to be useful when one has a caption
|
||||
* in a minipage in a figure inset. We need to go up to be able to see
|
||||
* that the caption sould use "Figure" as label
|
||||
*/
|
||||
else {
|
||||
Paragraph const * owner = &ownerPar(buf, in);
|
||||
tmppit = first_pit;
|
||||
tmppit = 0;
|
||||
for ( ; tmppit != end; ++tmppit)
|
||||
if (&pars_[tmppit] == owner)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (isOK) {
|
||||
@ -893,7 +904,7 @@ void LyXText::updateCounters()
|
||||
}
|
||||
|
||||
|
||||
// this really should just inset the inset and not move the cursor.
|
||||
// this really should just insert the inset and not move the cursor.
|
||||
void LyXText::insertInset(LCursor & cur, InsetBase * inset)
|
||||
{
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
|
Loading…
Reference in New Issue
Block a user