mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
GuiTabular: support for multirow offset; fileformat change
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36182 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
780a8c4bc7
commit
86b99f8f32
@ -7,6 +7,11 @@ The good example would be 2010-01-10 entry.
|
||||
|
||||
-----------------------
|
||||
|
||||
2010-11-07 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 407: support for vertical offset of
|
||||
multirow cells
|
||||
new tag "mroffset" for multirow chells with an offset
|
||||
|
||||
2010-11-06 Richard Heck <rgheck@comcast.net> and
|
||||
Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
* Format incremented to 406: ??
|
||||
|
@ -2085,6 +2085,70 @@ def revert_passthru(document):
|
||||
end = newend
|
||||
beg = end + 1
|
||||
|
||||
|
||||
def revert_multirowOffset(document):
|
||||
" Revert multirow cells with offset in tables to TeX-code"
|
||||
i = 0
|
||||
multirowOffset = False
|
||||
while True:
|
||||
# cell type 3 is multirow begin cell
|
||||
i = find_token(document.body, '<cell multirow="3" mroffset=', i)
|
||||
if i == -1:
|
||||
break
|
||||
# a multirow cell with offset was found
|
||||
multirowOffset = True
|
||||
# remove the multirow tag, set the valignment to top
|
||||
# the the bottom line and offset
|
||||
document.body[i] = document.body[i].replace(' multirow="3" ', ' ')
|
||||
document.body[i] = document.body[i].replace('valignment="middle"', 'valignment="top"')
|
||||
document.body[i] = document.body[i].replace(' bottomline="true" ', ' ')
|
||||
document.body[i] = document.body[i].replace(' mroffset=', '')
|
||||
# store the offset and remove it
|
||||
begin = document.body[i].find('"')
|
||||
end = document.body[i].find('" ', begin)
|
||||
offset = document.body[i][begin + 1:end]
|
||||
document.body[i] = document.body[i].replace(document.body[i][begin:end + 1], '')
|
||||
# write ERT to create the multirow cell
|
||||
# use 2 rows and 2cm as default with because the multirow span
|
||||
# and the column width is only hardly accessible
|
||||
cend = find_token(document.body, "</cell>", i)
|
||||
if cend == -1:
|
||||
document.warning("Malformed LyX document: Could not find end of tabular cell.")
|
||||
i += 1
|
||||
continue
|
||||
blay = find_token(document.body, "\\begin_layout", i, cend)
|
||||
if blay == -1:
|
||||
document.warning("Can't find layout for cell!")
|
||||
i = j
|
||||
continue
|
||||
bend = find_end_of_layout(document.body, blay)
|
||||
if blay == -1:
|
||||
document.warning("Can't find end of layout for cell!")
|
||||
i = cend
|
||||
continue
|
||||
# do the later one first, so as not to mess up the numbering
|
||||
# we are wrapping the whole cell in this ert
|
||||
# so before the end of the layout...
|
||||
document.body[bend:bend] = put_cmd_in_ert("}")
|
||||
# ...and after the beginning
|
||||
document.body[blay+1:blay+1] = put_cmd_in_ert("\\multirow{2}{2cm}[" + offset + "]{")
|
||||
while True:
|
||||
# cell type 4 is multirow part cell
|
||||
k = find_token(document.body, '<cell multirow="4"', cend)
|
||||
if k == -1:
|
||||
break
|
||||
# remove the multirow tag, set the valignment to top
|
||||
# and remove the top line
|
||||
document.body[k] = document.body[k].replace(' multirow="4" ', ' ')
|
||||
document.body[k] = document.body[k].replace('valignment="middle"', 'valignment="top"')
|
||||
document.body[k] = document.body[k].replace(' topline="true" ', ' ')
|
||||
k += 1
|
||||
# this will always be ok
|
||||
i = cend
|
||||
if multirowOffset == True:
|
||||
add_to_preamble(document, ["\\usepackage{multirow}"])
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -2150,10 +2214,12 @@ convert = [[346, []],
|
||||
[403, [convert_flexnames]],
|
||||
[404, [convert_prettyref]],
|
||||
[405, []],
|
||||
[406, [convert_passthru]]
|
||||
[406, [convert_passthru]],
|
||||
[407, []]
|
||||
]
|
||||
|
||||
revert = [[405, [revert_passthru]],
|
||||
revert = [[406, [revert_multirowOffset]],
|
||||
[405, [revert_passthru]],
|
||||
[404, []],
|
||||
[403, [revert_refstyle]],
|
||||
[402, [revert_flexnames]],
|
||||
|
@ -128,7 +128,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 406; // rgh: passthru changes
|
||||
int const LYX_FORMAT = 407; // uwestoehr: support for multirow offset
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -49,11 +49,13 @@ GuiTabular::GuiTabular(QWidget * parent)
|
||||
setupUi(this);
|
||||
|
||||
widthED->setValidator(unsignedLengthValidator(widthED));
|
||||
multirowOffsetED->setValidator(new LengthValidator(multirowOffsetED));
|
||||
topspaceED->setValidator(new LengthValidator(topspaceED));
|
||||
bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
|
||||
interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
|
||||
|
||||
widthUnitCB->setCurrentItem(Length::defaultUnit());
|
||||
multirowOffsetUnitCB->setCurrentItem(Length::defaultUnit());
|
||||
topspaceUnitCB->setCurrentItem(Length::defaultUnit());
|
||||
bottomspaceUnitCB->setCurrentItem(Length::defaultUnit());
|
||||
interlinespaceUnitCB->setCurrentItem(Length::defaultUnit());
|
||||
@ -92,6 +94,10 @@ GuiTabular::GuiTabular(QWidget * parent)
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(multirowCB, SIGNAL(clicked()),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(multirowOffsetED, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(multirowOffsetUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(newpageCB, SIGNAL(clicked()),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(headerStatusCB, SIGNAL(clicked()),
|
||||
@ -156,6 +162,7 @@ GuiTabular::GuiTabular(QWidget * parent)
|
||||
|
||||
// initialize the length validator
|
||||
addCheckedWidget(widthED, fixedWidthColLA);
|
||||
addCheckedWidget(multirowOffsetED, multirowOffsetLA);
|
||||
addCheckedWidget(topspaceED, topspaceLA);
|
||||
addCheckedWidget(bottomspaceED, bottomspaceLA);
|
||||
addCheckedWidget(interlinespaceED, interlinespaceLA);
|
||||
@ -237,6 +244,8 @@ void GuiTabular::checkEnabled()
|
||||
|
||||
multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
|
||||
multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
|
||||
multirowOffsetED->setEnabled(multirowCB->isChecked());
|
||||
multirowOffsetUnitCB->setEnabled(multirowCB->isChecked());
|
||||
|
||||
changed();
|
||||
}
|
||||
@ -461,6 +470,13 @@ docstring GuiTabular::dialogToParams() const
|
||||
setParam(param_str, Tabular::SET_MULTICOLUMN);
|
||||
else
|
||||
setParam(param_str, Tabular::UNSET_MULTICOLUMN);
|
||||
|
||||
// apply the multirow offset
|
||||
string mroffset = widgetsToLength(multirowOffsetED, multirowOffsetUnitCB);
|
||||
if (mroffset.empty())
|
||||
mroffset = "0pt";
|
||||
if (multirowCB->isChecked())
|
||||
setParam(param_str, Tabular::SET_MROFFSET, mroffset);
|
||||
//
|
||||
if (multirowCB->isChecked())
|
||||
setParam(param_str, Tabular::SET_MULTIROW);
|
||||
@ -574,6 +590,14 @@ static Length getMColumnPWidth(Tabular const & t, size_t cell)
|
||||
}
|
||||
|
||||
|
||||
static Length getMROffset(Tabular const & t, size_t cell)
|
||||
{
|
||||
if (t.isMultiRow(cell))
|
||||
return t.cellInfo(cell).mroffset;
|
||||
return Length();
|
||||
}
|
||||
|
||||
|
||||
static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
|
||||
{
|
||||
if (what == Tabular::SET_SPECIAL_MULTICOLUMN)
|
||||
@ -638,6 +662,17 @@ void GuiTabular::paramsToDialog(Inset const * inset)
|
||||
lengthToWidgets(widthED, widthUnitCB,
|
||||
colwidth, default_unit);
|
||||
}
|
||||
Length mroffset;
|
||||
if (multirow)
|
||||
mroffset = getMROffset(tabular, cell);
|
||||
string offset;
|
||||
if (mroffset.zero())
|
||||
multirowOffsetED->clear();
|
||||
else {
|
||||
offset = mroffset.asString();
|
||||
lengthToWidgets(multirowOffsetED, multirowOffsetUnitCB,
|
||||
offset, default_unit);
|
||||
}
|
||||
specialAlignmentED->setText(toqstr(special));
|
||||
///////////////////////////////////
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>439</width>
|
||||
<height>376</height>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -34,8 +34,8 @@
|
||||
<attribute name="title">
|
||||
<string>&Table Settings</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="GroupBox12">
|
||||
<property name="title">
|
||||
<string>Column settings</string>
|
||||
@ -231,12 +231,12 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Row setting</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="multirowCB">
|
||||
<property name="toolTip">
|
||||
@ -247,10 +247,43 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="multirowOffsetLA">
|
||||
<property name="toolTip">
|
||||
<string>optional vertical offset</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Vertical Offset:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>widthED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="multirowOffsetED">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>value of the optional vertical offset</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="LengthCombo" name="multirowOffsetUnitCB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Cell setting</string>
|
||||
@ -269,7 +302,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="tabAlignmentGB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
|
@ -142,6 +142,7 @@ TabularFeature tabularFeature[] =
|
||||
{ Tabular::MULTIROW, "multirow", false },
|
||||
{ Tabular::SET_MULTIROW, "set-multirow", false },
|
||||
{ Tabular::UNSET_MULTIROW, "unset-multirow", false },
|
||||
{ Tabular::SET_MROFFSET, "set-mroffset", true },
|
||||
{ Tabular::SET_ALL_LINES, "set-all-lines", false },
|
||||
{ Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
|
||||
{ Tabular::SET_LONGTABULAR, "set-longtabular", false },
|
||||
@ -573,6 +574,7 @@ Tabular::CellData::CellData(CellData const & cs)
|
||||
width(cs.width),
|
||||
multicolumn(cs.multicolumn),
|
||||
multirow(cs.multirow),
|
||||
mroffset(cs.mroffset),
|
||||
alignment(cs.alignment),
|
||||
valignment(cs.valignment),
|
||||
decimal_hoffset(cs.decimal_hoffset),
|
||||
@ -602,6 +604,7 @@ void Tabular::CellData::swap(CellData & rhs)
|
||||
std::swap(width, rhs.width);
|
||||
std::swap(multicolumn, rhs.multicolumn);
|
||||
std::swap(multirow, rhs.multirow);
|
||||
std::swap(mroffset, rhs.mroffset);
|
||||
std::swap(alignment, rhs.alignment);
|
||||
std::swap(valignment, rhs.valignment);
|
||||
std::swap(decimal_hoffset, rhs.decimal_hoffset);
|
||||
@ -1130,6 +1133,14 @@ bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell,
|
||||
}
|
||||
|
||||
|
||||
bool Tabular::setMROffset(Cursor & cur, idx_type cell,
|
||||
Length const & mroffset)
|
||||
{
|
||||
cellInfo(cell).mroffset = mroffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Tabular::setAlignSpecial(idx_type cell, docstring const & special,
|
||||
Tabular::Feature what)
|
||||
{
|
||||
@ -1249,6 +1260,12 @@ Length const Tabular::getPWidth(idx_type cell) const
|
||||
}
|
||||
|
||||
|
||||
Length const Tabular::getMROffset(idx_type cell) const
|
||||
{
|
||||
return cellInfo(cell).mroffset;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::textHOffset(idx_type cell) const
|
||||
{
|
||||
// the LaTeX Way :-(
|
||||
@ -1404,6 +1421,7 @@ void Tabular::write(ostream & os) const
|
||||
os << "<cell"
|
||||
<< write_attribute("multicolumn", cell_info[r][c].multicolumn)
|
||||
<< write_attribute("multirow", cell_info[r][c].multirow)
|
||||
<< write_attribute("mroffset", cell_info[r][c].mroffset)
|
||||
<< write_attribute("alignment", cell_info[r][c].alignment)
|
||||
<< write_attribute("valignment", cell_info[r][c].valignment)
|
||||
<< write_attribute("topline", cell_info[r][c].top_line)
|
||||
@ -1513,6 +1531,7 @@ void Tabular::read(Lexer & lex)
|
||||
}
|
||||
getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
|
||||
getTokenValue(line, "multirow", cell_info[i][j].multirow);
|
||||
getTokenValue(line, "mroffset", cell_info[i][j].mroffset);
|
||||
getTokenValue(line, "alignment", cell_info[i][j].alignment);
|
||||
getTokenValue(line, "valignment", cell_info[i][j].valignment);
|
||||
getTokenValue(line, "topline", cell_info[i][j].top_line);
|
||||
@ -2225,7 +2244,10 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell,
|
||||
else
|
||||
// we need to set a default value
|
||||
os << "*";
|
||||
os << "}{";
|
||||
os << "}";
|
||||
if (!getMROffset(cell).zero())
|
||||
os << "[" << from_ascii(getMROffset(cell).asLatexString()) << "]";
|
||||
os << "{";
|
||||
} // end if ismultirow
|
||||
|
||||
if (getRotateCell(cell)) {
|
||||
@ -5059,6 +5081,10 @@ void InsetTabular::tabularFeatures(Cursor & cur,
|
||||
tabular.setMColumnPWidth(cur, cur.idx(), Length(value));
|
||||
break;
|
||||
|
||||
case Tabular::SET_MROFFSET:
|
||||
tabular.setMROffset(cur, cur.idx(), Length(value));
|
||||
break;
|
||||
|
||||
case Tabular::SET_SPECIAL_COLUMN:
|
||||
case Tabular::SET_SPECIAL_MULTICOLUMN:
|
||||
if (value == "none")
|
||||
|
@ -192,6 +192,8 @@ public:
|
||||
///
|
||||
UNSET_MULTIROW,
|
||||
///
|
||||
SET_MROFFSET,
|
||||
///
|
||||
SET_ALL_LINES,
|
||||
///
|
||||
UNSET_ALL_LINES,
|
||||
@ -404,6 +406,8 @@ public:
|
||||
///
|
||||
bool setMColumnPWidth(Cursor &, idx_type, Length const &);
|
||||
///
|
||||
bool setMROffset(Cursor &, idx_type, Length const &);
|
||||
///
|
||||
void setAlignSpecial(idx_type cell, docstring const & special,
|
||||
Feature what);
|
||||
///
|
||||
@ -415,6 +419,8 @@ public:
|
||||
///
|
||||
Length const getPWidth(idx_type cell) const;
|
||||
///
|
||||
Length const getMROffset(idx_type cell) const;
|
||||
///
|
||||
int textHOffset(idx_type cell) const;
|
||||
///
|
||||
int textVOffset(idx_type cell) const;
|
||||
@ -561,6 +567,8 @@ public:
|
||||
///
|
||||
int multirow;
|
||||
///
|
||||
Length mroffset;
|
||||
///
|
||||
LyXAlignment alignment;
|
||||
///
|
||||
VAlignment valignment;
|
||||
|
Loading…
Reference in New Issue
Block a user