}
-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);
/// 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);
+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.
+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
lyxerr << "InsetTabular::edit: " << this << endl;
finishUndo();
int cell;
+ cur.push(*this);
if (left) {
if (isRightToLeft(cur))
cell = tabular.getLastCellInRow(0);
// this accesses the position cache before it is initialized
//resetPos(cur);
//cur.bv().fitCursor();
- cur.push(*this);
cur.idx() = cell;
}
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);
}
}
-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();
}
///
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;
}
-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;
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
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);
- }
}
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);
///
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;
}
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)
{}
*/
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.
}
-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)
/// 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,
}
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)) {
}
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)) {
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;
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());
}
// Maybe we have to increment the item depth.
- incrementItemDepth(pars_, pit, first_pit);
+ incrementItemDepth(pars_, pit, 0);
}
// erase what was there before
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
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) {
}
-// 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());