]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbibtex.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetbibtex.C
index f016af125cdb1bb223bf769cbf47506afba7c7f0..80d2cd832c942a129df44fc1f7924fd641b2b839 100644 (file)
@@ -5,12 +5,13 @@
  *
  * \author Alejandro Aguilar Sierra
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "insetbibtex.h"
+#include "metricsinfo.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "debug.h"
@@ -53,6 +54,20 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
        return std::auto_ptr<InsetBase>(new InsetBibtex(*this));
 }
 
+void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetBibtex::draw(PainterInfo & pi, int x, int y) const
+{
+       InsetCommand::draw(pi, x + center_indent_, y);
+}
+
 
 dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
 {
@@ -77,13 +92,13 @@ dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
 
 }
 
-string const InsetBibtex::getScreenLabel(Buffer const *) const
+string const InsetBibtex::getScreenLabel(Buffer const &) const
 {
        return _("BibTeX Generated References");
 }
 
 
-int InsetBibtex::latex(Buffer const * buffer, ostream & os,
+int InsetBibtex::latex(Buffer const & buffer, ostream & os,
                       LatexRunParams const & runparams) const
 {
        // changing the sequence of the commands
@@ -105,8 +120,8 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
        }
 
        if (!runparams.nice
-           && IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) {
-               style = MakeAbsPath(style, buffer->filePath());
+           && IsFileReadable(MakeAbsPath(style, buffer.filePath()) + ".bst")) {
+               style = MakeAbsPath(style, buffer.filePath());
        }
 
        if (!style.empty()) { // we want no \biblio...{}
@@ -119,9 +134,9 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
                // part of its name, because it's than book.
                // For the "official" lyx-layouts it's no problem to support
                // all well
-               if (!contains(buffer->params.getLyXTextClass().name(),
+               if (!contains(buffer.params.getLyXTextClass().name(),
                              "art")) {
-                       if (buffer->params.sides == LyXTextClass::OneSide) {
+                       if (buffer.params.sides == LyXTextClass::OneSide) {
                                // oneside
                                os << "\\clearpage";
                        } else {
@@ -145,8 +160,8 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
        string db_out;
        while (!adb.empty()) {
                if (!runparams.nice &&
-                   IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
-                        adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
+                   IsFileReadable(MakeAbsPath(adb, buffer.filePath())+".bib"))
+                        adb = os::external_path(MakeAbsPath(adb, buffer.filePath()));
                db_out += adb;
                db_out += ',';
                db_in = split(db_in, adb,',');
@@ -183,11 +198,10 @@ vector<string> const InsetBibtex::getFiles(Buffer const & buffer) const
 
 
 // This method returns a comma separated list of Bibtex entries
-void InsetBibtex::fillWithBibKeys(Buffer const * buffer,
+void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
                                  std::vector<std::pair<string, string> > & keys) const
 {
-       Assert(buffer);
-       vector<string> const files = getFiles(*buffer);
+       vector<string> const files = getFiles(buffer);
        for (vector<string>::const_iterator it = files.begin();
             it != files.end(); ++ it) {
                // This is a _very_ simple parser for Bibtex database