Pavel Sanda's "PDFOptions" patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20389 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-20 22:31:18 +00:00
parent ee7f8d4665
commit 3ff14b8300
9 changed files with 137 additions and 9 deletions

View 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];

View 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 =

View 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 &);

View File

@ -233,6 +233,8 @@ liblyxcore_la_SOURCES = \
ParagraphParameters.h \
ParIterator.cpp \
ParIterator.h \
PDFOptions.cpp \
PDFOptions.h \
Row.cpp \
Row.h \
rowpainter.cpp \

View 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_));
}

View 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;

View File

@ -235,6 +235,7 @@ UIFILES = \
NumberingUi.ui \
PageLayoutUi.ui \
ParagraphUi.ui \
PDFSupportUi.ui \
PreambleUi.ui \
PrefColorsUi.ui \
PrefConvertersUi.ui \

View 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

View 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"