mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +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
|
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>
|
2008-10-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
* Format incremented to 343: new param \use_default_options
|
* Format incremented to 343: new param \use_default_options
|
||||||
(fix bug 2114).
|
(fix bug 2114).
|
||||||
|
@ -2989,6 +2989,26 @@ def convert_default_options(document):
|
|||||||
document.header.insert(i, '\\use_default_options false')
|
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
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -3060,10 +3080,12 @@ convert = [[277, [fix_wrong_tables]],
|
|||||||
[340, [add_plain_layout]],
|
[340, [add_plain_layout]],
|
||||||
[341, []],
|
[341, []],
|
||||||
[342, []],
|
[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]],
|
[341, [revert_mongolian]],
|
||||||
[340, [revert_tabulators, revert_tabsize]],
|
[340, [revert_tabulators, revert_tabsize]],
|
||||||
[339, []],
|
[339, []],
|
||||||
|
@ -115,7 +115,9 @@ namespace os = support::os;
|
|||||||
|
|
||||||
namespace {
|
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<string, bool> DepClean;
|
||||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||||
|
@ -47,7 +47,6 @@ bool PDFOptions::empty() const
|
|||||||
&& pdfborder == x.pdfborder
|
&& pdfborder == x.pdfborder
|
||||||
&& colorlinks == x.colorlinks
|
&& colorlinks == x.colorlinks
|
||||||
&& backref == x.backref
|
&& backref == x.backref
|
||||||
&& pagebackref == x.pagebackref
|
|
||||||
&& pdfusetitle == x.pdfusetitle;
|
&& pdfusetitle == x.pdfusetitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +75,7 @@ void PDFOptions::writeFile(ostream & os) const
|
|||||||
os << "\\pdf_breaklinks " << convert<string>(breaklinks) << '\n';
|
os << "\\pdf_breaklinks " << convert<string>(breaklinks) << '\n';
|
||||||
os << "\\pdf_pdfborder " << convert<string>(pdfborder) << '\n';
|
os << "\\pdf_pdfborder " << convert<string>(pdfborder) << '\n';
|
||||||
os << "\\pdf_colorlinks " << convert<string>(colorlinks) << '\n';
|
os << "\\pdf_colorlinks " << convert<string>(colorlinks) << '\n';
|
||||||
os << "\\pdf_backref " << convert<string>(backref) << '\n';
|
os << "\\pdf_backref " << backref << '\n';
|
||||||
os << "\\pdf_pagebackref " << convert<string>(pagebackref) << '\n';
|
|
||||||
os << "\\pdf_pdfusetitle " << convert<string>(pdfusetitle) << '\n';
|
os << "\\pdf_pdfusetitle " << convert<string>(pdfusetitle) << '\n';
|
||||||
|
|
||||||
if (!pagemode.empty())
|
if (!pagemode.empty())
|
||||||
@ -116,9 +114,7 @@ void PDFOptions::writeLaTeX(odocstream & os, bool hyperref_already_provided) con
|
|||||||
opt += (pdfborder ?'0':'1');
|
opt += (pdfborder ?'0':'1');
|
||||||
opt += "},";
|
opt += "},";
|
||||||
|
|
||||||
opt += "backref=" + convert<string>(backref) + ',';
|
opt += "backref=" + backref + ',';
|
||||||
opt += "pagebackref=" + convert<string>(pagebackref) + ',';
|
|
||||||
opt += "\n ";
|
|
||||||
opt += "colorlinks=" + convert<string>(colorlinks) + ',';
|
opt += "colorlinks=" + convert<string>(colorlinks) + ',';
|
||||||
if (!pagemode.empty())
|
if (!pagemode.empty())
|
||||||
opt += "pdfpagemode=" + pagemode + ',';
|
opt += "pdfpagemode=" + pagemode + ',';
|
||||||
@ -194,8 +190,6 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
|
|||||||
lex >> colorlinks;
|
lex >> colorlinks;
|
||||||
} else if (token == "\\pdf_backref") {
|
} else if (token == "\\pdf_backref") {
|
||||||
lex >> backref;
|
lex >> backref;
|
||||||
} else if (token == "\\pdf_pagebackref") {
|
|
||||||
lex >> pagebackref;
|
|
||||||
} else if (token == "\\pdf_pdfusetitle") {
|
} else if (token == "\\pdf_pdfusetitle") {
|
||||||
lex >> pdfusetitle;
|
lex >> pdfusetitle;
|
||||||
} else if (token == "\\pdf_pagemode") {
|
} else if (token == "\\pdf_pagemode") {
|
||||||
@ -231,8 +225,7 @@ void PDFOptions::clear()
|
|||||||
breaklinks = false;
|
breaklinks = false;
|
||||||
pdfborder = false;
|
pdfborder = false;
|
||||||
colorlinks = false;
|
colorlinks = false;
|
||||||
backref = false;
|
backref = "false";
|
||||||
pagebackref = false;
|
|
||||||
pagemode.clear();
|
pagemode.clear();
|
||||||
quoted_options.clear();
|
quoted_options.clear();
|
||||||
pdfusetitle = true; //in contrast with hyperref
|
pdfusetitle = true; //in contrast with hyperref
|
||||||
|
@ -96,18 +96,14 @@ public:
|
|||||||
bool colorlinks;
|
bool colorlinks;
|
||||||
/**
|
/**
|
||||||
* Adds backlink text to the end of each item in the bibliography,
|
* 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
|
* This can only work properly if there is a blank line after each
|
||||||
* \bibitem.
|
* \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;
|
std::string backref;
|
||||||
/**
|
|
||||||
* Adds backlink text to the end of each item in the bibliography,
|
|
||||||
* as a list of page numbers.
|
|
||||||
* pagebackref boolean false
|
|
||||||
*/
|
|
||||||
bool pagebackref;
|
|
||||||
/**
|
/**
|
||||||
* Determines how the file is opening in Acrobat;
|
* Determines how the file is opening in Acrobat;
|
||||||
* the possibilities are None, UseThumbs (show thumbnails), UseOutlines
|
* 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;
|
vector<pair<string, QString> > pagestyles;
|
||||||
|
|
||||||
|
|
||||||
@ -989,17 +1001,18 @@ GuiDocument::GuiDocument(GuiView & lv)
|
|||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
|
connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
|
connect(pdfSupportModule->backrefCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
|
connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(change_adaptor()));
|
|
||||||
connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
|
connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)),
|
connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
|
|
||||||
|
for (int i = 0; backref_opts[i][0]; ++i)
|
||||||
|
pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
|
||||||
|
|
||||||
// float
|
// float
|
||||||
floatModule = new FloatPlacement;
|
floatModule = new FloatPlacement;
|
||||||
connect(floatModule, SIGNAL(changed()),
|
connect(floatModule, SIGNAL(changed()),
|
||||||
@ -1812,8 +1825,8 @@ void GuiDocument::apply(BufferParams & params)
|
|||||||
pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
|
pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
|
||||||
pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
|
pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
|
||||||
pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
|
pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
|
||||||
pdf.backref = pdfSupportModule->backrefCB->isChecked();
|
pdf.backref =
|
||||||
pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
|
backref_opts[pdfSupportModule->backrefCO->currentIndex()];
|
||||||
if (pdfSupportModule->fullscreenCB->isChecked())
|
if (pdfSupportModule->fullscreenCB->isChecked())
|
||||||
pdf.pagemode = pdf.pagemode_fullscreen;
|
pdf.pagemode = pdf.pagemode_fullscreen;
|
||||||
else
|
else
|
||||||
@ -2145,8 +2158,11 @@ void GuiDocument::paramsToDialog(BufferParams const & params)
|
|||||||
pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
|
pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
|
||||||
pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
|
pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
|
||||||
pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
|
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
|
pdfSupportModule->fullscreenCB->setChecked
|
||||||
(pdf.pagemode == pdf.pagemode_fullscreen);
|
(pdf.pagemode == pdf.pagemode_fullscreen);
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>420</width>
|
<width>437</width>
|
||||||
<height>411</height>
|
<height>400</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>181</width>
|
<width>181</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
@ -87,12 +87,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0" >
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="pdfusetitleCB" >
|
<widget class="QCheckBox" name="pdfusetitleCB" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -200,7 +200,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
@ -210,12 +210,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="breaklinksCB" >
|
<widget class="QCheckBox" name="breaklinksCB" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
@ -244,24 +244,20 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="backrefCB" >
|
<widget class="QLabel" name="label" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Adds "backlink" text to the end of each item in the bibliography</string>
|
<string>Bibliographical backreferences</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>B&ibliographical backreferences</string>
|
<string>B&ackreferences:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>backrefCO</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="pagebackrefCB" >
|
<widget class="QComboBox" name="backrefCO" />
|
||||||
<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>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -270,7 +266,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>151</width>
|
<width>151</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
@ -321,12 +317,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="bookmarksopenlevelLA" >
|
<widget class="QLabel" name="bookmarksopenlevelLA" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
@ -358,7 +354,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
@ -374,7 +370,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
@ -410,9 +406,7 @@
|
|||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<widget class="QLineEdit" name="optionsLE" >
|
<widget class="QLineEdit" name="optionsLE" >
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
<sizepolicy>
|
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||||
<hsizetype>7</hsizetype>
|
|
||||||
<vsizetype>0</vsizetype>
|
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -433,7 +427,7 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>402</width>
|
<width>402</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
|
Loading…
Reference in New Issue
Block a user