LyX file-format changes
-----------------------
+2008-01-11 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+ * Format incremented to 312: support for sidewaysalgorithm (rotfloat)
+ and wide sideways{figure,table}.
+
2008-01-10 Richard Heck <rgheck@bobjweil.com>
* Format incremented to 311: dummy format to drive the AMS conversion
\TestPackage{prettyref}
\TestPackage{preview}
\TestPackage{rotating}
+\TestPackage{rotfloat}
\TestPackage{setspace}
\TestPackage{soul}
\TestPackage{subfigure}
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
- ("1_6", range(277,312), minor_versions("1.6" , 0))] # Richard Heck: AMS conversion
+ ("1_6", range(277,313), minor_versions("1.6" , 0))] # JSpitzm: rotfloat support
def formats_list():
def revert_float(document):
- " Revert sideway floats. "
+ " Revert sideways floats. "
i = 0
while 1:
i = find_token_exact(document.body, '\\begin_inset Float', i)
if i == -1:
return
+ floatline = document.body[i]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed lyx document: Missing '\\end_inset'.")
i = i + 1
continue
if get_value(document.body, 'sideways', i, j) != "false":
- document.warning("Conversion of 'sideways true' not yet implemented.")
- # Don't remove 'sideways' so that people will get warnings by lyx
+ l = find_token(document.body, "\\begin_layout Standard", i + 1, j)
+ if l == -1:
+ document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
+ return
+ floattype = "table"
+ if floatline == "\\begin_inset Float figure":
+ floattype = "figure"
+ document.body[j] = '\\layout Standard\n\\begin_inset ERT\nstatus Collapsed\n\n' \
+ '\\layout Standard\n\n\n\\backslash\n' \
+ 'end{sideways' + floattype + '}\n\n\\end_inset\n'
+ del document.body[i+1:l-1]
+ document.body[i] = '\\begin_inset ERT\nstatus Collapsed\n\n' \
+ '\\layout Standard\n\n\n\\backslash\n' \
+ 'begin{sideways' + floattype + '}\n\n\\end_inset\n\n'
+ add_to_preamble(document,
+ ['\\usepackage{rotfloat}\n'])
i = i + 1
continue
del_token(document.body, 'sideways', i, j)
return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n'
+ dst + '\n\\end_layout\n\\end_inset\n')
+def add_to_preamble(document, text):
+ """ Add text to the preamble if it is not already there.
+ Only the first line is checked!"""
+
+ if find_token(document.preamble, text[0], 0) != -1:
+ return
+
+ document.preamble.extend(text)
+
####################################################################
def fix_wrong_tables(document):
j = j + 1
+def revert_rotfloat(document):
+ " Revert sidewaysalgorithm. "
+ i = 0
+ while 1:
+ i = find_token(document.body, '\\begin_inset Float algorithm', i)
+ if i == -1:
+ return
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed lyx document: Missing '\\end_inset'.")
+ i = i + 1
+ continue
+ if get_value(document.body, 'sideways', i, j) != "false":
+ l = find_token(document.body, "\\begin_layout Standard", i + 1, j)
+ if l == -1:
+ document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
+ return
+ document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
+ '\\begin_layout Standard\n\n\n\\backslash\n' \
+ 'end{sidewaysalgorithm}\n\\end_layout\n\n\\end_inset\n'
+ del document.body[i+1:l-1]
+ document.body[i] = '\\begin_inset ERT\nstatus collapsed\n\n' \
+ '\\begin_layout Standard\n\n\n\\backslash\n' \
+ 'begin{sidewaysalgorithm}\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n'
+ add_to_preamble(document,
+ ['% Commands inserted by lyx2lyx for sideways algorithm float',
+ '\\usepackage{rotfloat}\n'
+ '\\floatstyle{ruled}\n'
+ '\\newfloat{algorithm}{tbp}{loa}\n'
+ '\\floatname{algorithm}{Algorithm}\n'])
+ i = i + 1
+ continue
+ i = i + 1
+
+
+def revert_widesideways(document):
+ " Revert wide sideways floats. "
+ i = 0
+ while 1:
+ i = find_token(document.body, '\\begin_inset Float', i)
+ if i == -1:
+ return
+ floatline = document.body[i]
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed lyx document: Missing '\\end_inset'.")
+ i = i + 1
+ continue
+ if get_value(document.body, 'sideways', i, j) != "false":
+ if get_value(document.body, 'wide', i, j) != "false":
+ l = find_token(document.body, "\\begin_layout Standard", i + 1, j)
+ if l == -1:
+ document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
+ return
+ floattype = "table"
+ if floatline == "\\begin_inset Float figure":
+ floattype = "figure"
+ document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
+ '\\begin_layout Standard\n\n\n\\backslash\n' \
+ 'end{sideways' + floattype + '*}\n\\end_layout\n\n\\end_inset\n'
+ del document.body[i+1:l-1]
+ document.body[i] = '\\begin_inset ERT\nstatus collapsed\n\n' \
+ '\\begin_layout Standard\n\n\n\\backslash\n' \
+ 'begin{sideways' + floattype + '*}\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n'
+ add_to_preamble(document,
+ ['\\usepackage{rotfloat}\n'])
+ i = i + 1
+ continue
+ i = i + 1
+
+
##
# Conversion hub
#
[308, []],
[309, []],
[310, []],
- [311, [convert_ams_classes]]
+ [311, [convert_ams_classes]],
+ [312, []],
]
-revert = [[310, []],
+revert = [[311, [revert_rotfloat, revert_widesideways]],
+ [310, []],
[309, [revert_btprintall]],
[308, [revert_nocite]],
[307, [revert_serbianlatin]],
namespace {
-int const LYX_FORMAT = 311; // Richard Heck: a dummy format to drive the AMS conversion
+int const LYX_FORMAT = 312; // JSpitzm: rotfloat support
} // namespace anon
the `float' package. See the caption package documentation
for explanation.*/
"float",
+ "rotfloat",
"wrapfig",
"booktabs",
"dvipost",
{
set(params.placement);
+ standardfloat_ = (params.type == "figure"
+ || params.type == "table");
+
if (params.wide) {
herepossiblyCB->setChecked(false);
heredefinitelyCB->setChecked(false);
spanCB->setChecked(params.wide);
sidewaysCB->setChecked(params.sideways);
- sidewaysCB->setEnabled(params.type == "figure"
- || params.type == "table");
+ // the package rotfloat only has *-versions for figure and table
+ spanCB->setEnabled(!params.sideways || standardfloat_);
checkAllowed();
}
ignoreCB->setEnabled(!sideways && !defaults && ignore);
herepossiblyCB->setEnabled(!sideways && !defaults && !span);
heredefinitelyCB->setEnabled(!sideways && !defaults && !span);
- spanCB->setEnabled(!sideways);
+ spanCB->setEnabled(!sideways || standardfloat_);
} else {
topCB->setEnabled(!defaults);
bottomCB->setEnabled(!defaults);
Q_SIGNALS:
void changed();
+private:
+ /// one of figure or table?
+ bool standardfloat_;
+
};
}
if (params_.sideways)
- features.require("rotating");
+ features.require("rotfloat");
features.useFloat(params_.type);
InsetCollapsable::validate(features);
OutputParams const & runparams) const
{
FloatList const & floats = buf.params().getTextClass().floats();
- string tmptype = (params_.wide ? params_.type + "*" : params_.type);
- if (params_.sideways) {
- if (params_.type == "table")
- tmptype = "sidewaystable";
- else if (params_.type == "figure")
- tmptype = "sidewaysfigure";
- }
+ string tmptype = params_.type;
+ if (params_.sideways)
+ tmptype = "sideways" + params_.type;
+ if (params_.wide && (!params_.sideways ||
+ params_.type == "figure" ||
+ params_.type == "table"))
+ tmptype += "*";
// Figure out the float placement to use.
// From lowest to highest:
// - float default placement