mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
file format change for bug 698 and fix for the reproducible part of bug 922
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9584 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ac9feeaed5
commit
5890d93dce
@ -1,3 +1,7 @@
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* FORMAT: document change to format 241.
|
||||
|
||||
2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
|
||||
* FORMAT: document change to format 240.
|
||||
|
@ -1,6 +1,21 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* format incremented to 241.
|
||||
|
||||
All following changes apply only to text in ERT insets. The
|
||||
rationale is that text in ERT is simply ASCII text, and nothing more.
|
||||
|
||||
* paragraph breaks are now a single newline in latex and not a
|
||||
paragraph break anymore (bug 698).
|
||||
* \newline is not allowed anymore, because it is redundant (see above)
|
||||
* layouts other than Standard, paragraph parameters and font changes
|
||||
are not allowed anymore. They never made sense and were ignored for
|
||||
latex output, but now they can't be read or set anymore (bug 922).
|
||||
|
||||
|
||||
2005-01-23 Jürgen Spitzmüller <j.spitzmüller@gmx.de>
|
||||
|
||||
* format incremented to 240.
|
||||
|
@ -1,4 +1,4 @@
|
||||
2005-01-15 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
|
||||
* ui/classic.ui, ui/stdmenus.ui: add output-changes.
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* LyX.py: format up to 241
|
||||
* lyx_1_4.py (convert_ert_paragraphs, revert_ert_paragraphs): new
|
||||
* lyx_1_4.py, LyX.py: handle new format 241
|
||||
|
||||
2005-01-24 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* LyX.py: format up to 240.
|
||||
|
@ -46,7 +46,7 @@ format_relation = [("0_10", [210], ["0.10.7","0.10"]),
|
||||
("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
|
||||
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
|
||||
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]),
|
||||
("1_4", range(223,241), ["1.4.0cvs","1.4"])]
|
||||
("1_4", range(223,242), ["1.4.0cvs","1.4"])]
|
||||
|
||||
|
||||
def formats_list():
|
||||
|
@ -1551,6 +1551,122 @@ def revert_output_changes (file):
|
||||
del file.header[i]
|
||||
|
||||
|
||||
##
|
||||
# Convert paragraph breaks and sanitize paragraphs
|
||||
#
|
||||
def convert_ert_paragraphs(file):
|
||||
forbidden_settings = [
|
||||
# paragraph parameters
|
||||
'\\paragraph_spacing', '\\labelwidthstring',
|
||||
'\\start_of_appendix', '\\noindent',
|
||||
'\\leftindent', '\\align',
|
||||
# font settings
|
||||
'\\family', '\\series', '\\shape', '\\size',
|
||||
'\\emph', '\\numeric', '\\bar', '\\noun',
|
||||
'\\color', '\\lang']
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(file.body, '\\begin_inset ERT', i)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(file.body, i)
|
||||
if j == -1:
|
||||
file.warning("Malformed lyx file: Missing '\\end_inset'.")
|
||||
i = i + 1
|
||||
continue
|
||||
|
||||
# convert non-standard paragraphs to standard
|
||||
k = i
|
||||
while 1:
|
||||
k = find_token(file.body, "\\begin_layout", k, j)
|
||||
if k == -1:
|
||||
break
|
||||
file.body[k] = "\\begin_layout Standard"
|
||||
k = k + 1
|
||||
|
||||
# remove all paragraph parameters and font settings
|
||||
k = i
|
||||
while k < j:
|
||||
if (strip(file.body[k]) and
|
||||
split(file.body[k])[0] in forbidden_settings):
|
||||
del file.body[k]
|
||||
j = j - 1
|
||||
else:
|
||||
k = k + 1
|
||||
|
||||
# insert an empty paragraph before each paragraph but the first
|
||||
k = i
|
||||
first_pagraph = 1
|
||||
while 1:
|
||||
k = find_token(file.body, "\\begin_layout Standard", k, j)
|
||||
if k == -1:
|
||||
break
|
||||
if first_pagraph:
|
||||
first_pagraph = 0
|
||||
k = k + 1
|
||||
continue
|
||||
file.body[k:k] = ["\\begin_layout Standard", "",
|
||||
"\\end_layout", ""]
|
||||
k = k + 5
|
||||
j = j + 4
|
||||
|
||||
# convert \\newline to new paragraph
|
||||
k = i
|
||||
while 1:
|
||||
k = find_token(file.body, "\\newline", k, j)
|
||||
if k == -1:
|
||||
break
|
||||
file.body[k:k+1] = ["\\end_layout", "", "\\begin_layout Standard"]
|
||||
k = k + 4
|
||||
j = j + 3
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Remove double paragraph breaks
|
||||
#
|
||||
def revert_ert_paragraphs(file):
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(file.body, '\\begin_inset ERT', i)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(file.body, i)
|
||||
if j == -1:
|
||||
file.warning("Malformed lyx file: Missing '\\end_inset'.")
|
||||
i = i + 1
|
||||
continue
|
||||
|
||||
# replace paragraph breaks with \newline
|
||||
k = i
|
||||
while 1:
|
||||
k = find_token(file.body, "\\end_layout", k, j)
|
||||
l = find_token(file.body, "\\begin_layout", k, j)
|
||||
if k == -1 or l == -1:
|
||||
break
|
||||
file.body[k:l+1] = ["\\newline"]
|
||||
j = j - l + k
|
||||
k = k + 1
|
||||
|
||||
# replace double \newlines with paragraph breaks
|
||||
k = i
|
||||
while 1:
|
||||
k = find_token(file.body, "\\newline", k, j)
|
||||
if k == -1:
|
||||
break
|
||||
l = k + 1
|
||||
while file.body[l] == "":
|
||||
l = l + 1
|
||||
if strip(file.body[l]) and split(file.body[l])[0] == "\\newline":
|
||||
file.body[k:l+1] = ["\\end_layout", "",
|
||||
"\\begin_layout Standard"]
|
||||
j = j - l + k + 2
|
||||
k = k + 3
|
||||
else:
|
||||
k = k + 1
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Convertion hub
|
||||
#
|
||||
@ -1575,9 +1691,11 @@ convert = [[223, [insert_tracking_changes, add_end_header, remove_color_default,
|
||||
[237, [use_x_boolean]],
|
||||
[238, [update_latexaccents]],
|
||||
[239, [normalize_paragraph_params]],
|
||||
[240, [convert_output_changes]]]
|
||||
[240, [convert_output_changes]],
|
||||
[241, [convert_ert_paragraphs]]]
|
||||
|
||||
revert = [[239, [revert_output_changes]],
|
||||
revert = [[240, [revert_ert_paragraphs]],
|
||||
[239, [revert_output_changes]],
|
||||
[238, []],
|
||||
[237, []],
|
||||
[236, [use_x_binary]],
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* buffer.C: format up to 241.
|
||||
* CutAndPaste.C (pasteSelectionHelper): convert newline to paragraph
|
||||
break if pasting into ERT
|
||||
* lyxfunc.C (getStatus): suppress mathpanel and
|
||||
LFUN_DIALOG_SHOW_NEW_INSET in ERT
|
||||
|
||||
2005-02-01 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyxrc.C (getDescription): add a description for RC_PATH_PREFIX.
|
||||
|
@ -114,6 +114,21 @@ pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
|
||||
// Now remove all out of the pars which is NOT allowed in the
|
||||
// new environment and set also another font if that is required.
|
||||
|
||||
// Convert newline to paragraph break in ERT inset.
|
||||
// This should not be here!
|
||||
if (pars[pit].inInset()->lyxCode() == InsetBase::ERT_CODE) {
|
||||
for (ParagraphList::size_type i = 0; i < insertion.size(); ++i) {
|
||||
for (pos_type j = 0; j < insertion[i].size(); ++j) {
|
||||
if (insertion[i].isNewline(j)) {
|
||||
insertion[i].erase(j);
|
||||
breakParagraphConservative(
|
||||
buffer.params(),
|
||||
insertion, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure there is no class difference.
|
||||
lyx::cap::SwitchLayoutsBetweenClasses(textclass, tc, insertion,
|
||||
errorlist);
|
||||
@ -145,10 +160,9 @@ pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
|
||||
// Set the inset owner of this paragraph.
|
||||
tmpbuf->setInsetOwner(pars[pit].inInset());
|
||||
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
|
||||
if (tmpbuf->getChar(i) == Paragraph::META_INSET) {
|
||||
if (!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
|
||||
tmpbuf->erase(i--);
|
||||
}
|
||||
if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
|
||||
!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
|
||||
tmpbuf->erase(i--);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ extern BufferList bufferlist;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 240;
|
||||
int const LYX_FORMAT = 241;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
2005-02-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* insetert.C (latex, linuxdoc, docbook): remove newline handling
|
||||
* insetert.C (doDispatch): clean pasted paragraphs
|
||||
* insetert.C (getStatus): suppress more lfuns
|
||||
* insetert.C (insetAllowed): return always false
|
||||
|
||||
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
|
||||
|
||||
* inset.C:
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "funcrequest.h"
|
||||
@ -23,8 +24,11 @@
|
||||
#include "gettext.h"
|
||||
#include "language.h"
|
||||
#include "LColor.h"
|
||||
#include "LyXAction.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxtextclass.h"
|
||||
#include "metricsinfo.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
@ -33,6 +37,7 @@
|
||||
#include <sstream>
|
||||
|
||||
using lyx::pos_type;
|
||||
using lyx::support::token;
|
||||
|
||||
using std::endl;
|
||||
using std::min;
|
||||
@ -130,12 +135,7 @@ int InsetERT::latex(Buffer const &, ostream & os,
|
||||
if (isDeletedText(*par, i))
|
||||
continue;
|
||||
|
||||
if (par->isNewline(i)) {
|
||||
os << '\n';
|
||||
++lines;
|
||||
} else {
|
||||
os << par->getChar(i);
|
||||
}
|
||||
os << par->getChar(i);
|
||||
}
|
||||
++par;
|
||||
if (par != end) {
|
||||
@ -164,14 +164,8 @@ int InsetERT::linuxdoc(Buffer const &, ostream & os,
|
||||
int lines = 0;
|
||||
while (par != end) {
|
||||
pos_type siz = par->size();
|
||||
for (pos_type i = 0; i < siz; ++i) {
|
||||
if (par->isNewline(i)) {
|
||||
os << '\n';
|
||||
++lines;
|
||||
} else {
|
||||
os << par->getChar(i);
|
||||
}
|
||||
}
|
||||
for (pos_type i = 0; i < siz; ++i)
|
||||
os << par->getChar(i);
|
||||
++par;
|
||||
if (par != end) {
|
||||
os << "\n";
|
||||
@ -192,14 +186,8 @@ int InsetERT::docbook(Buffer const &, ostream & os,
|
||||
int lines = 0;
|
||||
while (par != end) {
|
||||
pos_type siz = par->size();
|
||||
for (pos_type i = 0; i < siz; ++i) {
|
||||
if (par->isNewline(i)) {
|
||||
os << '\n';
|
||||
++lines;
|
||||
} else {
|
||||
os << par->getChar(i);
|
||||
}
|
||||
}
|
||||
for (pos_type i = 0; i < siz; ++i)
|
||||
os << par->getChar(i);
|
||||
++par;
|
||||
if (par != end) {
|
||||
os << "\n";
|
||||
@ -222,7 +210,34 @@ void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
setStatus(st);
|
||||
break;
|
||||
}
|
||||
case LFUN_PASTE:
|
||||
case LFUN_PASTESELECTION: {
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
|
||||
// Since we can only store plain text, we must reset all
|
||||
// attributes.
|
||||
// FIXME: Change only the pasted paragraphs
|
||||
|
||||
BufferParams const & bp = cur.buffer().params();
|
||||
LyXLayout_ptr const layout =
|
||||
bp.getLyXTextClass().defaultLayout();
|
||||
LyXFont font = layout->font;
|
||||
// We need to set the language for non-english documents
|
||||
font.setLanguage(bp.language);
|
||||
ParagraphList::iterator const end = paragraphs().end();
|
||||
for (ParagraphList::iterator par = paragraphs().begin();
|
||||
par != end; ++par) {
|
||||
par->layout(layout);
|
||||
// in case par had a manual label
|
||||
par->setBeginOfBody();
|
||||
pos_type const siz = par->size();
|
||||
for (pos_type i = 0; i < siz; ++i) {
|
||||
par->setFont(i, font);
|
||||
}
|
||||
par->params().clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
@ -235,7 +250,36 @@ bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
{
|
||||
switch (cmd.action) {
|
||||
// suppress these
|
||||
case LFUN_LAYOUT:
|
||||
case LFUN_ACUTE:
|
||||
case LFUN_BREVE:
|
||||
case LFUN_CARON:
|
||||
case LFUN_CEDILLA:
|
||||
case LFUN_CIRCLE:
|
||||
case LFUN_CIRCUMFLEX:
|
||||
case LFUN_DOT:
|
||||
case LFUN_GRAVE:
|
||||
case LFUN_HUNG_UMLAUT:
|
||||
case LFUN_MACRON:
|
||||
case LFUN_OGONEK:
|
||||
case LFUN_SPECIAL_CARON:
|
||||
case LFUN_TIE:
|
||||
case LFUN_TILDE:
|
||||
case LFUN_UMLAUT:
|
||||
case LFUN_UNDERBAR:
|
||||
case LFUN_UNDERDOT:
|
||||
case LFUN_APPENDIX:
|
||||
case LFUN_BREAKLINE:
|
||||
case LFUN_INSET_CAPTION:
|
||||
case LFUN_DEPTH_MIN:
|
||||
case LFUN_DEPTH_PLUS:
|
||||
case LFUN_LDOTS:
|
||||
case LFUN_END_OF_SENTENCE:
|
||||
case LFUN_ENVIRONMENT_INSERT:
|
||||
case LFUN_INSET_ERT:
|
||||
case LFUN_FILE_INSERT:
|
||||
case LFUN_INSET_FLOAT:
|
||||
case LFUN_INSET_WIDE_FLOAT:
|
||||
case LFUN_INSET_WRAP:
|
||||
case LFUN_BOLD:
|
||||
case LFUN_CODE:
|
||||
case LFUN_DEFAULT:
|
||||
@ -250,12 +294,66 @@ bool InsetERT::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_FONT_SIZE:
|
||||
case LFUN_FONT_STATE:
|
||||
case LFUN_UNDERLINE:
|
||||
case LFUN_INSET_FOOTNOTE:
|
||||
case LFUN_HFILL:
|
||||
case LFUN_HTMLURL:
|
||||
case LFUN_HYPHENATION:
|
||||
case LFUN_LIGATURE_BREAK:
|
||||
case LFUN_INDEX_INSERT:
|
||||
case LFUN_INDEX_PRINT:
|
||||
case LFUN_INSERT_LABEL:
|
||||
case LFUN_INSET_OPTARG:
|
||||
case LFUN_INSERT_BIBITEM:
|
||||
case LFUN_INSERT_LINE:
|
||||
case LFUN_INSERT_PAGEBREAK:
|
||||
case LFUN_LANGUAGE:
|
||||
case LFUN_LAYOUT:
|
||||
case LFUN_LAYOUT_PARAGRAPH:
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
case LFUN_INSET_MARGINAL:
|
||||
case LFUN_MATH_DISPLAY:
|
||||
case LFUN_INSERT_MATH:
|
||||
case LFUN_INSERT_MATRIX:
|
||||
case LFUN_MATH_MODE:
|
||||
case LFUN_MENU_OPEN_BY_NAME:
|
||||
case LFUN_MENU_SEPARATOR:
|
||||
case LFUN_INSERT_BRANCH:
|
||||
case LFUN_INSERT_CHARSTYLE:
|
||||
case LFUN_INSERT_NOTE:
|
||||
case LFUN_INSERT_BOX:
|
||||
case LFUN_GOTONOTE:
|
||||
case LFUN_PARAGRAPH_SPACING:
|
||||
case LFUN_QUOTE:
|
||||
case LFUN_REF_GOTO:
|
||||
case LFUN_REFERENCE_GOTO:
|
||||
case LFUN_SPACE_INSERT:
|
||||
case LFUN_GOTOFILEROW:
|
||||
case LFUN_NOTIFY:
|
||||
case LFUN_SETXY:
|
||||
case LFUN_TABULAR_INSERT:
|
||||
case LFUN_TOC_INSERT:
|
||||
case LFUN_URL:
|
||||
case LFUN_FLOAT_LIST:
|
||||
case LFUN_INSET_INSERT:
|
||||
case LFUN_PARAGRAPH_APPLY:
|
||||
case LFUN_PARAGRAPH_UPDATE:
|
||||
case LFUN_NOACTION:
|
||||
status.enabled(false);
|
||||
return true;
|
||||
|
||||
// this one is difficult to get right. As a half-baked
|
||||
// solution, we consider only the first action of the sequence
|
||||
case LFUN_SEQUENCE: {
|
||||
// argument contains ';'-terminated commands
|
||||
string const firstcmd = token(cmd.argument, ';', 0);
|
||||
FuncRequest func(lyxaction.lookupFunc(firstcmd));
|
||||
func.origin = cmd.origin;
|
||||
return getStatus(cur, func, status);
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -265,9 +363,9 @@ void InsetERT::setButtonLabel()
|
||||
}
|
||||
|
||||
|
||||
bool InsetERT::insetAllowed(InsetBase::Code code) const
|
||||
bool InsetERT::insetAllowed(InsetBase::Code /* code */) const
|
||||
{
|
||||
return code == InsetBase::NEWLINE_CODE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,6 +95,7 @@
|
||||
|
||||
using bv_funcs::freefont2string;
|
||||
|
||||
using lyx::support::AbsolutePath;
|
||||
using lyx::support::AddName;
|
||||
using lyx::support::AddPath;
|
||||
using lyx::support::bformat;
|
||||
@ -487,7 +488,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
else if (name == "print")
|
||||
enable = Exporter::IsExportable(*buf, "dvi")
|
||||
&& lyxrc.print_command != "none";
|
||||
else if (name == "character")
|
||||
else if (name == "character" || name == "mathpanel")
|
||||
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
|
||||
else if (name == "vclog")
|
||||
enable = buf->lyxvc().inUse();
|
||||
@ -496,6 +497,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_DIALOG_SHOW_NEW_INSET:
|
||||
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
|
||||
break;
|
||||
|
||||
case LFUN_DIALOG_UPDATE: {
|
||||
string const name = cmd.getArg(0);
|
||||
if (!buf)
|
||||
@ -540,7 +545,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
case LFUN_NOTIFY:
|
||||
case LFUN_GOTOFILEROW:
|
||||
case LFUN_GOTO_PARAGRAPH:
|
||||
case LFUN_DIALOG_SHOW_NEW_INSET:
|
||||
case LFUN_DIALOG_SHOW_NEXT_INSET:
|
||||
case LFUN_DIALOG_HIDE:
|
||||
case LFUN_DIALOG_DISCONNECT_INSET:
|
||||
|
Loading…
Reference in New Issue
Block a user