Compare commits

..

3 Commits

Author SHA1 Message Date
Pavel Sanda
c87b2d5fc2 Header not needed anymore 2024-09-17 19:51:35 +02:00
Kornel Benko
e72ca6a586 Cmake lyx2lyx export tests: Try to use output format from the lyx-source 2024-09-17 18:42:46 +02:00
Juergen Spitzmueller
2e408d2fdc Do not output empty statement in lyx2lyx reversion 2024-09-17 15:53:18 +02:00
4 changed files with 102 additions and 14 deletions

View File

@ -7,8 +7,8 @@
# LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates,tabletemplates}
# LYX_USERDIR_VER = Name of environment variable for the user directory
# lyx =
# format = lyx16x|lyx20x|lyx21x|lyx22x|xhtml|docbook5|epub
# extension = 16.lyx|20.lyx|21.lyx|22.lyx|xhtml|xml|epub
# format = lyx16x|lyx20x|lyx21x|lyx22x|lyx23x|xhtml|docbook5|epub
# extension = 16.lyx|20.lyx|21.lyx|22.lyx|23.lyx|xhtml|xml|epub
# file = xxx
#
# Script should be called like:
@ -37,6 +37,7 @@ set(_TestResultMessage "")
message(STATUS "IgnoreErrorMessage = \"${IgnoreErrorMessage}\"")
set(Perl_Script "${TOP_SRC_DIR}/development/autotests/useSystemFonts.pl")
set(Structure_Script "${TOP_SRC_DIR}/development/autotests/beginEndStructureCheck.pl")
set(readDefaultOutputFormat "${TOP_SRC_DIR}/development/autotests/readDefaultOutputFormat.pl")
set(LanguageFile "${TOP_SRC_DIR}/lib/languages")
set(GetTempDir "${TOP_SRC_DIR}/development/autotests/getTempDir.pl")
set(_ft ${fonttype})
@ -226,6 +227,23 @@ set(ENV{LANGUAGE} "US:en")
if (extension MATCHES "\\.lyx$")
include(${TOP_SRC_DIR}/development/autotests/CheckLoadErrors.cmake)
get_md5sum(LYX_SOURCE source_md5sum _err)
message(STATUS "Executing ${PERL_EXECUTABLE} ${readDefaultOutputFormat} ${LYX_SOURCE}")
execute_process(
COMMAND ${PERL_EXECUTABLE} ${readDefaultOutputFormat} "${LYX_SOURCE}"
OUTPUT_VARIABLE _export_format)
message(STATUS "readDefaultOutputFormat = ${_export_format}")
if (${_export_format} MATCHES "pdf2")
set(_texformat "pdflatex")
elsif(${_export_format} MATCHES "pdf3")
set(_texformat "platex")
elsif(${_export_format} MATCHES "pdf4")
set(_texformat "xetex")
elsif(${_export_format} MATCHES "pdf5")
set(_texformat "luatex")
else()
set(_texformat "empty")
endif()
foreach(_lv RANGE 1 20)
set(used_tex_file "${result_file_base}.tex")
set(result_file_base "${result_file_base}.${LYX_FORMAT_NUM}")
@ -260,9 +278,11 @@ if (extension MATCHES "\\.lyx$")
break()
endif()
message(STATUS "Create the corresponding .tex file \"${used_tex_file}\"")
execute_process(
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E pdflatex ${used_tex_file} "${LYX_SOURCE}"
RESULT_VARIABLE _errx)
if (NOT ${_texformat} MATCHES "empty")
execute_process(
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${_texformat} ${used_tex_file} "${LYX_SOURCE}"
RESULT_VARIABLE _errx)
endif()
endif()
endif()
get_md5sum(result_file_name result_md5sum _err)
@ -284,12 +304,14 @@ if (extension MATCHES "\\.lyx$")
endif()
message(STATUS "Source(${LYX_SOURCE}) and dest(${result_file_name}) are equal")
message(STATUS "Now try to export the lyx2lyx created file")
message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E default \"${result_file_name}.default\" \"${result_file_name}\"")
execute_process(
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E default "${result_file_name}.default" "${result_file_name}"
RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)
Summary(_err "Test-compilation of \"${result_file_name}\" to format default")
if (_export_format MATCHES "^pdf")
message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${_export_format} \"${result_file_name}.default\" \"${result_file_name}\"")
execute_process(
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${_export_format} "${result_file_name}.default" "${result_file_name}"
RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)
Summary(_err "Test-compilation of \"${result_file_name}\" to format ${_export_format}")
endif()
break()
else()
list(APPEND _TestResultMessage "Warning: \"${LYX_SOURCE}\" and \"${result_file_name}\" differ")

View File

@ -0,0 +1,60 @@
#! /usr/bin/env perl
# -*- mode: perl; -*-
#
use strict;
my $useNonTexFonts = undef;
my $outputFormat = undef;
my $outputFormat = undef;
my $language = undef;
if (-e "$ARGV[0]") {
if (open(FI, "$ARGV[0]")) {
while (my $l = <FI>) {
chomp($l);
if ($l =~ /^\\use_non_tex_fonts\s+([a-z]+)/) {
$useNonTexFonts = ($1 eq "true");
}
elsif ($l =~ /^\\default_output_format\s+([a-z0-9]+)/) {
$outputFormat = $1;
}
elsif ($l =~ /\\language\s+([\-a-z_]+)/) {
$language = $1;
}
last if (defined($useNonTexFonts) && defined($outputFormat) && defined($language));
}
close(FI);
}
}
if (defined($useNonTexFonts) && defined($outputFormat)) {
if ($useNonTexFonts) {
if ($outputFormat eq "default") {
if ($language eq "japanese") {
$outputFormat = "pdf3";
}
else {
$outputFormat = "pdf5";
}
}
}
elsif ($outputFormat eq "default") {
if ($language eq "japanese") {
$outputFormat = "pdf3";
}
else {
$outputFormat = "pdf2";
}
}
if ($outputFormat !~ /^pdf/) {
$outputFormat = undef;
}
}
if (defined($outputFormat)) {
print "$outputFormat";
}
else {
print "undefined_output_format";
}
exit(0);

View File

@ -3219,24 +3219,31 @@ def revert_babelfont(document):
# set preamble stuff
pretext = ["%% This document must be processed with xelatex or lualatex!"]
pretext.append("\\AtBeginDocument{%")
have_append = False
if roman != "default":
pretext.append("\\babelfont{rm}[Mapping=tex-text]{" + roman + "}")
have_append = True
if sans != "default":
sf = "\\babelfont{sf}["
if sf_scale != 100.0:
sf += "Scale=" + str(sf_scale / 100.0) + ","
sf += "Mapping=tex-text]{" + sans + "}"
pretext.append(sf)
have_append = True
if typew != "default":
tw = "\\babelfont{tt}"
if tt_scale != 100.0:
tw += "[Scale=" + str(tt_scale / 100.0) + "]"
tw += "{" + typew + "}"
pretext.append(tw)
have_append = True
if osf:
pretext.append("\\defaultfontfeatures{Numbers=OldStyle}")
pretext.append("}")
insert_to_preamble(document, pretext)
have_append = True
if have_append:
pretext.append("}")
insert_to_preamble(document, pretext)
def revert_minionpro(document):

View File

@ -22,7 +22,6 @@
#include "BiblioInfo.h"
#include <QAbstractListModel>
#include <QStandardItemModel>
#include <QStringList>
#include <QStringListModel>