From e8a1fed47c15c7c2c9419894bcf39a0bc2aa43f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 11 Oct 2010 01:05:20 +0000 Subject: [PATCH] InsetBibtex.cpp: - fix #1881, fileformat change - fix #6470 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35590 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 35 +++++++++++++++++++++++++++++++++-- src/Buffer.cpp | 2 +- src/insets/InsetBibtex.cpp | 15 ++++++--------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 530446472b..45015937d2 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -2180,6 +2180,7 @@ def revert_rule(document): else: return + def revert_diagram(document): " Add the feyn package if \\Diagram is used in math " i = 0 @@ -2202,6 +2203,34 @@ def revert_diagram(document): return +def convert_bibtexClearpage(document): + " insert a clear(double)page bibliographystyle if bibtotoc option is used " + while True: + i = find_token(document.header, '\\papersides', 0) + document.warning(str(i)) + if i == -1: + document.warning("Malformed LyX document: Can't find papersides definition.") + return + else: + sides = int(document.header[i][12]) + # only act of there is the option "bibtotoc" + j = find_token(document.body, 'options "bibtotoc', 0) + if j == -1: + return + subst1 = '\\begin_layout Standard\n' \ + + '\\begin_inset Newpage clearpage\n' \ + + '\end_inset\n\n\n' \ + + '\end_layout\n' + subst2 = '\\begin_layout Standard\n' \ + + '\\begin_inset Newpage cleardoublepage\n' \ + + '\end_inset\n\n\n' \ + + '\end_layout\n' + if sides == 1: + document.body.insert(j -5, subst1) + else: + document.body.insert(j -5, subst2) + return + ## # Conversion hub @@ -2263,10 +2292,12 @@ convert = [[346, []], [398, []], [399, [convert_mathdots]], [400, [convert_rule]], - [401, []] + [401, []], + [402, [convert_bibtexClearpage]] ] -revert = [[400, [revert_diagram]], +revert = [[401, []], + [400, [revert_diagram]], [399, [revert_rule]], [398, [revert_mathdots]], [397, [revert_mathrsfs]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f0b5ea2353..91fc9fdd4d 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -127,7 +127,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 401; // Ronen: support for \Diagram +int const LYX_FORMAT = 402; // uwestoehr: fix for bug 1881 typedef map DepClean; typedef map > RefCache; diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index b4869b0c1b..36485d8f84 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -24,6 +24,7 @@ #include "LaTeXFeatures.h" #include "output_xhtml.h" #include "OutputParams.h" +#include "PDFOptions.h" #include "TextClass.h" #include "frontends/alert.h" @@ -379,16 +380,12 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const // bibtotoc-Option if (!bibtotoc.empty() && !buffer().params().use_bibtopic) { - if (buffer().params().documentClass().hasLaTeXLayout("chapter")) { - if (buffer().params().sides == OneSide) { - // oneside - os << "\\clearpage"; - } else { - // twoside - os << "\\cleardoublepage"; - } + // set label for hyperref, see http://www.lyx.org/trac/ticket/6470 + if (buffer().params().pdfoptions().use_hyperref) + os << "\\phantomsection"; + if (buffer().params().documentClass().hasLaTeXLayout("chapter")) os << "\\addcontentsline{toc}{chapter}{\\bibname}"; - } else if (buffer().params().documentClass().hasLaTeXLayout("section")) + else if (buffer().params().documentClass().hasLaTeXLayout("section")) os << "\\addcontentsline{toc}{section}{\\refname}"; } -- 2.39.2