Author: rgheck
Date: Wed Nov 10 17:45:55 2010
New Revision: 36238
URL: http://www.lyx.org/trac/changeset/36238
Log:
Fix a bug in getFormattedReference().
Also, change from using the "cha" prefix for chapters, a la prettyref,
to the "chap" prefix, a la refstyle. We alias \...@chap to \...@cha for
prettyref users.
Modified:
lyx-devel/trunk/lib/layouts/stdrefprefix.inc
lyx-devel/trunk/src/insets/InsetRef.cpp
Modified: lyx-devel/trunk/lib/layouts/stdrefprefix.inc
==============================================================================
--- lyx-devel/trunk/lib/layouts/stdrefprefix.inc Wed Nov 10 17:07:08
2010 (r36237)
+++ lyx-devel/trunk/lib/layouts/stdrefprefix.inc Wed Nov 10 17:45:55
2010 (r36238)
@@ -14,7 +14,7 @@
End
IfStyle Chapter
- RefPrefix cha
+ RefPrefix chap
End
IfStyle Section
Modified: lyx-devel/trunk/src/insets/InsetRef.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetRef.cpp Wed Nov 10 17:07:08 2010
(r36237)
+++ lyx-devel/trunk/src/insets/InsetRef.cpp Wed Nov 10 17:45:55 2010
(r36238)
@@ -92,8 +92,15 @@
label = split(ref, prefix, ':');
// we have to have xxx:xxxxx...
+ if (label.empty()) {
+ LYXERR0("Label `" << ref << "' contains no prefix.");
+ label = ref;
+ prefix = from_ascii("");
+ return defcmd;
+ }
+
if (prefix.empty()) {
- LYXERR0("Label `" << label << "' contains no prefix.");
+ // we have ":xxxx"
label = ref;
return defcmd;
}
@@ -283,19 +290,25 @@
if (cmd == "vref" || cmd == "vpageref")
features.require("varioref");
else if (getCmdName() == "formatted") {
+ docstring const data = getEscapedLabel(features.runparams());
+ docstring label;
+ docstring prefix;
if (buffer().params().use_refstyle) {
features.require("refstyle");
- docstring const data =
getEscapedLabel(features.runparams());
- docstring label;
- docstring prefix;
string const fcmd = to_utf8(getFormattedCmd(data,
label, prefix));
if (!prefix.empty()) {
string lcmd =
"\\AtBeginDocument{\\providecommand" +
fcmd + "[1]{\\ref{" +
to_utf8(prefix) + ":#1}}}";
features.addPreambleSnippet(lcmd);
- }
- } else
+ } else if (prefix == "cha")
+
features.addPreambleSnippet("\\let\\charef=\\chapref");
+ } else {
features.require("prettyref");
+ // prettyref uses "cha" for chapters, so we provide a
kind of
+ // translation.
+ if (prefix == "chap")
+
features.addPreambleSnippet("\\let\...@chap=\\pr@cha");
+ }
} else if (getCmdName() == "eqref" && !buffer().params().use_refstyle)
// refstyle defines its own version
features.require("amsmath");