#include "Paragraph.h"
#include "ParagraphParameters.h"
#include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
#include "TextClass.h"
#include "TextMetrics.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-
-#include <boost/scoped_ptr.hpp>
+#include "support/unique_ptr.h"
#include <cstring>
#include <iostream>
///
-boost::scoped_ptr<Tabular> paste_tabular;
+unique_ptr<Tabular> paste_tabular;
struct TabularFeature {
}
-DocIterator separatorPos(InsetTableCell * cell, docstring const & align_d)
+DocIterator separatorPos(InsetTableCell const * cell, docstring const & align_d)
{
DocIterator dit = doc_iterator_begin(&(cell->buffer()), cell);
for (; dit; dit.forwardChar())
dpoint = from_utf8(lyxrc.default_decimal_point);
} else {
cellInfo(cell).alignment = align;
- cellInset(cell).get()->setContentAlignment(align);
+ cellInset(cell)->setContentAlignment(align);
}
}
}
-Tabular::CellData & Tabular::cellInfo(idx_type cell) const
+Tabular::CellData const & Tabular::cellInfo(idx_type cell) const
+{
+ return cell_info[cellRow(cell)][cellColumn(cell)];
+}
+
+
+Tabular::CellData & Tabular::cellInfo(idx_type cell)
{
return cell_info[cellRow(cell)][cellColumn(cell)];
}
// we center in multicol when no decimal point
if (column_info[c].alignment == LYX_ALIGN_DECIMAL) {
docstring const align_d = column_info[c].decimal_point;
- DocIterator const dit = separatorPos(cellInset(cell).get(), align_d);
+ DocIterator const dit = separatorPos(cellInset(cell), align_d);
ismulticol |= !dit;
}
OutputParams const & runparams) const
{
idx_type cell = cellIndex(row, 0);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
string const lang = par.getParLanguage(buffer().params())->lang();
}
TeXCellPreamble(os, cell, ismulticol, ismultirow);
- shared_ptr<InsetTableCell> inset = cellInset(cell);
+ InsetTableCell const * inset = cellInset(cell);
Paragraph const & par = inset->paragraphs().front();
if (getAlignment(cell) == LYX_ALIGN_DECIMAL) {
// copy cell and split in 2
- InsetTableCell head = InsetTableCell(*cellInset(cell).get());
- head.setBuffer(buffer());
+ InsetTableCell head = InsetTableCell(*cellInset(cell));
+ head.setBuffer(const_cast<Buffer &>(buffer()));
DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition();
dit.pop_back();
dit.push_back(CursorSlice(head));
void Tabular::latex(otexstream & os, OutputParams const & runparams) const
{
bool const is_tabular_star = !tabular_width.zero();
- TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid,
- runparams.lastpos);
+ RowEntry pos = TexRow::textEntry(runparams.lastid, runparams.lastpos);
//+---------------------------------------------------------------------
//+ first the opening preamble +
continue;
stringstream attr;
+
+ Length const cwidth = column_info[c].p_width;
+ if (!cwidth.zero()) {
+ string const hwidth = cwidth.asHTMLString();
+ attr << "style =\"width: " << hwidth << ";\" ";
+ }
+
attr << "align='";
switch (getAlignment(cell)) {
case LYX_ALIGN_LEFT:
else if (isMultiRow(cell))
attr << " rowspan='" << rowSpan(cell) << "'";
- xs << html::StartTag(celltag, attr.str()) << html::CR();
+ xs << html::StartTag(celltag, attr.str(), true) << html::CR();
ret += cellInset(cell)->xhtml(xs, runparams);
xs << html::EndTag(celltag) << html::CR();
++cell;
}
-shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell) const
+shared_ptr<InsetTableCell> Tabular::cellInset(idx_type cell)
{
return cell_info[cellRow(cell)][cellColumn(cell)].inset;
}
-shared_ptr<InsetTableCell> Tabular::cellInset(row_type row,
- col_type column) const
+shared_ptr<InsetTableCell> Tabular::cellInset(row_type row, col_type column)
{
return cell_info[row][column].inset;
}
+InsetTableCell const * Tabular::cellInset(idx_type cell) const
+{
+ return cell_info[cellRow(cell)][cellColumn(cell)].inset.get();
+}
+
+
void Tabular::setCellInset(row_type row, col_type column,
- shared_ptr<InsetTableCell> ins) const
+ shared_ptr<InsetTableCell> ins)
{
CellData & cd = cell_info[row][column];
cd.inset = ins;
{
bool enabled = true;
switch (cmd.action()) {
- case LFUN_LAYOUT:
- enabled = !forcePlainLayout();
- break;
- case LFUN_LAYOUT_PARAGRAPH:
- enabled = allowParagraphCustomization();
- break;
-
case LFUN_MATH_DISPLAY:
if (!hasFixedWidth()) {
enabled = false;
InsetTabular::InsetTabular(InsetTabular const & tab)
- : Inset(tab), tabular(tab.tabular)
+ : Inset(tab), tabular(tab.tabular),
+ first_visible_cell_(0), offset_valign_(0), rowselect_(false), colselect_(false)
{
}
// determine horizontal offset because of decimal align (if necessary)
int decimal_width = 0;
if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
- InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell).get());
+ InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell));
tail.setBuffer(tabular.buffer());
// we need to set macrocontext position everywhere
// otherwise we crash with nested insets (e.g. footnotes)
int const y0 = yo(bv) - tabular.rowAscent(0) + offset_valign_;
// FIXME: using ADD_TO_TABULAR_WIDTH is not really correct since
// there is no margin added vertically to tabular insets.
- // Howerver, it works for now.
+ // However, it works for now.
return y < y0 + ADD_TO_TABULAR_WIDTH || y > y0 + tabular.height() - ADD_TO_TABULAR_WIDTH;
}
cur.idx() = tabular.getLastCellInRow(r);
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- cur.setSelection(true);
+ cur.selection(true);
bvcur = cur;
rowselect_ = true;
break;
cur.idx() = tabular.cellIndex(tabular.nrows() - 1, c);
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- cur.setSelection(true);
+ cur.selection(true);
bvcur = cur;
colselect_ = true;
break;
cur.pit() = 0;
cur.pos() = 0;
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
break;
}
// select (additional) column
cur.pit() = 0;
cur.pos() = 0;
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
break;
}
// only update if selection changes
cur.noScreenUpdate();
setCursorFromCoordinates(cur, cmd.x(), cmd.y());
bvcur.setCursor(cur);
- bvcur.setSelection(true);
+ bvcur.selection(true);
// if this is a multicell selection, we just set the cursor to
// the beginning of the cell's text.
if (bvcur.selIsMultiCell()) {
case LFUN_CELL_BACKWARD:
movePrevCell(cur);
- cur.setSelection(false);
+ cur.selection(false);
break;
case LFUN_CELL_FORWARD:
moveNextCell(cur);
- cur.setSelection(false);
+ cur.selection(false);
break;
case LFUN_CHAR_FORWARD_SELECT:
}
// check if there is already a caption
bool have_caption = false;
- InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()).get());
+ InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()));
ParagraphList::const_iterator pit = itc.paragraphs().begin();
ParagraphList::const_iterator pend = itc.paragraphs().end();
for (; pit != pend; ++pit) {
Inset * InsetTabular::editXY(Cursor & cur, int x, int y)
{
//lyxerr << "InsetTabular::editXY: " << this << endl;
- cur.setSelection(false);
+ cur.selection(false);
cur.push(*this);
cur.idx() = getNearestCell(cur.bv(), x, y);
return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y);
cur.idx() = tabular.cellIndex(sel_row_start, column);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
case Tabular::DELETE_COLUMN:
cur.idx() = tabular.cellIndex(row, sel_col_start);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
case Tabular::COPY_ROW:
tabular.rightLine(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
}
tabular.getAlignment(cur.selEnd().idx()));
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
break;
}
cur.idx() = tabular.setLTCaption(row, true);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
// If a row is set as caption, then also insert
// a caption. Otherwise the LaTeX output is broken.
// Select cell if it is non-empty
cur.idx() = tabular.setLTCaption(row, false);
cur.pit() = 0;
cur.pos() = 0;
- cur.setSelection(false);
+ cur.selection(false);
FuncRequest fr(LFUN_INSET_DISSOLVE, "caption");
if (lyx::getStatus(fr).enabled())
lyx::dispatch(fr);