There are 3 issues in your patch:

According to 
ftp://ftp.fu-berlin.de/tex/CTAN/macros/latex/contrib/hyperref/backref.pdf
- the option is "page", not "pages" (my fault)
- the option "backref" is the same as "backref=section" so we shouldn't provide an "On" option as this only leads to confusion

> Is it possible to convert between pageref and pagebackref?

It is, this is the third issue. Simply deleting information in lyx2lyx is not an option. I changed it now so that pagebackref is converted to backref=page, otherwise this would be a dataloss.

> to me hyperref support is a new feature and there is no correct way how to
> put it back into 1.5.

But this already works. Nevertheless we should at least take care of existing LyX documents created with LyX 1.6svn (beta or RC). Therefore deleting is no option in lyx2lyx.

Attached is my patch that includes your patch and my fixes. I also attached a 
diff between both patches.

So OK from me for the attached patch ;-).

regards Uwe
3c3
< --- lib/lyx2lyx/lyx_1_6.py	(revision 26873)
---
> --- lib/lyx2lyx/lyx_1_6.py	(revision 26868)
5c5
< @@ -2971,6 +2971,19 @@
---
> @@ -2971,6 +2971,26 @@
11c11
< +    i = find_token(document.header, "\\pdf_pageref", 0)
---
> +    i = find_token(document.header, "\\pdf_backref page", 0)
13c13,17
< +        del document.header[i]
---
> +        document.header[i] = "\\pdf_pagebackref true"
> +        return
> +    j = find_token(document.header, "\\pdf_backref", 0)
> +    if j != -1:
> +        del document.header[j]
17,18c21,22
< +    ' We have lost pagebackref option in favor of pageref '
< +    i = find_token(document.header, "\\pdf_pagebackref", 0)
---
> +    ' We have changed the option pagebackref to backref=true '
> +    i = find_token(document.header, "\\pdf_pagebackref true", 0)
20c24,27
< +        del document.header[i]
---
> +        document.header[i] = "\\pdf_backref page"
> +    j = find_token(document.header, "\\pdf_pagebackref false", 0)
> +    if j != -1:
> +        del document.header[j]
25c32
< @@ -3042,10 +3055,12 @@
---
> @@ -3042,10 +3062,12 @@
42c49
< --- src/Buffer.cpp	(revision 26873)
---
> --- src/Buffer.cpp	(revision 26868)
51c58
< +int const LYX_FORMAT = 344;  // ps: backref
---
> +int const LYX_FORMAT = 344; // ps: backref
57c64
< --- src/frontends/qt4/GuiDocument.cpp	(revision 26873)
---
> --- src/frontends/qt4/GuiDocument.cpp	(revision 26868)
65c72
< +	"false", "true", "section", "slide", "pages", ""
---
> +	"false", "section", "slide", "page", ""
71c78
< +	N_("Off"), N_("On"), N_("Section"), N_("Slide"), N_("Pages"), ""
---
> +	N_("Off"), N_("Section"), N_("Slide"), N_("Page"), ""
126c133
< --- src/frontends/qt4/ui/PDFSupportUi.ui	(revision 26873)
---
> --- src/frontends/qt4/ui/PDFSupportUi.ui	(revision 26868)
295c302
< --- src/PDFOptions.cpp	(revision 26873)
---
> --- src/PDFOptions.cpp	(revision 26868)
348c355
< --- src/PDFOptions.h	(revision 26873)
---
> --- src/PDFOptions.h	(revision 26868)
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py	(revision 26868)
+++ lib/lyx2lyx/lyx_1_6.py	(working copy)
@@ -2971,6 +2971,26 @@
     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
 #
@@ -3042,10 +3062,12 @@
            [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, []],
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revision 26868)
+++ src/Buffer.cpp	(working copy)
@@ -115,7 +115,9 @@
 
 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;
Index: src/frontends/qt4/GuiDocument.cpp
===================================================================
--- src/frontends/qt4/GuiDocument.cpp	(revision 26868)
+++ src/frontends/qt4/GuiDocument.cpp	(working copy)
@@ -134,6 +134,18 @@
 };
 
 
+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,16 +1001,17 @@
 		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;
@@ -1802,8 +1815,8 @@
 	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
@@ -2135,8 +2148,11 @@
 	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);
 
Index: src/frontends/qt4/ui/PDFSupportUi.ui
===================================================================
--- src/frontends/qt4/ui/PDFSupportUi.ui	(revision 26868)
+++ src/frontends/qt4/ui/PDFSupportUi.ui	(working copy)
@@ -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&amp;ibliographical backreferences</string>
+               <string>B&amp;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&amp;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>
Index: src/PDFOptions.cpp
===================================================================
--- src/PDFOptions.cpp	(revision 26868)
+++ src/PDFOptions.cpp	(working copy)
@@ -47,7 +47,6 @@
 		&& pdfborder == x.pdfborder
 		&& colorlinks == x.colorlinks
 		&& backref == x.backref
-		&& pagebackref == x.pagebackref
 		&& pdfusetitle == x.pdfusetitle;
 }
 
@@ -76,8 +75,7 @@
 	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,8 +114,9 @@
 	opt += (pdfborder ?'0':'1');
 	opt += "},";
 
-	opt += "backref="        + convert<string>(backref) + ',';
-	opt += "pagebackref="    + convert<string>(pagebackref) + ',';
+	string tmp = backref == "true" ? "" : "=" + backref;
+	opt += "backref" + tmp + ',';
+
 	opt += "\n ";
 	opt += "colorlinks="     + convert<string>(colorlinks) + ',';
 	if (!pagemode.empty())
@@ -194,8 +193,6 @@
 		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 +228,7 @@
 	breaklinks              = false;
 	pdfborder               = false;
 	colorlinks              = false;
-	backref                 = false;
-	pagebackref             = false;
+	backref                 = "false";
 	pagemode.clear();
 	quoted_options.clear();
 	pdfusetitle             = true;  //in contrast with hyperref
Index: src/PDFOptions.h
===================================================================
--- src/PDFOptions.h	(revision 26868)
+++ src/PDFOptions.h	(working copy)
@@ -96,19 +96,15 @@
 	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, "false", "section", "slide", "pages"
+		*
+		* Internally we use true/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;
 		* the possibilities are None, UseThumbs (show thumbnails), UseOutlines
 		* (show bookmarks), and FullScreen.

Reply via email to