mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Sanitize backreferences in hyperref.
http://bugzilla.lyx.org/show_bug.cgi?id=5340 http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg144958.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26882 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
792ece8130
commit
308e2d9df3
@ -1,6 +1,10 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2008-10-12 Pavel Sanda <sanda@lyx.org>
|
||||
* Format incremented to 344: sanitize backreference settings
|
||||
for hyperref (fix bug 5340).
|
||||
|
||||
2008-10-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
* Format incremented to 343: new param \use_default_options
|
||||
(fix bug 2114).
|
||||
|
@ -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, []],
|
||||
|
@ -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<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -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<string>(breaklinks) << '\n';
|
||||
os << "\\pdf_pdfborder " << convert<string>(pdfborder) << '\n';
|
||||
os << "\\pdf_colorlinks " << convert<string>(colorlinks) << '\n';
|
||||
os << "\\pdf_backref " << convert<string>(backref) << '\n';
|
||||
os << "\\pdf_pagebackref " << convert<string>(pagebackref) << '\n';
|
||||
os << "\\pdf_backref " << backref << '\n';
|
||||
os << "\\pdf_pdfusetitle " << convert<string>(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<string>(backref) + ',';
|
||||
opt += "pagebackref=" + convert<string>(pagebackref) + ',';
|
||||
opt += "\n ";
|
||||
opt += "backref=" + backref + ',';
|
||||
opt += "colorlinks=" + convert<string>(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
|
||||
|
@ -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
|
||||
|
@ -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<pair<string, QString> > 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);
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>411</height>
|
||||
<width>437</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -64,7 +64,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
@ -77,7 +77,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>181</width>
|
||||
<height>41</height>
|
||||
@ -87,12 +87,12 @@
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pdfusetitleCB" >
|
||||
<property name="toolTip" >
|
||||
@ -200,7 +200,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
@ -210,12 +210,12 @@
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="breaklinksCB" >
|
||||
<property name="toolTip" >
|
||||
@ -244,24 +244,20 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="backrefCB" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="toolTip" >
|
||||
<string>Adds "backlink" text to the end of each item in the bibliography</string>
|
||||
<string>Bibliographical backreferences</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>B&ibliographical backreferences</string>
|
||||
<string>B&ackreferences:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>backrefCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pagebackrefCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Adds "backlink" text to the end of each item in the bibliography</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Backreference by pa&ge number</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="backrefCO" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -270,7 +266,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
@ -321,12 +317,12 @@
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="bookmarksopenlevelLA" >
|
||||
<property name="text" >
|
||||
@ -358,7 +354,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
@ -374,7 +370,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
@ -410,9 +406,7 @@
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLineEdit" name="optionsLE" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -433,7 +427,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>402</width>
|
||||
<height>16</height>
|
||||
|
Loading…
Reference in New Issue
Block a user