diff --git a/development/FORMAT b/development/FORMAT index aa9d26851f..436d074f08 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,10 @@ LyX file-format changes ----------------------- +2008-10-12 Pavel Sanda + * Format incremented to 344: sanitize backreference settings + for hyperref (fix bug 5340). + 2008-10-12 Jürgen Spitzmüller * Format incremented to 343: new param \use_default_options (fix bug 2114). diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 1d819e1ab3..39b4b3fd6a 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -2989,6 +2989,26 @@ def convert_default_options(document): document.header.insert(i, '\\use_default_options false') +def revert_backref_options(document): + ' Remove pageref additional options ' + i = find_token(document.header, "\\pdf_backref page", 0) + if i != -1: + document.header[i] = "\\pdf_pagebackref true" + return + j = find_token(document.header, "\\pdf_backref", 0) + if j != -1: + del document.header[j] + + +def convert_backref_options(document): + ' We have changed the option pagebackref to backref=true ' + i = find_token(document.header, "\\pdf_pagebackref true", 0) + if i != -1: + document.header[i] = "\\pdf_backref page" + j = find_token(document.header, "\\pdf_pagebackref false", 0) + if j != -1: + del document.header[j] + ## # Conversion hub # @@ -3060,10 +3080,12 @@ convert = [[277, [fix_wrong_tables]], [340, [add_plain_layout]], [341, []], [342, []], - [343, [convert_default_options]] + [343, [convert_default_options]], + [344, [convert_backref_options]] ] -revert = [[342, [revert_default_options]], +revert = [[343, [revert_backref_options]], + [342, [revert_default_options]], [341, [revert_mongolian]], [340, [revert_tabulators, revert_tabsize]], [339, []], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2e60e5c43c..51f4ebf762 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -115,7 +115,9 @@ namespace os = support::os; namespace { -int const LYX_FORMAT = 343; +// Do not remove the comment below, so we get merge conflict in +// in independent branches. +int const LYX_FORMAT = 344; // ps: backref typedef map DepClean; typedef map > RefCache; diff --git a/src/PDFOptions.cpp b/src/PDFOptions.cpp index 644f26e738..ff44a17ddb 100644 --- a/src/PDFOptions.cpp +++ b/src/PDFOptions.cpp @@ -47,7 +47,6 @@ bool PDFOptions::empty() const && pdfborder == x.pdfborder && colorlinks == x.colorlinks && backref == x.backref - && pagebackref == x.pagebackref && pdfusetitle == x.pdfusetitle; } @@ -76,8 +75,7 @@ void PDFOptions::writeFile(ostream & os) const os << "\\pdf_breaklinks " << convert(breaklinks) << '\n'; os << "\\pdf_pdfborder " << convert(pdfborder) << '\n'; os << "\\pdf_colorlinks " << convert(colorlinks) << '\n'; - os << "\\pdf_backref " << convert(backref) << '\n'; - os << "\\pdf_pagebackref " << convert(pagebackref) << '\n'; + os << "\\pdf_backref " << backref << '\n'; os << "\\pdf_pdfusetitle " << convert(pdfusetitle) << '\n'; if (!pagemode.empty()) @@ -116,9 +114,7 @@ void PDFOptions::writeLaTeX(odocstream & os, bool hyperref_already_provided) con opt += (pdfborder ?'0':'1'); opt += "},"; - opt += "backref=" + convert(backref) + ','; - opt += "pagebackref=" + convert(pagebackref) + ','; - opt += "\n "; + opt += "backref=" + backref + ','; opt += "colorlinks=" + convert(colorlinks) + ','; if (!pagemode.empty()) opt += "pdfpagemode=" + pagemode + ','; @@ -194,8 +190,6 @@ string PDFOptions::readToken(Lexer &lex, string const & token) lex >> colorlinks; } else if (token == "\\pdf_backref") { lex >> backref; - } else if (token == "\\pdf_pagebackref") { - lex >> pagebackref; } else if (token == "\\pdf_pdfusetitle") { lex >> pdfusetitle; } else if (token == "\\pdf_pagemode") { @@ -231,8 +225,7 @@ void PDFOptions::clear() breaklinks = false; pdfborder = false; colorlinks = false; - backref = false; - pagebackref = false; + backref = "false"; pagemode.clear(); quoted_options.clear(); pdfusetitle = true; //in contrast with hyperref diff --git a/src/PDFOptions.h b/src/PDFOptions.h index 2fa661aa71..187e80c25f 100644 --- a/src/PDFOptions.h +++ b/src/PDFOptions.h @@ -96,18 +96,14 @@ public: bool colorlinks; /** * Adds backlink text to the end of each item in the bibliography, - * as a list of section numbers. + * as a list of section/slide/page numbers. * This can only work properly if there is a blank line after each * \bibitem. - * backref boolean false + * backref string empty(="section"), "false", "section", "slide", "page" + * + * Internally we use false/section/slide/pages. See also bug 5340. */ - bool backref; - /** - * Adds backlink text to the end of each item in the bibliography, - * as a list of page numbers. - * pagebackref boolean false - */ - bool pagebackref; + std::string backref; /** * Determines how the file is opening in Acrobat; * the possibilities are None, UseThumbs (show thumbnails), UseOutlines diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index dbf961fbc1..8cc8e7bcf6 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -134,6 +134,18 @@ char const * tex_fonts_monospaced_gui[] = }; +char const * backref_opts[] = +{ + "false", "section", "slide", "page", "" +}; + + +char const * backref_opts_gui[] = +{ + N_("Off"), N_("Section"), N_("Slide"), N_("Page"), "" +}; + + vector > pagestyles; @@ -989,17 +1001,18 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor())); - connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)), + connect(pdfSupportModule->backrefCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor())); - connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)), - this, SLOT(change_adaptor())); connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor())); connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); + for (int i = 0; backref_opts[i][0]; ++i) + pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i])); + // float floatModule = new FloatPlacement; connect(floatModule, SIGNAL(changed()), @@ -1812,8 +1825,8 @@ void GuiDocument::apply(BufferParams & params) pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked(); pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked(); pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked(); - pdf.backref = pdfSupportModule->backrefCB->isChecked(); - pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked(); + pdf.backref = + backref_opts[pdfSupportModule->backrefCO->currentIndex()]; if (pdfSupportModule->fullscreenCB->isChecked()) pdf.pagemode = pdf.pagemode_fullscreen; else @@ -2145,8 +2158,11 @@ void GuiDocument::paramsToDialog(BufferParams const & params) pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder); pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle); pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks); - pdfSupportModule->backrefCB->setChecked(pdf.backref); - pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref); + + n = findToken(backref_opts, pdf.backref); + if (n >= 0) + pdfSupportModule->backrefCO->setCurrentIndex(n); + pdfSupportModule->fullscreenCB->setChecked (pdf.pagemode == pdf.pagemode_fullscreen); diff --git a/src/frontends/qt4/ui/PDFSupportUi.ui b/src/frontends/qt4/ui/PDFSupportUi.ui index f8e75aa535..40567bfc15 100644 --- a/src/frontends/qt4/ui/PDFSupportUi.ui +++ b/src/frontends/qt4/ui/PDFSupportUi.ui @@ -5,8 +5,8 @@ 0 0 - 420 - 411 + 437 + 400 @@ -64,7 +64,7 @@ Qt::Vertical - + 20 40 @@ -77,7 +77,7 @@ Qt::Horizontal - + 181 41 @@ -87,12 +87,12 @@ - - 0 - 6 + + 0 + @@ -200,7 +200,7 @@ Qt::Vertical - + 20 40 @@ -210,12 +210,12 @@ - - 0 - 6 + + 0 + @@ -244,24 +244,20 @@ - + - Adds "backlink" text to the end of each item in the bibliography + Bibliographical backreferences - B&ibliographical backreferences + B&ackreferences: + + + backrefCO - - - Adds "backlink" text to the end of each item in the bibliography - - - Backreference by pa&ge number - - + @@ -270,7 +266,7 @@ Qt::Horizontal - + 151 20 @@ -321,12 +317,12 @@ - - 0 - 6 + + 0 + @@ -358,7 +354,7 @@ Qt::Horizontal - + 40 20 @@ -374,7 +370,7 @@ Qt::Vertical - + 20 40 @@ -410,9 +406,7 @@ - - 7 - 0 + 0 0 @@ -433,7 +427,7 @@ Qt::Vertical - + 402 16