]> git.lyx.org Git - features.git/commitdiff
Pavel Sanda's "PDFOptions" patch
authorAndré Pönitz <poenitz@gmx.net>
Thu, 20 Sep 2007 22:31:18 +0000 (22:31 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 20 Sep 2007 22:31:18 +0000 (22:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20389 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/Makefile.am
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/Makefile.am
src/frontends/qt4/ui/compile_uic.sh
src/insets/Inset.cpp

index 19d479cc9b2c8f1b1826723d22f479045b3dddfc..75799f764969b5ba665083e19a90f4e964a6a041 100644 (file)
@@ -55,6 +55,7 @@
 #include "Undo.h"
 #include "version.h"
 #include "EmbeddedFiles.h"
+#include "PDFOptions.h"
 
 #include "insets/InsetBibitem.h"
 #include "insets/InsetBibtex.h"
@@ -459,6 +460,7 @@ int Buffer::readHeader(Lexer & lex)
        params().footskip.erase();
        params().listings_params.clear();
        params().clearLayoutModules();
+       params().pdfoptions().clear();
        
        for (int i = 0; i < 4; ++i) {
                params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
index 2577abd1f823d63c01452f33c411dac08275068d..785e54d2d5e432c86f7736ec3e8e27a3ed2f55ef 100644 (file)
@@ -37,6 +37,7 @@
 #include "Spacing.h"
 #include "TexRow.h"
 #include "VSpace.h"
+#include "PDFOptions.h"
 
 #include "frontends/alert.h"
 #include "insets/InsetListingsParams.h"
@@ -44,6 +45,7 @@
 #include "support/convert.h"
 #include "support/filetools.h"
 #include "support/Translator.h"
+#include "support/lstrings.h"
 
 #include <boost/array.hpp>
 
@@ -63,6 +65,7 @@ using lyx::support::libFileSearch;
 using lyx::support::bformat;
 using lyx::support::rtrim;
 using lyx::support::tokenPos;
+using lyx::support::prefixIs;
 
 
 static char const * const string_paragraph_separation[] = {
@@ -290,6 +293,7 @@ public:
         * and for detached paragraphs in "indented" documents.
         */
        VSpace defskip;
+       PDFOptions pdfoptions;
 };
 
 
@@ -435,6 +439,16 @@ Spacing const & BufferParams::spacing() const
        return pimpl_->spacing;
 }
 
+PDFOptions & BufferParams::pdfoptions()
+{
+       return pimpl_->pdfoptions;
+}
+
+
+PDFOptions const & BufferParams::pdfoptions() const
+{
+       return pimpl_->pdfoptions;
+}
 
 VSpace const & BufferParams::getDefSkip() const
 {
@@ -633,6 +647,15 @@ string const BufferParams::readToken(Lexer & lex, string const & token)
                spacing().set(spacetranslator().find(nspacing), tmp_val);
        } else if (token == "\\float_placement") {
                lex >> float_placement;
+
+       } else if (prefixIs(token, "\\pdf_") || token == "\\use_hyperref") {
+               string toktmp;
+               toktmp = pdfoptions().readToken(lex, token);
+               if (!toktmp.empty()) {
+                       lyxerr << "PDFOptions::readToken(): Unknown token: " <<
+                               toktmp << endl;
+                       return toktmp;
+               }
        } else {
                lyxerr << "BufferParams::readToken(): Unknown token: " << 
                        token << endl;
@@ -694,6 +717,7 @@ void BufferParams::writeFile(ostream & os) const
        os << "\\paperfontsize " << fontsize << '\n';
 
        spacing().writeFile(os);
+       pdfoptions().writeFile(os);
 
        os << "\\papersize " << string_papersize[papersize]
           << "\n\\use_geometry " << convert<string>(use_geometry)
@@ -1167,6 +1191,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                lyxpreamble += from_utf8(features.getBabelOptions());
        }
 
+       // PDF support. Hypreref manual: "Make sure it comes last of your loaded
+       // packages, to give it a fighting chance of not being over-written,
+       // since its job is to redefine many LATEX commands."
+       // Has to be put into lyxpreamble (preserving line-counting for error
+       // parsing).
+       odocstringstream oss;
+       pdfoptions().writeLaTeX(oss);
+       lyxpreamble += oss.str();
+
        lyxpreamble += "\\makeatother\n\n";
 
        int const nlines =
index 62a481961d90d2dc560371aa8923055fcf66da30..bf3968ecb08aa8df15fa261ce99c045d2510fd0e 100644 (file)
@@ -39,6 +39,7 @@ class Spacing;
 class TexRow;
 class VSpace;
 class Language;
+class PDFOptions;
 
 /** Buffer parameters.
  *  This class contains all the parameters for this buffer's use. Some
@@ -289,6 +290,10 @@ public:
        ///
        void setCiteEngine(biblio::CiteEngine const);
 
+       /// options for pdf output
+       PDFOptions & pdfoptions();
+       PDFOptions const & pdfoptions() const;
+
 private:
        ///
        void readPreamble(Lexer &);
index df2a355c13794d4b69244ef6ab9bbc554f11ec19..7c90cf2cee41da6bdf498d7456646867db20f0f5 100644 (file)
@@ -233,6 +233,8 @@ liblyxcore_la_SOURCES = \
        ParagraphParameters.h \
        ParIterator.cpp \
        ParIterator.h \
+       PDFOptions.cpp \
+       PDFOptions.h \
        Row.cpp \
        Row.h \
        rowpainter.cpp \
index f835ed91e40a084dea56e2b20887bf7426d8ec50..0511db0c8a827231b7d06b7d61f0132d2f573c66 100644 (file)
@@ -32,6 +32,7 @@
 #include "LyXRC.h" // defaultUnit
 #include "TextClassList.h"
 #include "Spacing.h"
+#include "PDFOptions.h"
 
 #include "insets/InsetListingsParams.h"
 
@@ -610,6 +611,41 @@ GuiDocumentDialog::GuiDocumentDialog(LyXView & lv)
        connect(bulletsModule, SIGNAL(changed()),
                this, SLOT(change_adaptor()));
 
+       // PDF support
+       pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
+
+       connect(pdfSupportModule->use_hyperrefCB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->bookmarksopenlevelLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
+               this, SLOT(change_adaptor()));
+       connect(pdfSupportModule->backrefCB, 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(const QString &)),
+               this, SLOT(change_adaptor()));
 
        // float
        floatModule = new FloatPlacement;
@@ -624,6 +660,7 @@ GuiDocumentDialog::GuiDocumentDialog(LyXView & lv)
        docPS->addPanel(langModule, _("Language"));
        docPS->addPanel(numberingModule, _("Numbering & TOC"));
        docPS->addPanel(biblioModule, _("Bibliography"));
+       docPS->addPanel(pdfSupportModule, _("PDF Properties"));
        docPS->addPanel(mathsModule, _("Math Options"));
        docPS->addPanel(floatModule, _("Float Placement"));
        docPS->addPanel(bulletsModule, _("Bullets"));
@@ -946,6 +983,7 @@ void GuiDocumentDialog::updateNumbering()
        numberingModule->tocTW->update();
 }
 
+
 void GuiDocumentDialog::apply(BufferParams & params)
 {
        // preamble
@@ -1180,20 +1218,39 @@ void GuiDocumentDialog::apply(BufferParams & params)
        Ui::MarginsUi const * m(marginsModule);
 
        params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
-
        params.topmargin = widgetsToLength(m->topLE, m->topUnit);
-
        params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
-
        params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
-
        params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
-
        params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
-
        params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
 
        branchesModule->apply(params);
+
+       // PDF support
+       PDFOptions & pdf = params.pdfoptions();
+       pdf.use_hyperref_ = pdfSupportModule->use_hyperrefCB->isChecked();
+       pdf.title_ = fromqstr(pdfSupportModule->titleLE->text());
+       pdf.author_ = fromqstr(pdfSupportModule->authorLE->text());
+       pdf.subject_ = fromqstr(pdfSupportModule->subjectLE->text());
+       pdf.keywords_ = fromqstr(pdfSupportModule->keywordsLE->text());
+
+       pdf.bookmarks_ = pdfSupportModule->bookmarksGB->isChecked();
+       pdf.bookmarksnumbered_ = pdfSupportModule->bookmarksnumberedCB->isChecked();
+       pdf.bookmarksopen_ = pdfSupportModule->bookmarksopenGB->isChecked();
+       pdf.bookmarksopenlevel_ =
+               fromqstr(pdfSupportModule->bookmarksopenlevelLE->text());
+
+       pdf.breaklinks_ = pdfSupportModule->breaklinksCB->isChecked();
+       pdf.pdfborder_ = pdfSupportModule->pdfborderCB->isChecked();
+       pdf.colorlinks_ = pdfSupportModule->colorlinksCB->isChecked();
+       pdf.backref_ = pdfSupportModule->backrefCB->isChecked();
+       pdf.pagebackref_        = pdfSupportModule->pagebackrefCB->isChecked();
+       if (pdfSupportModule->fullscreenCB->isChecked())
+               pdf.pagemode_ = pdf.pagemode_fullscreen_;
+       pdf.quoted_options_ = fromqstr(pdfSupportModule->optionsLE->text());
+       if (pdf.use_hyperref_ || !pdf.empty())
+               pdf.store_options_ = true;
 }
 
 
@@ -1476,6 +1533,32 @@ void GuiDocumentDialog::updateParams(BufferParams const & params)
                params.footskip, defaultUnit);
 
        branchesModule->update(params);
+
+       // PDF support
+       PDFOptions const & pdf = params.pdfoptions();
+       pdfSupportModule->use_hyperrefCB->setChecked(pdf.use_hyperref_);
+       pdfSupportModule->titleLE->setText(toqstr(pdf.title_));
+       pdfSupportModule->authorLE->setText(toqstr(pdf.author_));
+       pdfSupportModule->subjectLE->setText(toqstr(pdf.subject_));
+       pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords_));
+
+       pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks_);
+       pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered_);
+       pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen_);
+
+       pdfSupportModule->bookmarksopenlevelLE->setText(
+               toqstr(pdf.bookmarksopenlevel_));
+
+       pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks_);
+       pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder_);
+       pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks_);
+       pdfSupportModule->backrefCB->setChecked(pdf.backref_);
+       pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref_);
+       pdfSupportModule->fullscreenCB->setChecked
+               (pdf.pagemode_ == pdf.pagemode_fullscreen_);
+
+       pdfSupportModule->optionsLE->setText(
+               toqstr(pdf.quoted_options_));
 }
 
 
index bd70aad9db793c06f99f4c96a5f18661c2ff5679..65877152c372bdedbca0797f14ec91769bfebcf9 100644 (file)
@@ -29,6 +29,7 @@
 #include "ui_NumberingUi.h"
 #include "ui_MarginsUi.h"
 #include "ui_PreambleUi.h"
+#include "ui_PDFSupportUi.h"
 
 #include <QDialog>
 #include <QStringList>
@@ -106,6 +107,7 @@ private:
        UiWidget<Ui::BiblioUi> *biblioModule;
        UiWidget<Ui::MathsUi> *mathsModule;
        UiWidget<Ui::LaTeXUi> *latexModule;
+       UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
        PreambleModule *preambleModule;
        
        GuiBranches *branchesModule;
index 6b3d7bc1db8ef961e1e669a76e9b3b2f5a8bcdc2..e073f62467d33bd711b53f35ed440cc37db59a61 100644 (file)
@@ -235,6 +235,7 @@ UIFILES = \
        NumberingUi.ui \
        PageLayoutUi.ui \
        ParagraphUi.ui \
+       PDFSupportUi.ui \
        PreambleUi.ui \
        PrefColorsUi.ui \
        PrefConvertersUi.ui \
index 30e3ba6a237baf80c042c1090490bbc54e685981..09657743d0cf584aa74d3e7ca411fca84b038bae 100644 (file)
@@ -6,6 +6,7 @@ uic BibtexAddUi.ui -o BibtexAddUi.h
 uic BibtexUi.ui -o BibtexUi.h
 uic BoxUi.ui -o BoxUi.h
 uic BranchesUi.ui -o BranchesUi.h
+uic PDFSupportUi.ui -o PDFSupportUi.h
 uic BranchUi.ui -o BranchUi.h
 uic ChangesUi.ui -o ChangesUi.h
 uic CharacterUi.ui -o CharacterUi.h
@@ -48,7 +49,7 @@ uic PrefSpellcheckerUi.ui -o PrefSpellcheckerUi.h
 uic PrefsUi.ui -o PrefsUi.h
 uic PrefUi.ui -o PrefUi.h
 uic PrintUi.ui -o PrintUi.h
-uic reambleUi.ui -o PreambleUi.h
+uic PreambleUi.ui -o PreambleUi.h
 uic RefUi.ui -o RefUi.h
 uic SearchUi.ui -o SearchUi.h
 uic SendtoUi.ui -o SendtoUi.h
@@ -60,7 +61,7 @@ uic TexinfoUi.ui -o TexinfoUi.h
 uic TextLayoutUi.ui -o TextLayoutUi.h
 uic ThesaurusUi.ui -o ThesaurusUi.h
 uic TocUi.ui -o TocUi.h
-uic ulletsUi.ui -o BulletsUi.h
+uic BulletsUi.ui -o BulletsUi.h
 uic URLUi.ui -o URLUi.h
 uic VSpaceUi.ui -o VSpaceUi.h
 uic WrapUi.ui -o WrapUi.h
index 0995a7a0f8a2943658d48ed581dbe2b61d9ba104..e505e4a5086aac8989f7ab4c5ea8adf46d066553 100644 (file)
@@ -23,7 +23,6 @@
 #include "CoordCache.h"
 #include "Cursor.h"
 #include "debug.h"
-#include "debug.h"
 #include "Dimension.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"