hi, this patch follows the recent discussions how to treat automatical filling of pdf header information from title and author environments + merge the fileformat changes kept in the stack from the past. the current solution is to have checkbox for automatical filling (set to true by default).
i would like to ask for help on two things, which i would finally solve somehow but they are just 5 min fixes for experts in the given areas i guess. 1. fileformat version & lyx2lyx to sum up the .lyx fileformat changes: option discarded:\pdf_store_options bool option added:\pdfusetitle bool option changed:\pdf_bookmarksopenlevel "3" -> \pdf_bookmarksopenlevel 3 2. qt designer showing incompatibilities between linux vs windows. i decreased the widths of boxes so they should appear ok now on windows but it looks bit 'underrated' here on linux. there are probably some components for automatical expanding window elements in designer (spacers?), but dont know how to use them correctly. after these two issues solved, i consider the basic pdf support feature complete from my point of view. until some bug or new request appears... thanks, pavel
Index: src/frontends/qt4/GuiDocument.cpp =================================================================== --- src/frontends/qt4/GuiDocument.cpp (revision 20866) +++ src/frontends/qt4/GuiDocument.cpp (working copy) @@ -654,6 +654,8 @@ this, SLOT(change_adaptor())); connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)), 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)), @@ -1249,6 +1251,7 @@ pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked(); 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(); @@ -1257,8 +1260,6 @@ else pdf.pagemode.clear(); pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text()); - if (pdf.use_hyperref || !pdf.empty()) - pdf.store_options = true; } @@ -1556,6 +1557,7 @@ pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks); 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); Index: src/frontends/qt4/ui/PDFSupportUi.ui =================================================================== --- src/frontends/qt4/ui/PDFSupportUi.ui (revision 20866) +++ src/frontends/qt4/ui/PDFSupportUi.ui (working copy) @@ -5,7 +5,7 @@ <rect> <x>0</x> <y>0</y> - <width>436</width> + <width>423</width> <height>394</height> </rect> </property> @@ -14,7 +14,7 @@ <rect> <x>2</x> <y>2</y> - <width>423</width> + <width>409</width> <height>381</height> </rect> </property> @@ -35,68 +35,90 @@ <rect> <x>186</x> <y>170</y> - <width>231</width> + <width>218</width> <height>148</height> </rect> </property> <property name="title" > <string>Links</string> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> + <widget class="QCheckBox" name="colorlinksCB" > + <property name="geometry" > + <rect> + <x>11</x> + <y>74</y> + <width>198</width> + <height>17</height> + </rect> </property> - <property name="spacing" > - <number>6</number> + <property name="text" > + <string>Color links</string> </property> - <item row="2" column="0" > - <widget class="QCheckBox" name="colorlinksCB" > - <property name="text" > - <string>Color links</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QCheckBox" name="pdfborderCB" > - <property name="text" > - <string>No frames around links</string> - </property> - <property name="tristate" > - <bool>false</bool> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QCheckBox" name="breaklinksCB" > - <property name="toolTip" > - <string>Allows link text to break across lines.</string> - </property> - <property name="text" > - <string>Break links over lines</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QCheckBox" name="backrefCB" > - <property name="toolTip" > - <string>Adds "backlink" text to the end of each item in the bibliography</string> - </property> - <property name="text" > - <string>&Bibliographical backreferences</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <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> - </item> - </layout> + </widget> + <widget class="QCheckBox" name="pdfborderCB" > + <property name="geometry" > + <rect> + <x>11</x> + <y>51</y> + <width>200</width> + <height>17</height> + </rect> + </property> + <property name="text" > + <string>No frames around links</string> + </property> + <property name="tristate" > + <bool>false</bool> + </property> + </widget> + <widget class="QCheckBox" name="breaklinksCB" > + <property name="geometry" > + <rect> + <x>11</x> + <y>27</y> + <width>201</width> + <height>18</height> + </rect> + </property> + <property name="toolTip" > + <string>Allows link text to break across lines.</string> + </property> + <property name="text" > + <string>Break links over lines</string> + </property> + </widget> + <widget class="QCheckBox" name="backrefCB" > + <property name="geometry" > + <rect> + <x>11</x> + <y>97</y> + <width>202</width> + <height>17</height> + </rect> + </property> + <property name="toolTip" > + <string>Adds "backlink" text to the end of each item in the bibliography</string> + </property> + <property name="text" > + <string>&Bibliographical backreferences</string> + </property> + </widget> + <widget class="QCheckBox" name="pagebackrefCB" > + <property name="geometry" > + <rect> + <x>11</x> + <y>120</y> + <width>202</width> + <height>17</height> + </rect> + </property> + <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> <widget class="QGroupBox" name="bookmarksGB" > <property name="geometry" > @@ -117,12 +139,24 @@ <bool>true</bool> </property> <layout class="QGridLayout" > - <property name="margin" > + <property name="leftMargin" > <number>9</number> </property> - <property name="spacing" > + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > <number>6</number> </property> + <property name="verticalSpacing" > + <number>6</number> + </property> <item row="0" column="0" > <widget class="QCheckBox" name="bookmarksnumberedCB" > <property name="text" > @@ -178,7 +212,7 @@ <property name="geometry" > <rect> <x>10</x> - <y>300</y> + <y>306</y> <width>161</width> <height>21</height> </rect> @@ -195,80 +229,124 @@ <rect> <x>6</x> <y>20</y> - <width>411</width> + <width>397</width> <height>141</height> </rect> </property> <property name="title" > <string>Header Information</string> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> + <widget class="QLineEdit" name="authorLE" > + <property name="geometry" > + <rect> + <x>75</x> + <y>55</y> + <width>315</width> + <height>22</height> + </rect> </property> - <property name="spacing" > - <number>6</number> + </widget> + <widget class="QLineEdit" name="titleLE" > + <property name="geometry" > + <rect> + <x>75</x> + <y>27</y> + <width>315</width> + <height>22</height> + </rect> </property> - <item row="1" column="1" > - <widget class="QLineEdit" name="authorLE" /> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="titleLE" /> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="titleL" > - <property name="text" > - <string>&Title:</string> - </property> - <property name="buddy" > - <cstring>titleLE</cstring> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="authorL" > - <property name="text" > - <string>&Author:</string> - </property> - <property name="buddy" > - <cstring>authorLE</cstring> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="subjectL" > - <property name="text" > - <string>&Subject:</string> - </property> - <property name="buddy" > - <cstring>subjectLE</cstring> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="keywordsL" > - <property name="text" > - <string>&Keywords:</string> - </property> - <property name="buddy" > - <cstring>keywordsLE</cstring> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="keywordsLE" /> - </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="subjectLE" /> - </item> - </layout> + </widget> + <widget class="QLabel" name="titleL" > + <property name="geometry" > + <rect> + <x>11</x> + <y>27</y> + <width>58</width> + <height>22</height> + </rect> + </property> + <property name="text" > + <string>&Title:</string> + </property> + <property name="buddy" > + <cstring>titleLE</cstring> + </property> + </widget> + <widget class="QLabel" name="authorL" > + <property name="geometry" > + <rect> + <x>11</x> + <y>55</y> + <width>58</width> + <height>21</height> + </rect> + </property> + <property name="text" > + <string>&Author:</string> + </property> + <property name="buddy" > + <cstring>authorLE</cstring> + </property> + </widget> + <widget class="QLabel" name="subjectL" > + <property name="geometry" > + <rect> + <x>11</x> + <y>82</y> + <width>58</width> + <height>21</height> + </rect> + </property> + <property name="text" > + <string>&Subject:</string> + </property> + <property name="buddy" > + <cstring>subjectLE</cstring> + </property> + </widget> + <widget class="QLabel" name="keywordsL" > + <property name="geometry" > + <rect> + <x>11</x> + <y>109</y> + <width>58</width> + <height>21</height> + </rect> + </property> + <property name="text" > + <string>&Keywords:</string> + </property> + <property name="buddy" > + <cstring>keywordsLE</cstring> + </property> + </widget> + <widget class="QLineEdit" name="keywordsLE" > + <property name="geometry" > + <rect> + <x>75</x> + <y>109</y> + <width>315</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QLineEdit" name="subjectLE" > + <property name="geometry" > + <rect> + <x>75</x> + <y>82</y> + <width>315</width> + <height>21</height> + </rect> + </property> + </widget> </widget> <widget class="QGroupBox" name="groupBox_3" > <property name="geometry" > <rect> <x>6</x> <y>330</y> - <width>411</width> + <width>397</width> <height>54</height> </rect> </property> @@ -284,24 +362,57 @@ <property name="checked" > <bool>false</bool> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> + <widget class="QLineEdit" name="optionsLE" > + <property name="geometry" > + <rect> + <x>11</x> + <y>21</y> + <width>384</width> + <height>22</height> + </rect> </property> - <property name="spacing" > - <number>6</number> + <property name="toolTip" > + <string>eg: pdfstartview=XYZ, plainpages=false, pdfpagelabels</string> </property> - <item row="0" column="0" > - <widget class="QLineEdit" name="optionsLE" > - <property name="toolTip" > - <string>eg: pdfstartview=XYZ, plainpages=false, pdfpagelabels</string> - </property> - </widget> - </item> - </layout> + </widget> </widget> + <widget class="QCheckBox" name="pdfusetitleCB" > + <property name="geometry" > + <rect> + <x>10</x> + <y>286</y> + <width>166</width> + <height>21</height> + </rect> + </property> + <property name="toolTip" > + <string>If not stated explicitly, fill title and author from appropriate environments</string> + </property> + <property name="text" > + <string>Automatically fill header</string> + </property> + </widget> </widget> </widget> + <tabstops> + <tabstop>use_hyperrefGB</tabstop> + <tabstop>titleLE</tabstop> + <tabstop>authorLE</tabstop> + <tabstop>subjectLE</tabstop> + <tabstop>keywordsLE</tabstop> + <tabstop>bookmarksGB</tabstop> + <tabstop>bookmarksnumberedCB</tabstop> + <tabstop>bookmarksopenGB</tabstop> + <tabstop>bookmarksopenlevelSB</tabstop> + <tabstop>breaklinksCB</tabstop> + <tabstop>pdfborderCB</tabstop> + <tabstop>colorlinksCB</tabstop> + <tabstop>backrefCB</tabstop> + <tabstop>pagebackrefCB</tabstop> + <tabstop>pdfusetitleCB</tabstop> + <tabstop>fullscreenCB</tabstop> + <tabstop>optionsLE</tabstop> + </tabstops> <includes> <include location="local" >qt_helpers.h</include> </includes> Index: src/PDFOptions.cpp =================================================================== --- src/PDFOptions.cpp (revision 20866) +++ src/PDFOptions.cpp (working copy) @@ -47,14 +47,14 @@ && pdfborder == x.pdfborder && colorlinks == x.colorlinks && backref == x.backref - && pagebackref == x.pagebackref ; + && pagebackref == x.pagebackref + && pdfusetitle == x.pdfusetitle; } void PDFOptions::writeFile(ostream & os) const { os << "\\use_hyperref " << convert<string>(use_hyperref) << '\n'; - os << "\\pdf_store_options " << convert<string>(store_options) << '\n'; - if (!use_hyperref && !store_options) + if (!use_hyperref && empty()) return; if (!title.empty() ) @@ -70,13 +70,14 @@ os << "\\pdf_bookmarks " << convert<string>(bookmarks) << '\n'; os << "\\pdf_bookmarksnumbered " << convert<string>(bookmarksnumbered) << '\n'; os << "\\pdf_bookmarksopen " << convert<string>(bookmarksopen) << '\n'; - os << "\\pdf_bookmarksopenlevel \"" << bookmarksopenlevel << "\"\n"; + os << "\\pdf_bookmarksopenlevel " << convert<string>(bookmarksopenlevel) << '\n'; 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_pdfusetitle " << convert<string>(pdfusetitle) << '\n'; if (!pagemode.empty()) os << "\\pdf_pagemode " << pagemode << '\n'; @@ -99,10 +100,10 @@ // try to extract author and title from document when none is // explicitely given - if (title.empty() && author.empty()) - opt += "pdfusetitle,\n "; - else - opt += "\n "; + if (pdfusetitle && title.empty() && author.empty()) + opt += "pdfusetitle,"; + opt += "\n "; + opt += "bookmarks=" + convert<string>(bookmarks) + ','; if (bookmarks) { opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ','; @@ -181,12 +182,14 @@ lex >> backref; } else if (token == "\\pdf_pagebackref") { lex >> pagebackref; + } else if (token == "\\pdf_pdfusetitle") { + lex >> pdfusetitle; } else if (token == "\\pdf_pagemode") { lex >> pagemode; } else if (token == "\\pdf_quoted_options") { lex >> quoted_options; } else if (token == "\\pdf_store_options") { - lex >> store_options; + //leftover from previous option; intended for later removal } else { return token; } @@ -200,7 +203,7 @@ return quoted_options; } -// Keep implicit hyperref settings +//set implicit settings for hyperref void PDFOptions::clear() { use_hyperref = false; @@ -219,7 +222,7 @@ pagebackref = false; pagemode.clear(); quoted_options.clear(); - store_options = false; + pdfusetitle = true; //in contrast with hyperref } } // namespace lyx Index: src/PDFOptions.h =================================================================== --- src/PDFOptions.h (revision 20866) +++ src/PDFOptions.h (working copy) @@ -19,18 +19,6 @@ class Lexer; /// Options for PDF generation - -/* - Possible cleanups, left for next fileformat change: - - - bookmarksopenlevel is stored in .lyx as string; - after change to spinbox it would be appropriate - change to int. - - store_options flag can be completely replaced by - function store_options() doing essentialy the same - as empty() now. -*/ - class PDFOptions { public: /// @@ -43,7 +31,7 @@ void writeLaTeX(odocstringstream &) const; /// read tokens from lyx header std::string readToken(Lexer &lex, std::string const & token); - /// keep implicit hyperref settings + /// set implicit settings for hyperref void clear(); /// @@ -128,6 +116,15 @@ * dialog -> PDFOptions.pagemode . */ std::string pagemode; + /** + * Flag indicating whether hyperref tries to derive the values for + * pdftitle and pdfauthor from \title and \author. + * pdfusetitle boolean false + * + * Note that we use true as default value instead. The option is also + * used in latex output only when title and author is not filled. + */ + bool pdfusetitle; ///latex string static const std::string pagemode_fullscreen; /** @@ -138,14 +135,6 @@ * Possible syntax check of users additional parameters here. */ std::string quoted_options_get() const; - - - /** - * Flag indicating whether user made some input into PDF preferences. - * We want to save options, when user decide to switch off PDF support - * for a while. - */ - bool store_options; }; } // namespace lyx