mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
Fix bug 518 (thanks to Jean Marc and Martin for the help)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19455 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8622ebaa4d
commit
ca81b43f03
@ -30,7 +30,7 @@ try:
|
||||
import lyx2lyx_version
|
||||
version_lyx2lyx = lyx2lyx_version.version
|
||||
except: # we are running from build directory so assume the last version
|
||||
version_lyx2lyx = '1.5.0svn'
|
||||
version_lyx2lyx = '1.6.0svn'
|
||||
|
||||
default_debug_level = 2
|
||||
|
||||
@ -77,7 +77,8 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)),
|
||||
("1_2", [220], generate_minor_versions("1.2" , 4)),
|
||||
("1_3", [221], generate_minor_versions("1.3" , 7)),
|
||||
("1_4", range(222,246), generate_minor_versions("1.4" , 5)),
|
||||
("1_5", range(246,277), generate_minor_versions("1.5" , 0))]
|
||||
("1_5", range(246,277), generate_minor_versions("1.5" , 1)),
|
||||
("1_6", range(277,278), generate_minor_versions("1.6" , 0))]
|
||||
|
||||
|
||||
def formats_list():
|
||||
@ -470,7 +471,7 @@ class LyX_Base:
|
||||
first_step = 1
|
||||
for step in format_relation:
|
||||
if initial_step <= step[0] <= final_step:
|
||||
if first_step and len(step[1]) == 1:
|
||||
if first_step:
|
||||
first_step = 0
|
||||
continue
|
||||
steps.append(step[0])
|
||||
@ -488,6 +489,7 @@ class LyX_Base:
|
||||
if last_step[1][-1] == self.end_format:
|
||||
steps.pop()
|
||||
|
||||
self.warning("Convertion mode: %s\tsteps%s" %(mode, steps), 10)
|
||||
return mode, steps
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ dist_lyx2lyx_PYTHON = \
|
||||
lyx_1_3.py \
|
||||
lyx_1_4.py \
|
||||
lyx_1_5.py \
|
||||
lyx_1_6.py \
|
||||
profiling.py \
|
||||
test_parser_tools.py
|
||||
|
||||
|
85
lib/lyx2lyx/lyx_1_6.py
Normal file
85
lib/lyx2lyx/lyx_1_6.py
Normal file
@ -0,0 +1,85 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2007 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.6"""
|
||||
|
||||
import re
|
||||
import unicodedata
|
||||
import sys, os
|
||||
|
||||
from parser_tools import find_token, find_end_of
|
||||
|
||||
####################################################################
|
||||
# Private helper functions
|
||||
|
||||
def find_end_of_inset(lines, i):
|
||||
" Find end of inset, where lines[i] is included."
|
||||
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||
|
||||
####################################################################
|
||||
|
||||
def fix_wrong_tables(document):
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Tabular", i)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(document.body, i + 1)
|
||||
if j == -1:
|
||||
document.warning("Malformed LyX document: Could not find end of tabular.")
|
||||
continue
|
||||
|
||||
m = i + 1
|
||||
nrows = int(document.body[i+1].split('"')[3])
|
||||
ncols = int(document.body[i+1].split('"')[5])
|
||||
|
||||
for l in range(nrows):
|
||||
prev_multicolumn = 0
|
||||
for k in range(ncols):
|
||||
m = find_token(document.body, '<cell', m)
|
||||
|
||||
if document.body[m].find('multicolumn') != -1:
|
||||
multicol_cont = int(document.body[m].split('"')[1])
|
||||
|
||||
if multicol_cont == 2 and (k == 0 or prev_multicolumn == 0):
|
||||
document.body[m] = document.body[m][:5] + document.body[m][21:]
|
||||
prev_multicolumn = 0
|
||||
else:
|
||||
prev_multicolumn = multicol_cont
|
||||
else:
|
||||
prev_multicolumn = 0
|
||||
|
||||
i = j + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
|
||||
supported_versions = ["1.6.0","1.6"]
|
||||
convert = [
|
||||
[277, [fix_wrong_tables]],
|
||||
]
|
||||
|
||||
revert = [
|
||||
[276, []],
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
@ -135,7 +135,7 @@ namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 276;
|
||||
int const LYX_FORMAT = 277;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
@ -721,8 +721,15 @@ void Tabular::deleteColumn(col_type const column)
|
||||
return;
|
||||
|
||||
column_info.erase(column_info.begin() + column);
|
||||
for (row_type i = 0; i < rows_; ++i)
|
||||
for (row_type i = 0; i < rows_; ++i) {
|
||||
// Care about multicolumn cells
|
||||
if (column + 1 < columns_ &&
|
||||
cell_info[i][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN &&
|
||||
cell_info[i][column + 1].multicolumn == CELL_PART_OF_MULTICOLUMN) {
|
||||
cell_info[i][column + 1].multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
|
||||
}
|
||||
cell_info[i].erase(cell_info[i].begin() + column);
|
||||
}
|
||||
--columns_;
|
||||
fixCellNums();
|
||||
}
|
||||
@ -747,22 +754,10 @@ void Tabular::copyColumn(BufferParams const & bp, col_type const column)
|
||||
void Tabular::set_row_column_number_info()
|
||||
{
|
||||
numberofcells = 0;
|
||||
// Count only non-multicol cells plus begin multicol
|
||||
// cells, ignore non-begin multicol cells:
|
||||
for (row_type row = 0; row < rows_; ++row) {
|
||||
for (col_type column = 0; column < columns_; ++column) {
|
||||
|
||||
// If on its left is either the edge, or a normal cell,
|
||||
// then this cannot be a non-begin multicol cell.
|
||||
// Clean up as well as we can:
|
||||
if (cell_info[row][column].multicolumn
|
||||
== CELL_PART_OF_MULTICOLUMN) {
|
||||
if (column == 0 ||
|
||||
cell_info[row][column - 1]
|
||||
.multicolumn == CELL_NORMAL)
|
||||
cell_info[row][column].multicolumn =
|
||||
CELL_NORMAL;
|
||||
}
|
||||
// Count only non-multicol cells plus begin multicol
|
||||
// cells, ignore non-begin multicol cells:
|
||||
if (cell_info[row][column].multicolumn
|
||||
!= Tabular::CELL_PART_OF_MULTICOLUMN)
|
||||
++numberofcells;
|
||||
|
Loading…
Reference in New Issue
Block a user