+2005-11-28 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * text2.C (setLayout): move recUndo call to other setLayout method
+ * tabular.C (toggleFixedWidth): new, handle cell width changes
+ * tabular.C (setColumnPWidth): move some code from insettabular.C here
+ and use toggleFixedWidth
+ * tabular.C (setMColumnPWidth): ditto
+
2005-11-25 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* paragraph.C (asString): use new inset->textString method (fix bug 2089)
+2005-11-28 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * insettabular.C (tabularFeatures): Move some code to
+ setColumnPWidth and setMColumnPWidth
+
2005-11-25 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetbase.h:
case LyXTabular::SET_PWIDTH: {
LyXLength const len(value);
- tabular.setColumnPWidth(cur.idx(), len);
- // cur position can become invalid after newlines were removed
- if (cur.pos() > cur.lastpos())
- cur.pos() = cur.lastpos();
+ tabular.setColumnPWidth(cur, cur.idx(), len);
if (len.zero()
&& tabular.getAlignment(cur.idx(), true) == LYX_ALIGN_BLOCK)
tabularFeatures(cur, LyXTabular::ALIGN_CENTER, string());
}
case LyXTabular::SET_MPWIDTH:
- tabular.setMColumnPWidth(cur.idx(), LyXLength(value));
- // cur position can become invalid after newlines were removed
- if (cur.pos() > cur.lastpos())
- cur.pos() = cur.lastpos();
+ tabular.setMColumnPWidth(cur, cur.idx(), LyXLength(value));
break;
case LyXTabular::SET_SPECIAL_COLUMN:
void breakParagraph(LCursor & cur, bool keep_layout = false);
/// set layout over selection
- pit_type setLayout(pit_type start, pit_type end,
+ void setLayout(pit_type start, pit_type end,
std::string const & layout);
///
void setLayout(LCursor & cur, std::string const & layout);
#include "buffer.h"
#include "bufferparams.h"
+#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
#include "LaTeXFeatures.h"
#include "lyxlex.h"
#include "outputparams.h"
#include "paragraph.h"
+#include "paragraph_funcs.h"
#include "insets/insettabular.h"
}
-void LyXTabular::setColumnPWidth(idx_type cell, LyXLength const & width)
+namespace {
+
+/**
+ * Allow line and paragraph breaks for fixed width cells or disallow them,
+ * merge cell paragraphs and reset layout to standard for variable width
+ * cells.
+ */
+void toggleFixedWidth(LCursor & cur, InsetText * inset, bool fixedWidth)
+{
+ inset->setAutoBreakRows(fixedWidth);
+ if (fixedWidth)
+ return;
+
+ // merge all paragraphs to one
+ BufferParams const & bp =
+ inset->getText(0)->bv_owner->buffer()->params();
+ while (inset->paragraphs().size() > 1)
+ mergeParagraph(bp, inset->paragraphs(), 0);
+
+ // reset layout
+ cur.push(*inset);
+ inset->getText(0)->setLayout(0, cur.lastpit() + 1, "Standard");
+ cur.pop();
+}
+
+}
+
+
+void LyXTabular::setColumnPWidth(LCursor & cur, idx_type cell,
+ LyXLength const & width)
{
col_type const j = column_of_cell(cell);
for (row_type i = 0; i < rows_; ++i) {
idx_type const cell = getCellNumber(i, j);
// because of multicolumns
- getCellInset(cell)->setAutoBreakRows(!getPWidth(cell).zero());
+ toggleFixedWidth(cur, getCellInset(cell).get(),
+ !getPWidth(cell).zero());
}
+ // cur paragraph can become invalid after paragraphs were merged
+ if (cur.pit() > cur.lastpit())
+ cur.pit() = cur.lastpit();
+ // cur position can become invalid after newlines were removed
+ if (cur.pos() > cur.lastpos())
+ cur.pos() = cur.lastpos();
}
-bool LyXTabular::setMColumnPWidth(idx_type cell, LyXLength const & width)
+bool LyXTabular::setMColumnPWidth(LCursor & cur, idx_type cell,
+ LyXLength const & width)
{
if (!isMultiColumn(cell))
return false;
cellinfo_of_cell(cell).p_width = width;
- getCellInset(cell)->setAutoBreakRows(!width.zero());
+ toggleFixedWidth(cur, getCellInset(cell).get(), !width.zero());
+ // cur paragraph can become invalid after paragraphs were merged
+ if (cur.pit() > cur.lastpit())
+ cur.pit() = cur.lastpit();
+ // cur position can become invalid after newlines were removed
+ if (cur.pos() > cur.lastpos())
+ cur.pos() = cur.lastpos();
return true;
}
#include <vector>
class InsetTabular;
+class LCursor;
class OutputParams;
/* The features the text class offers for tables */
void setVAlignment(idx_type cell, VAlignment align,
bool onlycolumn = false);
///
- void setColumnPWidth(idx_type cell, LyXLength const & width);
+ void setColumnPWidth(LCursor &, idx_type, LyXLength const &);
///
- bool setMColumnPWidth(idx_type cell, LyXLength const & width);
+ bool setMColumnPWidth(LCursor &, idx_type, LyXLength const &);
///
void setAlignSpecial(idx_type cell, std::string const & special,
Feature what);
}
-pit_type LyXText::setLayout(pit_type start, pit_type end, string const & layout)
+void LyXText::setLayout(pit_type start, pit_type end, string const & layout)
{
BOOST_ASSERT(start != end);
- pit_type undopit = undoSpan(end - 1);
- recUndo(start, undopit - 1);
BufferParams const & bufparams = bv()->buffer()->params();
LyXLayout_ptr const & lyxlayout = bufparams.getLyXTextClass()[layout];
if (lyxlayout->margintype == MARGIN_MANUAL)
pars_[pit].setLabelWidthString(lyxlayout->labelstring());
}
-
- return undopit;
}
pit_type start = cur.selBegin().pit();
pit_type end = cur.selEnd().pit() + 1;
+ pit_type undopit = undoSpan(end - 1);
+ recUndo(start, undopit - 1);
setLayout(start, end, layout);
updateCounters(cur.buffer());
}