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
This commit is contained in:
Uwe Stöhr 2010-10-11 01:05:20 +00:00
parent 1e8059fcf2
commit e8a1fed47c
3 changed files with 40 additions and 12 deletions

View File

@ -2180,6 +2180,7 @@ def revert_rule(document):
else: else:
return return
def revert_diagram(document): def revert_diagram(document):
" Add the feyn package if \\Diagram is used in math " " Add the feyn package if \\Diagram is used in math "
i = 0 i = 0
@ -2202,6 +2203,34 @@ def revert_diagram(document):
return 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 # Conversion hub
@ -2263,10 +2292,12 @@ convert = [[346, []],
[398, []], [398, []],
[399, [convert_mathdots]], [399, [convert_mathdots]],
[400, [convert_rule]], [400, [convert_rule]],
[401, []] [401, []],
[402, [convert_bibtexClearpage]]
] ]
revert = [[400, [revert_diagram]], revert = [[401, []],
[400, [revert_diagram]],
[399, [revert_rule]], [399, [revert_rule]],
[398, [revert_mathdots]], [398, [revert_mathdots]],
[397, [revert_mathrsfs]], [397, [revert_mathrsfs]],

View File

@ -127,7 +127,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // 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<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -24,6 +24,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "PDFOptions.h"
#include "TextClass.h" #include "TextClass.h"
#include "frontends/alert.h" #include "frontends/alert.h"
@ -379,16 +380,12 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
// bibtotoc-Option // bibtotoc-Option
if (!bibtotoc.empty() && !buffer().params().use_bibtopic) { if (!bibtotoc.empty() && !buffer().params().use_bibtopic) {
if (buffer().params().documentClass().hasLaTeXLayout("chapter")) { // set label for hyperref, see http://www.lyx.org/trac/ticket/6470
if (buffer().params().sides == OneSide) { if (buffer().params().pdfoptions().use_hyperref)
// oneside os << "\\phantomsection";
os << "\\clearpage"; if (buffer().params().documentClass().hasLaTeXLayout("chapter"))
} else {
// twoside
os << "\\cleardoublepage";
}
os << "\\addcontentsline{toc}{chapter}{\\bibname}"; os << "\\addcontentsline{toc}{chapter}{\\bibname}";
} else if (buffer().params().documentClass().hasLaTeXLayout("section")) else if (buffer().params().documentClass().hasLaTeXLayout("section"))
os << "\\addcontentsline{toc}{section}{\\refname}"; os << "\\addcontentsline{toc}{section}{\\refname}";
} }