Nameref support.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34884 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-07-13 03:23:29 +00:00
parent e2e63b4b1b
commit 47db764ccc
5 changed files with 167 additions and 141 deletions

View File

@ -7,6 +7,11 @@ The good example would be 2010-01-10 entry.
-----------------------
2010-07-13 Richard Heck <rgheck@comcast.net>
* Format incremented to 396 (r34884)
nameref support
new commands nameref and Nameref for InsetRef
2010-07-13 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 395: support for ISO C-series paper format;
new parameter \papersize cxpaper with (x = 0 - 6)

View File

@ -91,6 +91,8 @@ Menuset
Item "On Page <Page>|O" "inset-modify changetype vpageref"
Item "<Reference> on Page <Page>|f" "inset-modify changetype vref"
Item "Formatted Reference|t" "inset-modify changetype prettyref"
Item "Textual Reference|x" "inset-modify changetype nameref"
Item "Textual Reference plus <page>|l" "inset-modify changetype Nameref"
Separator
Item "Settings...|S" "inset-settings"
End

View File

@ -1775,7 +1775,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
texrow.newlines(lines);
// set back for the rest
lyxpreamble.clear();
}
} else if (features.isRequired("nameref"))
// hyperref loads this automatically
lyxpreamble += "\\usepackage{nameref}\n";
// Will be surrounded by \makeatletter and \makeatother when not empty
docstring atlyxpreamble;

View File

@ -1,105 +1,103 @@
<ui version="4.0" >
<ui version="4.0">
<class>RefUi</class>
<widget class="QDialog" name="RefUi" >
<property name="geometry" >
<widget class="QDialog" name="RefUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<width>435</width>
<height>443</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string/>
</property>
<property name="sizeGripEnabled" >
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="2" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="findKeysLA" >
<property name="text" >
<widget class="QLabel" name="findKeysLA">
<property name="text">
<string>Fil&amp;ter:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>findLE</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="findLE" >
<property name="toolTip" >
<widget class="QLineEdit" name="findLE">
<property name="toolTip">
<string>Enter string to filter the label list</string>
</property>
<property name="text" >
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="csFindCB" >
<property name="toolTip" >
<widget class="QCheckBox" name="csFindCB">
<property name="toolTip">
<string>Filter case-sensitively</string>
</property>
<property name="text" >
<property name="text">
<string>Case-sensiti&amp;ve</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<item row="7" column="0" colspan="3">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="updatePB" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<widget class="QPushButton" name="updatePB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<property name="toolTip">
<string>Update the label list</string>
</property>
<property name="text" >
<property name="text">
<string>&amp;Update</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>31</width>
<height>30</height>
@ -108,88 +106,88 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="okPB" >
<property name="text" >
<widget class="QPushButton" name="okPB">
<property name="text">
<string>&amp;OK</string>
</property>
<property name="autoDefault" >
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default" >
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applyPB" >
<property name="text" >
<widget class="QPushButton" name="applyPB">
<property name="text">
<string>&amp;Apply</string>
</property>
<property name="autoDefault" >
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default" >
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closePB" >
<property name="text" >
<widget class="QPushButton" name="closePB">
<property name="text">
<string>&amp;Close</string>
</property>
<property name="autoDefault" >
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<item row="3" column="0" colspan="3">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="sortCB" >
<property name="toolTip" >
<widget class="QCheckBox" name="sortCB">
<property name="toolTip">
<string>Sort labels in alphabetical order (case-insensitively unless the Case-sensitive option is checked)</string>
</property>
<property name="text" >
<property name="text">
<string>&amp;Sort</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="caseSensitiveCB" >
<property name="enabled" >
<widget class="QCheckBox" name="caseSensitiveCB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip" >
<property name="toolTip">
<string>Sort labels case-sensitively in alphabetical order</string>
</property>
<property name="text" >
<property name="text">
<string>Cas&amp;e-sensitive</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="groupCB" >
<property name="toolTip" >
<string>Group labels by prefix (e.g. "sec:")</string>
<widget class="QCheckBox" name="groupCB">
<property name="toolTip">
<string>Group labels by prefix (e.g. &quot;sec:&quot;)</string>
</property>
<property name="text" >
<property name="text">
<string>Grou&amp;p</string>
</property>
</widget>
@ -198,10 +196,10 @@
</item>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
@ -210,143 +208,153 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="gotoPB" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<widget class="QPushButton" name="gotoPB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>&amp;Go to Label</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="refsL" >
<property name="text" >
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="refsL">
<property name="text">
<string>La&amp;bels in:</string>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>bufferCO</cstring>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QComboBox" name="bufferCO" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<item row="0" column="2">
<widget class="QComboBox" name="bufferCO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="nameL" >
<property name="enabled" >
<item row="6" column="0">
<widget class="QLabel" name="nameL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text" >
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>nameED</cstring>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2" >
<widget class="QLineEdit" name="nameED" >
<property name="enabled" >
<item row="6" column="1" colspan="2">
<widget class="QLineEdit" name="nameED">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="typeLA" >
<property name="text" >
<item row="5" column="0">
<widget class="QLabel" name="typeLA">
<property name="text">
<string>&amp;Format:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>typeLA</cstring>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2" >
<widget class="QComboBox" name="typeCO" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="typeCO">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<property name="toolTip">
<string>Cross-reference as it appears in output</string>
</property>
<item>
<property name="text" >
<string>&lt;reference></string>
<property name="text">
<string>&lt;reference&gt;</string>
</property>
</item>
<item>
<property name="text" >
<string>(&lt;reference>)</string>
<property name="text">
<string>(&lt;reference&gt;)</string>
</property>
</item>
<item>
<property name="text" >
<string>&lt;page></string>
<property name="text">
<string>&lt;page&gt;</string>
</property>
</item>
<item>
<property name="text" >
<string>on page &lt;page></string>
<property name="text">
<string>on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text" >
<string>&lt;reference> on page &lt;page></string>
<property name="text">
<string>&lt;reference&gt; on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Formatted reference</string>
</property>
</item>
<item>
<property name="text">
<string>Textual reference</string>
</property>
</item>
<item>
<property name="text">
<string>Textual reference plus &lt;page&gt;</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="referenceL" >
<property name="text" >
<item row="4" column="0">
<widget class="QLabel" name="referenceL">
<property name="text">
<string>&amp;Label:</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>referenceED</cstring>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2" >
<widget class="QLineEdit" name="referenceED" />
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="referenceED"/>
</item>
<item row="1" column="0" colspan="3" >
<widget class="QTreeWidget" name="refsTW" />
<item row="1" column="0" colspan="3">
<widget class="QTreeWidget" name="refsTW">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
@ -363,7 +371,7 @@
<tabstop>closePB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_i18n.h</include>
<include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections/>

