]> git.lyx.org Git - features.git/commitdiff
InsetBibtex.cpp:
authorUwe Stöhr <uwestoehr@web.de>
Mon, 11 Oct 2010 01:05:20 +0000 (01:05 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 11 Oct 2010 01:05:20 +0000 (01:05 +0000)
- 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
src/Buffer.cpp
src/insets/InsetBibtex.cpp

index 530446472b154a2474f43decfc6bcf9b3ca3058a..45015937d2dfc8b7d965be281bf5ef7336cafca8 100644 (file)
@@ -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]],
index f0b5ea2353300fdda4829608b4b285af36412280..91fc9fdd4d4b78cd1a7ce4b5d6fb5480b45fc7b8 100644 (file)
@@ -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<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index b4869b0c1b5e02e201498c49738cf1e8b0867042..36485d8f8443193fa6276cc98b28ae45a1a971c8 100644 (file)
@@ -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}";
        }