From 3ccb9d8af9225853cc87142fe7472dcd079c4a27 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Thu, 15 Feb 2007 20:14:12 +0000 Subject: [PATCH] * src/exporter.C (Exporter::Export): Remove hardcoded check for lyx backend. Use the shortest converter path instead, that is more flexible and always correct. * lib/configure.py: Add new formats and converters for importing and exporting files from CJK LyX. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17202 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/configure.py | 11 ++++++++++- src/exporter.C | 23 ++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index 8ae35687b7..53c0c47d7a 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -301,6 +301,9 @@ def checkFormatEntries(dtl_tools): \Format lyx lyx LyX "" "" "" "" \Format lyx13x lyx13 "LyX 1.3.x" "" "" "" "document" \Format lyx14x lyx14 "LyX 1.4.x" "" "" "" "document" +\Format clyx cjklyx "CJK LyX 1.4.x (big5)" "" "" "" "document" +\Format jlyx cjklyx "CJK LyX 1.4.x (euc-jp)" "" "" "" "document" +\Format klyx cjklyx "CJK LyX 1.4.x (euc-kr)" "" "" "" "document" \Format lyxpreview lyxpreview "LyX Preview" "" "" "" "" \Format pdftex pdftex_t PDFTEX "" "" "" "" \Format program "" Program "" "" "" "" @@ -449,7 +452,7 @@ def checkConverterEntries(): # FIXME: no rc_entry? comment it out # checkProg('Image converter', ['convert $$i $$o']) # - # Entried that do not need checkProg + # Entries that do not need checkProg addToRC(r'''\converter lyxpreview ppm "python -tt $$s/scripts/lyxpreview2bitmap.py" "" \converter date dateout "python -tt $$s/scripts/date.py %d-%m-%Y > $$o" "" \converter docbook docbook-xml "cp $$i $$o" "xml" @@ -458,6 +461,12 @@ def checkConverterEntries(): \converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" "" \converter lyx lyx13x "python -tt $$s/lyx2lyx/lyx2lyx -t 221 $$i > $$o" "" \converter lyx lyx14x "python -tt $$s/lyx2lyx/lyx2lyx -t 245 $$i > $$o" "" +\converter lyx clyx "python -tt $$s/lyx2lyx/lyx2lyx -c big5 -t 245 $$i > $$o" "" +\converter lyx jlyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_jp -t 245 $$i > $$o" "" +\converter lyx klyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr -t 245 $$i > $$o" "" +\converter clyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c big5 $$i > $$o" "" +\converter jlyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_jp $$i > $$o" "" +\converter klyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr $$i > $$o" "" ''') diff --git a/src/exporter.C b/src/exporter.C index 51184170eb..d3ff74a95e 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -153,27 +153,20 @@ bool Exporter::Export(Buffer * buffer, string const & format, runparams.flavor = OutputParams::LATEX; runparams.linelen = lyxrc.plaintext_linelen; vector backends = Backends(*buffer); - // FIXME: Without this test export to lyx1[34] would be through - // latex -> lyx -> lyx1[34], because the first backend below with a - // working conversion path is used. We should replace this test and - // the explicit loop below with a method - // getShortestPath(vector const & from, string const & to) - // which returns the shortest path from one of the formats in 'from' - // to 'to'. - if ((format == "lyx13x" || format == "lyx14x") && - !theConverters().getPath("lyx", format).empty()) - backend_format = "lyx"; - else if (find(backends.begin(), backends.end(), format) == backends.end()) { + if (find(backends.begin(), backends.end(), format) == backends.end()) { + // Get shortest path to format + Graph::EdgePath path; for (vector::const_iterator it = backends.begin(); it != backends.end(); ++it) { Graph::EdgePath p = theConverters().getPath(*it, format); - if (!p.empty()) { - runparams.flavor = theConverters().getFlavor(p); + if (!p.empty() && (path.empty() || p.size() < path.size())) { backend_format = *it; - break; + path = p; } } - if (backend_format.empty()) { + if (!path.empty()) + runparams.flavor = theConverters().getFlavor(path); + else { Alert::error(_("Couldn't export file"), bformat(_("No information for exporting the format %1$s."), formats.prettyName(format)));