mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
** add support for protected horizontal fill. FILE FORMAT CHANGE. **
* src/Buffer.cpp: - increment file format to 320. * src/insets(InsetSpace.{cpp, h}: - add HFILL_PROTECTED, a protected horizontal fill (LaTeX: \hspace*{\fill}) * src/factory.cpp: * src/frontends/qt4/GuiHSpace.{cpp, h}: - handle the new space type. * lib/lyx2lyx/LyX.py: * lib/lyx2lyx/lyx_1_6.py: - reversion routine for protected hfill. * development/FORMAT: - document file format change git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23805 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
aad4651830
commit
18101eea7b
@ -1,8 +1,12 @@
|
|||||||
LyX file-format changes
|
LyX file-format changes
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
2008-03-18 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
* Format incremented to 320: support for protected horizontal fill
|
||||||
|
(\hspace*{\fill})
|
||||||
|
|
||||||
2008-03-10 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2008-03-10 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
* Format incremented to 319: hspace and extended hfill support.
|
* Format incremented to 319: hspace and extended hfill support
|
||||||
|
|
||||||
2008-03-09 Bo Peng <ben.bob@gmail.com>
|
2008-03-09 Bo Peng <ben.bob@gmail.com>
|
||||||
* Format incremented to 318: add \extra_embedded_files to buffer params
|
* Format incremented to 318: add \extra_embedded_files to buffer params
|
||||||
|
@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
|
|||||||
("1_3", [221], minor_versions("1.3" , 7)),
|
("1_3", [221], minor_versions("1.3" , 7)),
|
||||||
("1_4", range(222,246), minor_versions("1.4" , 5)),
|
("1_4", range(222,246), minor_versions("1.4" , 5)),
|
||||||
("1_5", range(246,277), minor_versions("1.5" , 2)),
|
("1_5", range(246,277), minor_versions("1.5" , 2)),
|
||||||
("1_6", range(277,320), minor_versions("1.6" , 0))]
|
("1_6", range(277,321), minor_versions("1.6" , 0))]
|
||||||
|
|
||||||
|
|
||||||
def formats_list():
|
def formats_list():
|
||||||
|
@ -1458,6 +1458,24 @@ def revert_hspace(document):
|
|||||||
'hspace{' + length + '}\n\\end_layout\n\n\\end_inset\n\n')
|
'hspace{' + length + '}\n\\end_layout\n\n\\end_inset\n\n')
|
||||||
|
|
||||||
|
|
||||||
|
def revert_protected_hfill(document):
|
||||||
|
' Revert \\begin_inset Space \\hspace*{\\fill} to ERT '
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token(document.body, '\\begin_inset Space \\hspace*{\\fill}', i)
|
||||||
|
if i == -1:
|
||||||
|
return
|
||||||
|
j = find_end_of_inset(document.body, i)
|
||||||
|
if j == -1:
|
||||||
|
document.warning("Malformed LyX document: Could not find end of space inset.")
|
||||||
|
continue
|
||||||
|
del document.body[j]
|
||||||
|
document.body[i] = document.body[i].replace('\\begin_inset Space \\hspace*{\\fill}', \
|
||||||
|
'\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||||
|
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
||||||
|
'hspace*{\n\\backslash\nfill}\n\\end_layout\n\n\\end_inset\n\n')
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -1505,10 +1523,12 @@ convert = [[277, [fix_wrong_tables]],
|
|||||||
[316, [convert_subfig]],
|
[316, [convert_subfig]],
|
||||||
[317, []],
|
[317, []],
|
||||||
[318, []],
|
[318, []],
|
||||||
[319, [convert_spaceinset, convert_hfill]]
|
[319, [convert_spaceinset, convert_hfill]],
|
||||||
|
[320, []]
|
||||||
]
|
]
|
||||||
|
|
||||||
revert = [[318, [revert_spaceinset, revert_hfills, revert_hspace]],
|
revert = [[319, [revert_protected_hfill]],
|
||||||
|
[318, [revert_spaceinset, revert_hfills, revert_hspace]],
|
||||||
[317, [remove_extra_embedded_files]],
|
[317, [remove_extra_embedded_files]],
|
||||||
[316, [revert_wrapplacement]],
|
[316, [revert_wrapplacement]],
|
||||||
[315, [revert_subfig]],
|
[315, [revert_subfig]],
|
||||||
|
@ -116,7 +116,7 @@ namespace os = support::os;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int const LYX_FORMAT = 319;
|
int const LYX_FORMAT = 320;
|
||||||
|
|
||||||
typedef map<string, bool> DepClean;
|
typedef map<string, bool> DepClean;
|
||||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||||
|
@ -348,6 +348,8 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
|
|||||||
isp.kind = InsetSpaceParams::NEGTHIN;
|
isp.kind = InsetSpaceParams::NEGTHIN;
|
||||||
else if (name == "hfill")
|
else if (name == "hfill")
|
||||||
isp.kind = InsetSpaceParams::HFILL;
|
isp.kind = InsetSpaceParams::HFILL;
|
||||||
|
else if (name == "hfill*")
|
||||||
|
isp.kind = InsetSpaceParams::HFILL_PROTECTED;
|
||||||
else if (name == "dotfill")
|
else if (name == "dotfill")
|
||||||
isp.kind = InsetSpaceParams::DOTFILL;
|
isp.kind = InsetSpaceParams::DOTFILL;
|
||||||
else if (name == "hrulefill")
|
else if (name == "hrulefill")
|
||||||
|
@ -54,7 +54,7 @@ GuiHSpace::GuiHSpace(GuiView & lv)
|
|||||||
connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(fillPatternCO, SIGNAL(activated(int)),
|
connect(fillPatternCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(patternChanged()));
|
||||||
|
|
||||||
valueLE->setValidator(unsignedLengthValidator(valueLE));
|
valueLE->setValidator(unsignedLengthValidator(valueLE));
|
||||||
|
|
||||||
@ -90,13 +90,22 @@ void GuiHSpace::enableWidgets(int selection)
|
|||||||
valueLE->setEnabled(selection == 7);
|
valueLE->setEnabled(selection == 7);
|
||||||
unitCO->setEnabled(selection == 7);
|
unitCO->setEnabled(selection == 7);
|
||||||
fillPatternCO->setEnabled(selection == 6);
|
fillPatternCO->setEnabled(selection == 6);
|
||||||
|
int pattern = fillPatternCO->currentIndex();
|
||||||
bool const enable_keep =
|
bool const enable_keep =
|
||||||
selection == 0 || selection == 3 || selection == 7;
|
selection == 0 || selection == 3 ||
|
||||||
|
(selection == 6 && pattern == 0) || selection == 7;
|
||||||
keepCB->setEnabled(enable_keep);
|
keepCB->setEnabled(enable_keep);
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiHSpace::patternChanged()
|
||||||
|
{
|
||||||
|
enableWidgets(spacingCO->currentIndex());
|
||||||
|
changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void setWidgetsFromHSpace(InsetSpaceParams const & params,
|
static void setWidgetsFromHSpace(InsetSpaceParams const & params,
|
||||||
QComboBox * spacing,
|
QComboBox * spacing,
|
||||||
QLineEdit * value,
|
QLineEdit * value,
|
||||||
@ -137,6 +146,10 @@ static void setWidgetsFromHSpace(InsetSpaceParams const & params,
|
|||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
item = 6;
|
item = 6;
|
||||||
break;
|
break;
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
|
item = 6;
|
||||||
|
protect = true;
|
||||||
|
break;
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
item = 6;
|
item = 6;
|
||||||
pattern = 1;
|
pattern = 1;
|
||||||
@ -200,6 +213,8 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing,
|
|||||||
params.kind = InsetSpaceParams::DOTFILL;
|
params.kind = InsetSpaceParams::DOTFILL;
|
||||||
else if (fill == 2)
|
else if (fill == 2)
|
||||||
params.kind = InsetSpaceParams::HRULEFILL;
|
params.kind = InsetSpaceParams::HRULEFILL;
|
||||||
|
else if (keep)
|
||||||
|
params.kind = InsetSpaceParams::HFILL_PROTECTED;
|
||||||
else
|
else
|
||||||
params.kind = InsetSpaceParams::HFILL;
|
params.kind = InsetSpaceParams::HFILL;
|
||||||
break;
|
break;
|
||||||
|
@ -31,6 +31,8 @@ private Q_SLOTS:
|
|||||||
void change_adaptor();
|
void change_adaptor();
|
||||||
///
|
///
|
||||||
void enableWidgets(int);
|
void enableWidgets(int);
|
||||||
|
///
|
||||||
|
void patternChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Apply from dialog
|
/// Apply from dialog
|
||||||
|
@ -96,6 +96,9 @@ docstring InsetSpace::toolTip(BufferView const &, int, int) const
|
|||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
message = _("Horizontal Fill");
|
message = _("Horizontal Fill");
|
||||||
break;
|
break;
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
|
message = _("Protected Horizontal Fill");
|
||||||
|
break;
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
message = _("Horizontal Fill (Dots)");
|
message = _("Horizontal Fill (Dots)");
|
||||||
break;
|
break;
|
||||||
@ -141,9 +144,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
if (params_.kind == InsetSpaceParams::HFILL ||
|
if (isStretchableSpace()) {
|
||||||
params_.kind == InsetSpaceParams::DOTFILL ||
|
|
||||||
params_.kind == InsetSpaceParams::HRULEFILL) {
|
|
||||||
// The metrics for this kinds are calculated externally in
|
// The metrics for this kinds are calculated externally in
|
||||||
// \c TextMetrics::computeRowMetrics. Those are dummy value:
|
// \c TextMetrics::computeRowMetrics. Those are dummy value:
|
||||||
dim = Dimension(10, 10, 10);
|
dim = Dimension(10, 10, 10);
|
||||||
@ -178,6 +179,7 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
dim.wid = params_.length.inBP();
|
dim.wid = params_.length.inBP();
|
||||||
break;
|
break;
|
||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
case InsetSpaceParams::HRULEFILL:
|
case InsetSpaceParams::HRULEFILL:
|
||||||
// shut up compiler
|
// shut up compiler
|
||||||
@ -192,9 +194,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
|
|||||||
{
|
{
|
||||||
Dimension const dim = dimension(*pi.base.bv);
|
Dimension const dim = dimension(*pi.base.bv);
|
||||||
|
|
||||||
if (params_.kind == InsetSpaceParams::HFILL ||
|
if (isStretchableSpace()) {
|
||||||
params_.kind == InsetSpaceParams::DOTFILL ||
|
|
||||||
params_.kind == InsetSpaceParams::HRULEFILL) {
|
|
||||||
int const asc = theFontMetrics(pi.base.font).ascent('M');
|
int const asc = theFontMetrics(pi.base.font).ascent('M');
|
||||||
int const desc = theFontMetrics(pi.base.font).descent('M');
|
int const desc = theFontMetrics(pi.base.font).descent('M');
|
||||||
int const x0 = x + 1;
|
int const x0 = x + 1;
|
||||||
@ -208,6 +208,11 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
|
|||||||
pi.pain.line(x0, y2 , x1, y2, Color_added_space,
|
pi.pain.line(x0, y2 , x1, y2, Color_added_space,
|
||||||
frontend::Painter::line_onoffdash);
|
frontend::Painter::line_onoffdash);
|
||||||
pi.pain.line(x1, y1, x1, y0, Color_added_space);
|
pi.pain.line(x1, y1, x1, y0, Color_added_space);
|
||||||
|
} else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
|
||||||
|
pi.pain.line(x0, y1, x0, y0, Color_latex);
|
||||||
|
pi.pain.line(x0, y2 , x1, y2, Color_latex,
|
||||||
|
frontend::Painter::line_onoffdash);
|
||||||
|
pi.pain.line(x1, y1, x1, y0, Color_latex);
|
||||||
} else if (params_.kind == InsetSpaceParams::DOTFILL) {
|
} else if (params_.kind == InsetSpaceParams::DOTFILL) {
|
||||||
pi.pain.line(x0, y1, x0, y0, Color_special);
|
pi.pain.line(x0, y1, x0, y0, Color_special);
|
||||||
pi.pain.line(x0, y, x1, y, Color_special,
|
pi.pain.line(x0, y, x1, y, Color_special,
|
||||||
@ -279,6 +284,9 @@ void InsetSpaceParams::write(ostream & os) const
|
|||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
os << "\\hfill{}";
|
os << "\\hfill{}";
|
||||||
break;
|
break;
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
|
os << "\\hspace*{\\fill}";
|
||||||
|
break;
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
os << "\\dotfill{}";
|
os << "\\dotfill{}";
|
||||||
break;
|
break;
|
||||||
@ -321,6 +329,8 @@ void InsetSpaceParams::read(Lexer & lex)
|
|||||||
kind = InsetSpaceParams::NEGTHIN;
|
kind = InsetSpaceParams::NEGTHIN;
|
||||||
else if (command == "\\hfill{}")
|
else if (command == "\\hfill{}")
|
||||||
kind = InsetSpaceParams::HFILL;
|
kind = InsetSpaceParams::HFILL;
|
||||||
|
else if (command == "\\hspace*{\\fill}")
|
||||||
|
kind = InsetSpaceParams::HFILL_PROTECTED;
|
||||||
else if (command == "\\dotfill{}")
|
else if (command == "\\dotfill{}")
|
||||||
kind = InsetSpaceParams::DOTFILL;
|
kind = InsetSpaceParams::DOTFILL;
|
||||||
else if (command == "\\hrulefill{}")
|
else if (command == "\\hrulefill{}")
|
||||||
@ -393,6 +403,9 @@ int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
|
|||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
os << (runparams.free_spacing ? " " : "\\hfill{}");
|
os << (runparams.free_spacing ? " " : "\\hfill{}");
|
||||||
break;
|
break;
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
|
os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
|
||||||
|
break;
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
os << (runparams.free_spacing ? " " : "\\dotfill{}");
|
os << (runparams.free_spacing ? " " : "\\dotfill{}");
|
||||||
break;
|
break;
|
||||||
@ -420,6 +433,7 @@ int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
|
|||||||
{
|
{
|
||||||
switch (params_.kind) {
|
switch (params_.kind) {
|
||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
os << " ";
|
os << " ";
|
||||||
return 5;
|
return 5;
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
@ -451,6 +465,7 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
|
|||||||
os << " ";
|
os << " ";
|
||||||
break;
|
break;
|
||||||
case InsetSpaceParams::HFILL:
|
case InsetSpaceParams::HFILL:
|
||||||
|
case InsetSpaceParams::HFILL_PROTECTED:
|
||||||
os << '\n';
|
os << '\n';
|
||||||
case InsetSpaceParams::DOTFILL:
|
case InsetSpaceParams::DOTFILL:
|
||||||
// FIXME
|
// FIXME
|
||||||
@ -476,6 +491,7 @@ void InsetSpace::textString(odocstream & os) const
|
|||||||
bool InsetSpace::isStretchableSpace() const
|
bool InsetSpace::isStretchableSpace() const
|
||||||
{
|
{
|
||||||
return (params_.kind == InsetSpaceParams::HFILL ||
|
return (params_.kind == InsetSpaceParams::HFILL ||
|
||||||
|
params_.kind == InsetSpaceParams::HFILL_PROTECTED ||
|
||||||
params_.kind == InsetSpaceParams::DOTFILL ||
|
params_.kind == InsetSpaceParams::DOTFILL ||
|
||||||
params_.kind == InsetSpaceParams::HRULEFILL);
|
params_.kind == InsetSpaceParams::HRULEFILL);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ public:
|
|||||||
NEGTHIN,
|
NEGTHIN,
|
||||||
/// rubber length
|
/// rubber length
|
||||||
HFILL,
|
HFILL,
|
||||||
|
/// \hspace*{\fill}
|
||||||
|
HFILL_PROTECTED,
|
||||||
/// rubber length, filled with dots
|
/// rubber length, filled with dots
|
||||||
DOTFILL,
|
DOTFILL,
|
||||||
/// rubber length, filled with a rule
|
/// rubber length, filled with a rule
|
||||||
|
Loading…
Reference in New Issue
Block a user