mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
- new support for makebox; fileformat change
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34748 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b77c2213cb
commit
ebcef496a5
@ -7,6 +7,10 @@ The good example would be 2010-01-10 entry.
|
||||
|
||||
-----------------------
|
||||
|
||||
2010-07-03 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 394: support for makebox;
|
||||
new box parameter \use_makebox
|
||||
|
||||
2010-06-07 Richard Heck <rgheck@comcast.net>
|
||||
* Format incremented to 393 (r34619)
|
||||
Renaming in LyX format: \begin_inset OptArg becomes
|
||||
|
@ -1718,6 +1718,43 @@ def revert_argument(document):
|
||||
document.body[i] = "\\begin_inset OptArg"
|
||||
i += 1
|
||||
|
||||
|
||||
def revert_makebox(document):
|
||||
" Convert \\makebox to ERT "
|
||||
i = 0
|
||||
while 1:
|
||||
# only revert frameless boxes without an inner box
|
||||
i = find_token(document.body, '\\begin_inset Box Frameless', i)
|
||||
if i == -1:
|
||||
return
|
||||
else:
|
||||
z = find_end_of_inset(document.body, i)
|
||||
if z == -1:
|
||||
document.warning("Malformed LyX document: Can't find end of box inset.")
|
||||
return
|
||||
j = find_token(document.body, 'use_makebox 1', i)
|
||||
# assure we found the makebox of the current box
|
||||
if j > i + 7 or j == -1:
|
||||
return
|
||||
else:
|
||||
# remove the \end_inset
|
||||
document.body[z - 2:z + 1] = put_cmd_in_ert("}")
|
||||
# determine the alignment
|
||||
k = find_token(document.body, 'hor_pos', j - 4)
|
||||
align = document.body[k][9]
|
||||
# determine the width
|
||||
l = find_token(document.body, 'width "', j + 1)
|
||||
length = document.body[l][7:]
|
||||
# remove trailing '"'
|
||||
length = length[:-1]
|
||||
# latex_length returns "bool,length"
|
||||
length = latex_length(length).split(",")[1]
|
||||
subst = "\\makebox[" + length + "][" \
|
||||
+ align + "]{"
|
||||
document.body[i:i+13] = put_cmd_in_ert(subst)
|
||||
i += 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1770,10 +1807,12 @@ convert = [[346, []],
|
||||
[390, []],
|
||||
[391, []],
|
||||
[392, [convert_beamer_args]],
|
||||
[393, [convert_optarg]]
|
||||
[393, [convert_optarg]],
|
||||
[394, []]
|
||||
]
|
||||
|
||||
revert = [[392, [revert_argument]],
|
||||
revert = [[393, [revert_makebox]],
|
||||
[392, [revert_argument]],
|
||||
[391, [revert_beamer_args]],
|
||||
[390, [revert_align_decimal]],
|
||||
[389, [revert_output_sync]],
|
||||
|
@ -126,7 +126,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 393; // rgh: rename OptArg to Argument in LyX format
|
||||
int const LYX_FORMAT = 394; // uwestoehr: support for \makebox
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -113,12 +113,18 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
||||
|
||||
void GuiBox::on_innerBoxCO_activated(int index)
|
||||
{
|
||||
QString itype =
|
||||
innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
|
||||
// handle parbox and minipage the same way
|
||||
bool const ibox =
|
||||
(innerBoxCO->itemData(index).toString() != "none");
|
||||
(itype != "none"
|
||||
&& itype != "makebox");
|
||||
QString const outer =
|
||||
typeCO->itemData(typeCO->currentIndex()).toString();
|
||||
valignCO->setEnabled(ibox);
|
||||
ialignCO->setEnabled(ibox);
|
||||
if (heightCB->isChecked() && !ibox)
|
||||
heightCB->setChecked(false);
|
||||
heightCB->setEnabled(ibox);
|
||||
// except for frameless and boxed, the width cannot be specified if
|
||||
// there is no inner box
|
||||
@ -126,8 +132,10 @@ void GuiBox::on_innerBoxCO_activated(int index)
|
||||
outer != "Boxed");
|
||||
widthED->setEnabled(!width_disabled);
|
||||
widthUnitsLC->setEnabled(!width_disabled);
|
||||
// halign and pagebreak are only allowed for Boxed without inner box
|
||||
halignCO->setEnabled(!ibox && outer == "Boxed");
|
||||
// halign is only allowed for Boxed without inner box or for makebox
|
||||
halignCO->setEnabled((!ibox && outer == "Boxed")
|
||||
|| (itype == "makebox"));
|
||||
// pagebreak is only allowed for Boxed without inner box
|
||||
pagebreakCB->setEnabled(!ibox && outer == "Boxed");
|
||||
setSpecial(ibox);
|
||||
changed();
|
||||
@ -139,26 +147,34 @@ void GuiBox::on_typeCO_activated(int index)
|
||||
QString const type =
|
||||
typeCO->itemData(index).toString();
|
||||
bool const frameless = (type == "Frameless");
|
||||
if (frameless) {
|
||||
valignCO->setEnabled(true);
|
||||
ialignCO->setEnabled(true);
|
||||
heightCB->setEnabled(true);
|
||||
setSpecial(true);
|
||||
}
|
||||
if (type != "Boxed")
|
||||
pagebreakCB->setChecked(false);
|
||||
QString itype =
|
||||
innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
|
||||
setInnerType(frameless, itype);
|
||||
// refresh itype because it might have been changed in setInnerType
|
||||
itype =
|
||||
innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
|
||||
// handle parbox and minipage the same way
|
||||
bool const ibox =
|
||||
(itype != "none"
|
||||
&& itype != "makebox");
|
||||
if (frameless && itype != "makebox") {
|
||||
valignCO->setEnabled(ibox);
|
||||
ialignCO->setEnabled(ibox);
|
||||
if (heightCB->isChecked() && !ibox)
|
||||
heightCB->setChecked(false);
|
||||
heightCB->setEnabled(ibox);
|
||||
setSpecial(ibox);
|
||||
}
|
||||
// except for frameless and boxed, the width cannot be specified if
|
||||
// there is no inner box
|
||||
bool const width_disabled = (itype == "none" && !frameless
|
||||
&& type != "Boxed");
|
||||
widthED->setEnabled(!width_disabled);
|
||||
widthUnitsLC->setEnabled(!width_disabled);
|
||||
// halign and pagebreak are only allowed for Boxed without inner box
|
||||
halignCO->setEnabled(type == "Boxed" && itype == "none");
|
||||
// halign is only allowed for Boxed without inner box or for makebox
|
||||
halignCO->setEnabled((type == "Boxed" && itype == "none") || (itype == "makebox"));
|
||||
// pagebreak is only allowed for Boxed without inner box
|
||||
pagebreakCB->setEnabled(type == "Boxed" && itype == "none");
|
||||
setInnerType(frameless, itype);
|
||||
changed();
|
||||
}
|
||||
|
||||
@ -224,6 +240,8 @@ void GuiBox::paramsToDialog(Inset const * inset)
|
||||
inner_type = "none";
|
||||
if (params.use_parbox)
|
||||
inner_type = "parbox";
|
||||
if (params.use_makebox)
|
||||
inner_type = "makebox";
|
||||
bool const frameless = (params.type == "Frameless");
|
||||
setInnerType(frameless, inner_type);
|
||||
|
||||
@ -234,13 +252,14 @@ void GuiBox::paramsToDialog(Inset const * inset)
|
||||
c = params.hor_pos;
|
||||
halignCO->setCurrentIndex(string("lcrs").find(c, 0));
|
||||
|
||||
bool ibox = params.inner_box;
|
||||
bool ibox = (params.inner_box && !params.use_makebox);
|
||||
valignCO->setEnabled(ibox);
|
||||
ialignCO->setEnabled(ibox);
|
||||
setSpecial(ibox);
|
||||
|
||||
// halign and pagebreak are only allowed for Boxed without inner box
|
||||
halignCO->setEnabled(!ibox && type == "Boxed");
|
||||
halignCO->setEnabled((!ibox && type == "Boxed") || (params.use_makebox));
|
||||
// pagebreak is only allowed for Boxed without inner box
|
||||
pagebreakCB->setEnabled(!ibox && type == "Boxed");
|
||||
|
||||
// except for frameless and boxed, the width cannot be specified if
|
||||
@ -294,6 +313,8 @@ docstring GuiBox::dialogToParams() const
|
||||
(!pagebreak && innerBoxCO->currentText() != qt_("None"));
|
||||
params.use_parbox =
|
||||
(!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
|
||||
params.use_makebox =
|
||||
(!pagebreak && innerBoxCO->currentText() == qt_("Makebox"));
|
||||
|
||||
params.pos = "tcb"[valignCO->currentIndex()];
|
||||
params.inner_pos = "tcbs"[ialignCO->currentIndex()];
|
||||
@ -367,6 +388,8 @@ void GuiBox::setInnerType(bool frameless, QString const & type)
|
||||
innerBoxCO->clear();
|
||||
if (!frameless)
|
||||
innerBoxCO->addItem(qt_("None"), toqstr("none"));
|
||||
else
|
||||
innerBoxCO->addItem(qt_("Makebox"), toqstr("makebox"));
|
||||
innerBoxCO->addItem(qt_("Parbox"), toqstr("parbox"));
|
||||
innerBoxCO->addItem(qt_("Minipage"), toqstr("minipage"));
|
||||
int i = (innerBoxCO->findData(type) != -1)
|
||||
|
@ -136,6 +136,8 @@ void InsetBox::setButtonLabel()
|
||||
if (params_.inner_box) {
|
||||
if (params_.use_parbox)
|
||||
inner = _("Parbox");
|
||||
else if (params_.use_makebox)
|
||||
inner = _("Makebox");
|
||||
else
|
||||
inner = _("Minipage");
|
||||
}
|
||||
@ -294,7 +296,6 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const
|
||||
if (params_.hor_pos != 'c')
|
||||
os << "[" << params_.hor_pos << "]";
|
||||
}
|
||||
|
||||
os << "{";
|
||||
break;
|
||||
case ovalbox:
|
||||
@ -317,38 +318,56 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const
|
||||
if (params_.inner_box) {
|
||||
if (params_.use_parbox)
|
||||
os << "\\parbox";
|
||||
else if (params_.use_makebox) {
|
||||
os << "\\makebox";
|
||||
// FIXME UNICODE
|
||||
// output the width and horizontal position
|
||||
if (params_.special != "none") {
|
||||
os << "[" << params_.width.value()
|
||||
<< '\\' << from_utf8(params_.special)
|
||||
<< ']';
|
||||
} else
|
||||
os << '[' << from_ascii(width_string)
|
||||
<< ']';
|
||||
if (params_.hor_pos != 'c')
|
||||
os << "[" << params_.hor_pos << "]";
|
||||
os << "{";
|
||||
}
|
||||
else
|
||||
os << "\\begin{minipage}";
|
||||
|
||||
os << "[" << params_.pos << "]";
|
||||
if (params_.height_special == "none") {
|
||||
// FIXME UNICODE
|
||||
os << "[" << from_ascii(params_.height.asLatexString()) << "]";
|
||||
} else {
|
||||
// Special heights
|
||||
// set no optional argument when the value is the default "1\height"
|
||||
// (special units like \height are handled as "in")
|
||||
// but when the user has chosen a non-default inner_pos, the height
|
||||
// must be given: \minipage[pos][height][inner-pos]{width}
|
||||
if ((params_.height != Length("1in") ||
|
||||
params_.height_special != "totalheight") ||
|
||||
params_.inner_pos != params_.pos) {
|
||||
// output parameters for parbox and minipage
|
||||
if (!params_.use_makebox) {
|
||||
os << "[" << params_.pos << "]";
|
||||
if (params_.height_special == "none") {
|
||||
// FIXME UNICODE
|
||||
os << "[" << params_.height.value()
|
||||
<< "\\" << from_utf8(params_.height_special) << "]";
|
||||
os << "[" << from_ascii(params_.height.asLatexString()) << "]";
|
||||
} else {
|
||||
// Special heights
|
||||
// set no optional argument when the value is the default "1\height"
|
||||
// (special units like \height are handled as "in")
|
||||
// but when the user has chosen a non-default inner_pos, the height
|
||||
// must be given: \minipage[pos][height][inner-pos]{width}
|
||||
if ((params_.height != Length("1in") ||
|
||||
params_.height_special != "totalheight") ||
|
||||
params_.inner_pos != params_.pos) {
|
||||
// FIXME UNICODE
|
||||
os << "[" << params_.height.value()
|
||||
<< "\\" << from_utf8(params_.height_special) << "]";
|
||||
}
|
||||
}
|
||||
if (params_.inner_pos != params_.pos)
|
||||
os << "[" << params_.inner_pos << "]";
|
||||
// FIXME UNICODE
|
||||
os << '{' << from_ascii(width_string) << '}';
|
||||
if (params_.use_parbox)
|
||||
os << "{";
|
||||
}
|
||||
if (params_.inner_pos != params_.pos)
|
||||
os << "[" << params_.inner_pos << "]";
|
||||
|
||||
// FIXME UNICODE
|
||||
os << '{' << from_ascii(width_string) << '}';
|
||||
|
||||
if (params_.use_parbox)
|
||||
os << "{";
|
||||
os << "%\n";
|
||||
++i;
|
||||
}
|
||||
} // end if inner_box
|
||||
|
||||
if (btype == Shaded) {
|
||||
os << "\\begin{shaded}%\n";
|
||||
++i;
|
||||
@ -360,7 +379,7 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const
|
||||
os << "\\end{shaded}";
|
||||
|
||||
if (params_.inner_box) {
|
||||
if (params_.use_parbox)
|
||||
if (params_.use_parbox || params_.use_makebox)
|
||||
os << "%\n}";
|
||||
else
|
||||
os << "%\n\\end{minipage}";
|
||||
@ -564,6 +583,7 @@ void InsetBox::string2params(string const & in, InsetBoxParams & params)
|
||||
InsetBoxParams::InsetBoxParams(string const & label)
|
||||
: type(label),
|
||||
use_parbox(false),
|
||||
use_makebox(false),
|
||||
inner_box(true),
|
||||
width(Length("100col%")),
|
||||
special("none"),
|
||||
@ -583,6 +603,7 @@ void InsetBoxParams::write(ostream & os) const
|
||||
os << "has_inner_box " << inner_box << "\n";
|
||||
os << "inner_pos \"" << inner_pos << "\"\n";
|
||||
os << "use_parbox " << use_parbox << "\n";
|
||||
os << "use_makebox " << use_makebox << "\n";
|
||||
os << "width \"" << width.asString() << "\"\n";
|
||||
os << "special \"" << special << "\"\n";
|
||||
os << "height \"" << height.asString() << "\"\n";
|
||||
@ -601,6 +622,7 @@ void InsetBoxParams::read(Lexer & lex)
|
||||
inner_box = false;
|
||||
lex >> "inner_pos" >> inner_pos;
|
||||
lex >> "use_parbox" >> use_parbox;
|
||||
lex >> "use_makebox" >> use_makebox;
|
||||
lex >> "width" >> width;
|
||||
lex >> "special" >> special;
|
||||
lex >> "height" >> height;
|
||||
|
@ -31,8 +31,10 @@ public:
|
||||
|
||||
///
|
||||
std::string type;
|
||||
/// Use a parbox (true) or minipage (false)
|
||||
/// Is there a parbox?
|
||||
bool use_parbox;
|
||||
/// Is there a makebox?
|
||||
bool use_makebox;
|
||||
/// Do we have an inner parbox or minipage to format paragraphs to
|
||||
/// columnwidth?
|
||||
bool inner_box;
|
||||
|
Loading…
Reference in New Issue
Block a user