#include "Language.h"
#include "LaTeXFeatures.h"
#include "Color.h"
-#include "lyx_cb.h"
+#include "callback.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "support/convert.h"
#include "support/lstrings.h"
-#include "frontends/Alert.h"
+#include "frontends/alert.h"
#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
{ Tabular::SET_MPWIDTH, "set-mpwidth" },
{ Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
{ Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
+ { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular" },
{ Tabular::SET_ROTATE_CELL, "set-rotate-cell" },
{ Tabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
+ { Tabular::TOGGLE_ROTATE_CELL, "toggle-rotate-cell" },
{ Tabular::SET_USEBOX, "set-usebox" },
{ Tabular::SET_LTHEAD, "set-lthead" },
{ Tabular::UNSET_LTHEAD, "unset-lthead" },
template <>
-string const write_attribute(string const & name, LyXLength const & value)
+string const write_attribute(string const & name, Length const & value)
{
// we write only the value if we really have one same reson as above.
return value.zero() ? string() : write_attribute(name, value.asString());
}
-bool getTokenValue(string const & str, char const * token, LyXLength & len)
+bool getTokenValue(string const & str, char const * token, Length & len)
{
// set the lenght to be zero() as default as this it should be if not
// in the file format.
- len = LyXLength();
+ len = Length();
string tmp;
return getTokenValue(str, token, tmp) && isValidLength(tmp, &len);
}
-bool getTokenValue(string const & str, char const * token, LyXLength & len, bool & flag)
+bool getTokenValue(string const & str, char const * token, Length & len, bool & flag)
{
- len = LyXLength();
+ len = Length();
flag = false;
string tmp;
if (!getTokenValue(str, token, tmp))
return false;
if (!wholecolumn && isMultiColumn(cell) &&
(isFirstCellInRow(cell) || isMultiColumn(cell-1)))
- {
- if (cellinfo_of_cell(cell).align_special.empty())
- return cellinfo_of_cell(cell).left_line;
- return prefixIs(ltrim(cellinfo_of_cell(cell).align_special), '|');
- }
- if (column_info[column_of_cell(cell)].align_special.empty())
- return column_info[column_of_cell(cell)].left_line;
- return prefixIs(ltrim(column_info[column_of_cell(cell)].align_special), '|');
+ return cellinfo_of_cell(cell).left_line;
+ return column_info[column_of_cell(cell)].left_line;
}
return false;
if (!wholecolumn && isMultiColumn(cell) &&
(isLastCellInRow(cell) || isMultiColumn(cell + 1)))
- {
- if (cellinfo_of_cell(cell).align_special.empty())
- return cellinfo_of_cell(cell).right_line;
- return suffixIs(rtrim(cellinfo_of_cell(cell).align_special), '|');
- }
- if (column_info[column_of_cell(cell)].align_special.empty())
- return column_info[right_column_of_cell(cell)].right_line;
- return suffixIs(rtrim(column_info[column_of_cell(cell)].align_special), '|');
+ return cellinfo_of_cell(cell).right_line;
+ return column_info[right_column_of_cell(cell)].right_line;
}
cur.push(*inset);
// undo information has already been recorded
inset->getText(0)->setLayout(*cur.bv().buffer(), 0, cur.lastpit() + 1,
- bp.getLyXTextClass().defaultLayoutName());
+ bp.getTextClass().defaultLayoutName());
cur.pop();
}
void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
- LyXLength const & width)
+ Length const & width)
{
col_type const j = column_of_cell(cell);
bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell,
- LyXLength const & width)
+ Length const & width)
{
if (!isMultiColumn(cell))
return false;
}
-LyXLength const Tabular::getPWidth(idx_type cell) const
+Length const Tabular::getPWidth(idx_type cell) const
{
if (isMultiColumn(cell))
return cellinfo_of_cell(cell).p_width;
}
-LyXLength const Tabular::getColumnPWidth(idx_type cell) const
+Length const Tabular::getColumnPWidth(idx_type cell) const
{
return column_info[column_of_cell(cell)].p_width;
}
-LyXLength const Tabular::getMColumnPWidth(idx_type cell) const
+Length const Tabular::getMColumnPWidth(idx_type cell) const
{
if (isMultiColumn(cell))
return cellinfo_of_cell(cell).p_width;
- return LyXLength();
+ return Length();
}
}
if (isMultiColumn(cell)) {
os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
+ if (leftLine(cell) &&
+ (isFirstCellInRow(cell) ||
+ (!isMultiColumn(cell - 1) && !leftLine(cell, true) &&
+ !rightLine(cell - 1, true))))
+ os << '|';
if (!cellinfo_of_cell(cell).align_special.empty()) {
- os << cellinfo_of_cell(cell).align_special << "}{";
+ os << cellinfo_of_cell(cell).align_special;
} else {
- if (leftLine(cell) &&
- (isFirstCellInRow(cell) ||
- (!isMultiColumn(cell - 1) && !leftLine(cell, true) &&
- !rightLine(cell - 1, true))))
- {
- os << '|';
- }
if (!getPWidth(cell).zero()) {
switch (getVAlignment(cell)) {
case LYX_VALIGN_TOP:
os << 'c';
break;
}
- }
- if (rightLine(cell))
- os << '|';
- if (((cell + 1) < numberofcells) && !isFirstCellInRow(cell+1) &&
- leftLine(cell+1))
- os << '|';
- os << "}{";
+ } // end if else !getPWidth
+ } // end if else !cellinfo_of_cell
+ if (rightLine(cell))
+ os << '|';
+ if (((cell + 1) < numberofcells) && !isFirstCellInRow(cell+1) &&
+ leftLine(cell+1))
+ os << '|';
+ os << "}{";
}
- }
if (getUsebox(cell) == BOX_PARBOX) {
os << "\\parbox[";
switch (getVAlignment(cell)) {
else
os << "\\begin{tabular}{";
for (col_type i = 0; i < columns_; ++i) {
+ if (!use_booktabs && column_info[i].left_line)
+ os << '|';
if (!column_info[i].align_special.empty()) {
os << column_info[i].align_special;
} else {
- if (!use_booktabs && column_info[i].left_line)
- os << '|';
if (!column_info[i].p_width.zero()) {
switch (column_info[i].alignment) {
case LYX_ALIGN_LEFT:
os << 'c';
break;
}
- }
- if (!use_booktabs && column_info[i].right_line)
- os << '|';
- }
+ } // end if else !column_info[i].p_width
+ } // end if else !column_info[i].align_special
+ if (!use_booktabs && column_info[i].right_line)
+ os << '|';
}
os << "}\n";
++ret;
Tabular::idx_type
-Tabular::getCellFromInset(InsetBase const * inset) const
+Tabular::getCellFromInset(Inset const * inset) const
{
// is this inset part of the tabular?
if (!inset) {
InsetTabular::InsetTabular(InsetTabular const & tab)
- : InsetOld(tab), tabular(tab.tabular),
+ : Inset(tab), tabular(tab.tabular),
buffer_(tab.buffer_), scx_(0), is_deleted_(false)
{}
}
-auto_ptr<InsetBase> InsetTabular::doClone() const
+auto_ptr<Inset> InsetTabular::doClone() const
{
- return auto_ptr<InsetBase>(new InsetTabular(*this));
+ return auto_ptr<Inset>(new InsetTabular(*this));
}
continue;
Dimension dim;
MetricsInfo m = mi;
- LyXLength p_width;
+ Length p_width;
if (tabular.cell_info[i][j].multicolumn ==
Tabular::CELL_BEGIN_OF_MULTICOLUMN)
p_width = tabular.cellinfo_of_cell(cell).p_width;
Color::color onoffcol = Color::tabularonoffline;
if (erased) {
- col = Color::strikeout;
- onoffcol = Color::strikeout;
+ col = Color::deletedtext;
+ onoffcol = Color::deletedtext;
}
if (!tabular.topAlreadyDrawn(cell)) {
if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
- // See comment in LyXText::dispatch why we
+ // See comment in Text::dispatch why we
// do this
// FIXME This does not use paste_tabular,
// another reason why paste_tabular should go.
cell(cur.idx())->dispatch(cur, cmd);
cur.dispatched(); // override the cell's decision
if (sl == cur.top())
- // if our LyXText didn't do anything to the cursor
+ // if our Text didn't do anything to the cursor
// then we try to put the cursor into the cell below
// setting also the right targetX.
if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
cell(cur.idx())->dispatch(cur, cmd);
cur.dispatched(); // override the cell's decision
if (sl == cur.top())
- // if our LyXText didn't do anything to the cursor
+ // if our Text didn't do anything to the cursor
// then we try to put the cursor into the cell above
// setting also the right targetX.
if (tabular.row_of_cell(cur.idx()) != 0) {
cur.idx() = tabular.getCellAbove(cur.idx());
cur.pit() = cur.lastpit();
- LyXText const * text = cell(cur.idx())->getText(0);
+ Text const * text = cell(cur.idx())->getText(0);
TextMetrics const & tm = cur.bv().textMetrics(text);
ParagraphMetrics const & pm =
tm.parMetrics(cur.lastpit());
row_type sel_row_start = 0;
row_type sel_row_end = 0;
- col_type dummy;
+ col_type sel_col_start = 0;
+ col_type sel_col_end = 0;
Tabular::ltType dummyltt;
bool flag = true;
- getSelection(cur, sel_row_start, sel_row_end, dummy, dummy);
+ getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
switch (action) {
case Tabular::SET_PWIDTH:
status.setOnOff(!tabular.isLongTabular());
break;
+ case Tabular::TOGGLE_ROTATE_TABULAR:
case Tabular::SET_ROTATE_TABULAR:
status.setOnOff(tabular.getRotateTabular());
break;
status.setOnOff(!tabular.getRotateTabular());
break;
+ case Tabular::TOGGLE_ROTATE_CELL:
case Tabular::SET_ROTATE_CELL:
- status.setOnOff(tabular.getRotateCell(cur.idx()));
+ status.setOnOff(!oneCellHasRotationState(false,
+ sel_row_start, sel_row_end, sel_col_start, sel_col_end));
break;
case Tabular::UNSET_ROTATE_CELL:
- status.setOnOff(!tabular.getRotateCell(cur.idx()));
+ status.setOnOff(!oneCellHasRotationState(true,
+ sel_row_start, sel_row_end, sel_col_start, sel_col_end));
break;
case Tabular::SET_USEBOX:
OutputParams const & runparams) const
{
int ret = 0;
- InsetBase * master = 0;
+ Inset * master = 0;
#ifdef WITH_WARNINGS
#warning Why not pass a proper DocIterator here?
// if the table is inside a float it doesn't need the informaltable
// wrapper. Search for it.
for (master = owner(); master; master = master->owner())
- if (master->lyxCode() == InsetBase::FLOAT_CODE)
+ if (master->lyxCode() == Inset::FLOAT_CODE)
break;
#endif
{
int xx = 0;
int yy = 0;
- InsetBase const & inset = *tabular.getCellInset(cell);
+ Inset const & inset = *tabular.getCellInset(cell);
Point o = bv.coordCache().getInsets().xy(&inset);
int const xbeg = o.x_ - tabular.getBeginningOfTextInCell(cell);
int const xend = xbeg + tabular.getWidthOfColumn(cell);
}
-InsetBase * InsetTabular::editXY(Cursor & cur, int x, int y)
+Inset * InsetTabular::editXY(Cursor & cur, int x, int y)
{
//lyxerr << "InsetTabular::editXY: " << this << endl;
cur.selection() = false;
}
}
+bool InsetTabular::oneCellHasRotationState(bool rotated,
+ row_type row_start, row_type row_end,
+ col_type col_start, col_type col_end) const {
+
+ for (row_type i = row_start; i <= row_end; ++i) {
+ for (col_type j = col_start; j <= col_end; ++j) {
+ if (tabular.getRotateCell(tabular.getCellNumber(i, j))
+ == rotated) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
void InsetTabular::tabularFeatures(Cursor & cur,
Tabular::Feature feature, string const & value)
switch (feature) {
case Tabular::SET_PWIDTH: {
- LyXLength const len(value);
+ Length const len(value);
tabular.setColumnPWidth(cur, cur.idx(), len);
if (len.zero()
&& tabular.getAlignment(cur.idx(), true) == LYX_ALIGN_BLOCK)
}
case Tabular::SET_MPWIDTH:
- tabular.setMColumnPWidth(cur, cur.idx(), LyXLength(value));
+ tabular.setMColumnPWidth(cur, cur.idx(), Length(value));
break;
case Tabular::SET_SPECIAL_COLUMN:
tabular.setRotateTabular(false);
break;
+ case Tabular::TOGGLE_ROTATE_TABULAR:
+ tabular.setRotateTabular(!tabular.getRotateTabular());
+ break;
+
case Tabular::SET_ROTATE_CELL:
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
for (col_type j = sel_col_start; j <= sel_col_end; ++j)
tabular.getCellNumber(i, j), false);
break;
+ case Tabular::TOGGLE_ROTATE_CELL:
+ {
+ bool oneNotRotated = oneCellHasRotationState(false,
+ sel_row_start, sel_row_end, sel_col_start, sel_col_end);
+
+ for (row_type i = sel_row_start; i <= sel_row_end; ++i)
+ for (col_type j = sel_col_start; j <= sel_col_end; ++j)
+ tabular.setRotateCell(tabular.getCellNumber(i, j),
+ oneNotRotated);
+ }
+ break;
+
case Tabular::SET_USEBOX: {
Tabular::BoxType val = Tabular::BoxType(convert<int>(value));
if (val == tabular.getUsebox(cur.idx()))
break;
case Tabular::SET_TOP_SPACE: {
- LyXLength len;
+ Length len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].top_space_default = true;
}
case Tabular::SET_BOTTOM_SPACE: {
- LyXLength len;
+ Length len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].bottom_space_default = true;
}
case Tabular::SET_INTERLINE_SPACE: {
- LyXLength len;
+ Length len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].interline_space_default = true;
}
-LyXText * InsetTabular::getText(int idx) const
+Text * InsetTabular::getText(int idx) const
{
return size_t(idx) < nargs() ? cell(idx)->getText(0) : 0;
}
if (cols < columns) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell);
Paragraph & par = inset->text_.getPar(0);
- LyXFont const font = inset->text_.getFont(buffer, par, 0);
+ Font const font = inset->text_.getFont(buffer, par, 0);
inset->setText(buf.substr(op, p - op), font,
buffer.params().trackChanges);
++cols;
if (cols < columns) {
shared_ptr<InsetText> inset = tabular.getCellInset(cell);
Paragraph & par = inset->text_.getPar(0);
- LyXFont const font = inset->text_.getFont(buffer, par, 0);
+ Font const font = inset->text_.getFont(buffer, par, 0);
inset->setText(buf.substr(op, p - op), font,
buffer.params().trackChanges);
}
if (cell < cells && op < len) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell);
Paragraph & par = inset->text_.getPar(0);
- LyXFont const font = inset->text_.getFont(buffer, par, 0);
+ Font const font = inset->text_.getFont(buffer, par, 0);
inset->setText(buf.substr(op, len - op), font,
buffer.params().trackChanges);
}