View File

@ -52,7 +52,9 @@ bool InsetRef::isCompatibleCommand(string const & s) {
|| s == "vref"
|| s == "vpageref"
|| s == "prettyref"
|| s == "eqref";
|| s == "eqref"
|| s == "nameref"
|| s == "Nameref";
}
@ -132,9 +134,11 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
display_string = _("elsewhere");
else if (cmd == "eqref")
display_string = bformat(from_ascii("equation (%1$s)"), value);
else { // "prettyref"
else if (cmd == "prettyref"
// we don't really have the ability to handle these
// properly in XHTML output
|| cmd == "nameref" || cmd == "Nameref")
display_string = il->prettyCounter();
}
} else
display_string = ref;
@ -206,12 +210,15 @@ void InsetRef::addToToc(DocIterator const & cpit)
void InsetRef::validate(LaTeXFeatures & features) const
{
if (getCmdName() == "vref" || getCmdName() == "vpageref")
string const cmd = getCmdName();
if (cmd == "vref" || cmd == "vpageref")
features.require("varioref");
else if (getCmdName() == "prettyref")
else if (cmd == "prettyref")
features.require("prettyref");
else if (getCmdName() == "eqref")
else if (cmd == "eqref")
features.require("amsmath");
else if (cmd == "nameref" || cmd == "Nameref")
features.require("nameref");
}
@ -222,6 +229,8 @@ InsetRef::type_info InsetRef::types[] = {
{ "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
{ "prettyref", N_("PrettyRef"), N_("FrmtRef: ")},
{ "nameref", N_("Reference to Name"), N_("NameRef:")},
{ "Nameref", N_("Name+Textual Page"), N_("NamePgRef:")},
{ "", "", "" }
};