]> git.lyx.org Git - lyx.git/blobdiff - src/PDFOptions.cpp
start dissolving frontends/controllers. 40 steps to go.
[lyx.git] / src / PDFOptions.cpp
index 5c8233f75420227a070b93ae5567a11f4cc763e6..bff976f39d4ff6741093dd538be0e78c90ddd230 100644 (file)
@@ -31,12 +31,23 @@ const string PDFOptions::pagemode_fullscreen("FullScreen");
 
 bool PDFOptions::empty() const
 {
-       return author.empty()
-               && title.empty()
-               && subject.empty()
-               && keywords.empty()
-               && pagemode.empty()
-               && quoted_options.empty();
+       PDFOptions x; //implicit hyperref settings
+
+       return  author == x.author
+               && title == x.title
+               && subject == x.subject
+               && keywords == x.keywords
+               && pagemode == x.pagemode
+               && quoted_options == x.quoted_options
+               && bookmarks == x.bookmarks
+               && bookmarksnumbered == x.bookmarksnumbered
+               && bookmarksopen == x.bookmarksopen
+               && bookmarksopenlevel == x.bookmarksopenlevel
+               && breaklinks == x.breaklinks
+               && pdfborder == x.pdfborder
+               && colorlinks == x.colorlinks
+               && backref == x.backref
+               && pagebackref == x.pagebackref ;
 }
 
 void PDFOptions::writeFile(ostream & os) const
@@ -82,19 +93,20 @@ void PDFOptions::writeLaTeX(odocstringstream &os) const
        string opt;
        
        opt = "\\usepackage[";
-       if (!title.empty())
-               opt += "pdftitle={"   + title + "},\n ";
-       if (!author.empty())
-               opt += "pdfauthor={"  + author + "},\n ";
-       if (!subject.empty())
-               opt += "pdfsubject={" + subject + "},\n ";
-       if (!keywords.empty())
-               opt += "pdfkeywords={" + keywords + "},\n ";
+       // since LyX uses unicode, also set the PDF strings to unicode strings with the
+       // hyperref option "unicode"
+       opt += "unicode=true, ";
+       
+       // try to extract author and title from document when none is
+       // explicitely given
+       if (title.empty() && author.empty())
+               opt += "pdfusetitle,\n ";
+       else
+               opt += "\n ";
        opt += "bookmarks=" + convert<string>(bookmarks) + ',';
        if (bookmarks) {
                opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ',';
                opt += "bookmarksopen=" + convert<string>(bookmarksopen) + ',';
-       
                if (bookmarksopen)
                        opt += "bookmarksopenlevel=" + convert<string>(bookmarksopenlevel) + ',';
        }
@@ -111,12 +123,28 @@ void PDFOptions::writeLaTeX(odocstringstream &os) const
        opt += "colorlinks="     + convert<string>(colorlinks) + ',';
        if (!pagemode.empty())
                opt += "pdfpagemode=" + pagemode + ',';
-       if (!quoted_options.empty()){
-               opt += "\n ";
-               opt += quoted_options_get();
-       }
+       
        opt = support::rtrim(opt,",");
        opt += "]\n {hyperref}\n";
+
+       // load the pdftitle etc. as hypersetup, otherwise you'll get
+       // LaTeX-errors when using non-latin characters
+       string hyperset;
+       if (!title.empty())
+               hyperset += "pdftitle={"   + title + "},";
+       if (!author.empty())
+               hyperset += "\n pdfauthor={"  + author + "},";
+       if (!subject.empty())
+               hyperset += "\n pdfsubject={" + subject + "},";
+       if (!keywords.empty())
+               hyperset += "\n pdfkeywords={" + keywords + "},";
+       if (!quoted_options.empty()){
+               hyperset += "\n ";
+               hyperset += quoted_options_get();
+       }
+       hyperset = support::rtrim(hyperset,",");
+       if (!hyperset.empty())
+               opt += "\\hypersetup{" + hyperset + "}\n ";
        
        // FIXME UNICODE
        os << from_utf8(opt);