]> git.lyx.org Git - lyx.git/commitdiff
* BufferParams:
authorAbdelrazak Younes <younes@lyx.org>
Sun, 25 Mar 2007 01:12:38 +0000 (01:12 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 25 Mar 2007 01:12:38 +0000 (01:12 +0000)
  * transfer CiteEngine enum declaration to biblio.h
  * delete unneeded CiteEngine_enum
  * cite_engine is now cite_engine_ and is private.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17537 a592a061-630c-0410-9148-cb99ea01b6c8

src/LaTeXFeatures.C
src/bufferparams.C
src/bufferparams.h
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/biblio.C
src/frontends/controllers/biblio.h
src/frontends/qt4/QDocumentDialog.C
src/insets/insetcite.C
src/insets/insetcite.h
src/lyxfunc.C

index 16fe59da46e15820686ae7d2a0cdd0361df1eb44..63f74837cd5700e480b0935244dd2de3b768fa9b 100644 (file)
@@ -31,6 +31,7 @@
 #include "support/docstream.h"
 #include "support/filetools.h"
 
+#include "frontends/controllers/biblio.h"
 
 namespace lyx {
 
@@ -378,7 +379,7 @@ string const LaTeXFeatures::getPackages() const
        // natbib.sty
        if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
                packages << "\\usepackage[";
-               if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
+               if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
                        packages << "numbers";
                } else {
                        packages << "authoryear";
index 9711b65adb9857d8448606de53c591d84ec1b06c..f7d659c906528cdfd489d9cffe655d50baae36c9 100644 (file)
@@ -37,6 +37,7 @@
 #include "vspace.h"
 
 #include "frontends/Alert.h"
+#include "frontends/controllers/biblio.h"
 
 #include "support/lyxalgo.h" // for lyx::count
 #include "support/convert.h"
@@ -303,7 +304,7 @@ BufferParams::BufferParams()
        use_geometry = false;
        use_amsmath = package_auto;
        use_esint = package_auto;
-       cite_engine = biblio::ENGINE_BASIC;
+       cite_engine_ = biblio::ENGINE_BASIC;
        use_bibtopic = false;
        trackChanges = false;
        outputChanges = false;
@@ -495,7 +496,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
        } else if (token == "\\cite_engine") {
                string engine;
                lex >> engine;
-               cite_engine = citeenginetranslator().find(engine);
+               cite_engine_ = citeenginetranslator().find(engine);
        } else if (token == "\\use_bibtopic") {
                lex >> use_bibtopic;
        } else if (token == "\\tracking_changes") {
@@ -642,7 +643,7 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\use_geometry " << convert<string>(use_geometry)
           << "\n\\use_amsmath " << use_amsmath
           << "\n\\use_esint " << use_esint
-          << "\n\\cite_engine " << citeenginetranslator().find(cite_engine)
+          << "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
           << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
           << "\n\\paperorientation " << string_orientation[orientation]
           << '\n';
@@ -1483,14 +1484,20 @@ Encoding const & BufferParams::encoding() const
 }
 
 
-biblio::CiteEngine_enum BufferParams::getEngine() const
+biblio::CiteEngine BufferParams::getEngine() const
 {
        // FIXME the class should provide the numerical/
        // authoryear choice
        if (getLyXTextClass().provides(LyXTextClass::natbib)
-           && cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+           && cite_engine_ != biblio::ENGINE_NATBIB_NUMERICAL)
                return biblio::ENGINE_NATBIB_AUTHORYEAR;
-       return cite_engine;
+       return cite_engine_;
+}
+
+
+void BufferParams::setCiteEngine(biblio::CiteEngine const cite_engine)
+{
+       cite_engine_ = cite_engine;
 }
 
 } // namespace lyx
index 444a0c2ed0edf275608adf558cdf9539451418c1..e5b0d2f6c738fd730f21f3073be822db24ea08e6 100644 (file)
@@ -39,23 +39,8 @@ class TexRow;
 class VSpace;
 class Language;
 
-
 namespace biblio {
-
-enum CiteEngine {
-       ENGINE_BASIC,
-       ENGINE_NATBIB_AUTHORYEAR,
-       ENGINE_NATBIB_NUMERICAL,
-       ENGINE_JURABIB
-};
-
-class CiteEngine_enum {
-       CiteEngine val_;
-public:
-       CiteEngine_enum(CiteEngine val) : val_(val) {}
-       operator CiteEngine() const{ return val_; }
-};
-
+enum CiteEngine;
 } // namespace biblio
 
 
@@ -240,8 +225,6 @@ public:
        /// Whether and how to load esint
        Package use_esint;
        ///
-       biblio::CiteEngine cite_engine;
-       ///
        bool use_bibtopic;
        /// revision tracking for this buffer ?
        bool trackChanges;
@@ -278,7 +261,10 @@ public:
        /// path of the current buffer
        std::string filepath;
        /// get the appropriate cite engine (natbib handling)
-       biblio::CiteEngine_enum getEngine() const;
+       biblio::CiteEngine getEngine() const;
+
+       ///
+       void setCiteEngine(biblio::CiteEngine const);
 
 private:
        /** Use the Pimpl idiom to hide those member variables that would otherwise
@@ -291,6 +277,9 @@ private:
                static void destroy(Impl *);
        };
        support::copied_ptr<Impl, MemoryTraits> pimpl_;
+
+       ///
+       biblio::CiteEngine cite_engine_;
 };
 
 } // namespace lyx
index fe6b9414c87aab2850545f73ed1b10472dc7a524..6a069ee1e906c394e82360df8769657f29bea35a 100644 (file)
@@ -133,7 +133,7 @@ string const ControlBibtex::getStylefile() const
 {
        // the different bibtex packages have (and need) their
        // own "plain" stylefiles
-       biblio::CiteEngine_enum const & engine =
+       biblio::CiteEngine const engine =
                kernel().buffer().params().getEngine();
        docstring defaultstyle;
        switch (engine) {
index ae5c978df6882a9600646fa7e6e15da7a388399e..85bc4c8ca65f7ee501c2b751565c186c43dbb771 100644 (file)
@@ -111,7 +111,7 @@ static const docstring TheBibliographyRef(from_ascii("TheBibliographyRef"));
 
 
 string const asValidLatexCommand(string const & input,
-                                CiteEngine_enum const & engine)
+                                CiteEngine const engine)
 {
        string const default_str = default_cite_command(engine);
        if (!is_possible_cite_command(input))
@@ -688,7 +688,7 @@ string const CitationStyle::asLatexStr() const
 }
 
 
-vector<CiteStyle> const getCiteStyles(CiteEngine_enum const & engine)
+vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
 {
        unsigned int nStyles = 0;
        unsigned int start = 0;
index 10a3f6dd866165db5df8c23a67b0703072f6f8c5..4d8fe5f9045cde835a62cd5797794f3cc99af5d1 100644 (file)
@@ -23,7 +23,12 @@ class Buffer;
 namespace lyx {
 namespace biblio {
 
-class CiteEngine_enum;
+enum CiteEngine {
+       ENGINE_BASIC,
+       ENGINE_NATBIB_AUTHORYEAR,
+       ENGINE_NATBIB_NUMERICAL,
+       ENGINE_JURABIB
+};
 
 
 enum CiteStyle {
@@ -55,7 +60,7 @@ enum Direction {
  *  returns an appropriate command, valid for \c engine.
  */
 std::string const asValidLatexCommand(std::string const & input,
-                                     CiteEngine_enum const & engine);
+                                     CiteEngine const engine);
 
 /// First entry is the bibliography key, second the data
 typedef std::map<std::string, docstring> InfoMap;
@@ -121,7 +126,7 @@ public:
 
 
 /// Returns a vector of available Citation styles.
-std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
+std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
 
 /**
    "Translates" the available Citation Styles into strings for this key.
index 90aa6de8600c6c2b775a8ba601c48bb7e1c474cd..63cf65817b6a787811a9ee4b40032f2d868e089c 100644 (file)
@@ -35,6 +35,7 @@
 #include "tex-strings.h" // tex_graphics
 #include "Spacing.h"
 
+#include "frontends/controllers/biblio.h"
 #include "controllers/ControlDocument.h"
 #include "controllers/frnt_lang.h"
 
@@ -642,18 +643,18 @@ void QDocumentDialog::apply(BufferParams & params)
                fromqstr(preambleModule->preambleTE->document()->toPlainText());
 
        // biblio
-       params.cite_engine = biblio::ENGINE_BASIC;
+       params.setCiteEngine(biblio::ENGINE_BASIC);
 
        if (biblioModule->citeNatbibRB->isChecked()) {
                bool const use_numerical_citations =
                        biblioModule->citeStyleCO->currentIndex();
                if (use_numerical_citations)
-                       params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
+                       params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
                else
-                       params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+                       params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
 
        } else if (biblioModule->citeJurabibRB->isChecked())
-               params.cite_engine = biblio::ENGINE_JURABIB;
+               params.setCiteEngine(biblio::ENGINE_JURABIB);
 
        params.use_bibtopic =
                biblioModule->bibtopicCB->isChecked();
@@ -920,17 +921,17 @@ void QDocumentDialog::updateParams(BufferParams const & params)
 
        // biblio
        biblioModule->citeDefaultRB->setChecked(
-               params.cite_engine == biblio::ENGINE_BASIC);
+               params.getEngine() == biblio::ENGINE_BASIC);
 
        biblioModule->citeNatbibRB->setChecked(
-               params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
-               params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
+               params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
+               params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
 
        biblioModule->citeStyleCO->setCurrentIndex(
-               params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
+               params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
 
        biblioModule->citeJurabibRB->setChecked(
-               params.cite_engine == biblio::ENGINE_JURABIB);
+               params.getEngine() == biblio::ENGINE_JURABIB);
 
        biblioModule->bibtopicCB->setChecked(
                params.use_bibtopic);
index 8f579226fc7f5b9cad0aa35c2b688488266f858f..90d83728c7364aa92380545f2a1ba8b639a33840 100644 (file)
@@ -317,7 +317,7 @@ docstring const InsetCitation::generateLabel(Buffer const & buffer) const
        docstring const after  = getParam("after");
 
        docstring label;
-       biblio::CiteEngine const engine = buffer.params().cite_engine;
+       biblio::CiteEngine const engine = buffer.params().getEngine();
        if (engine != biblio::ENGINE_BASIC) {
                // FIXME UNICODE
                label = getNatbibLabel(buffer, getCmdName(), to_utf8(getParam("key")),
@@ -446,7 +446,7 @@ int InsetCitation::latex(Buffer const & buffer, odocstream & os,
 
 void InsetCitation::validate(LaTeXFeatures & features) const
 {
-       switch (features.bufferParams().cite_engine) {
+       switch (features.bufferParams().getEngine()) {
        case biblio::ENGINE_BASIC:
                break;
        case biblio::ENGINE_NATBIB_AUTHORYEAR:
index d07a5bdfbb2ee167eff349e8147b69b85f932d16..36b083fdf2dd040835a9f3731ec20468fd18361f 100644 (file)
@@ -15,7 +15,8 @@
 
 
 #include "insetcommand.h"
-#include "bufferparams.h"
+
+#include "frontends/controllers/biblio.h"
 
 
 namespace lyx {
index ed0553518a76381981af5495d766b59de1bcde01..b8c978cd7fa41fa24be94a19440d116b01fd6277 100644 (file)
@@ -1623,7 +1623,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_BUFFER_PARAMS_APPLY: {
                        BOOST_ASSERT(lyx_view_);
                        biblio::CiteEngine const engine =
-                               lyx_view_->buffer()->params().cite_engine;
+                               lyx_view_->buffer()->params().getEngine();
 
                        istringstream ss(argument);
                        LyXLex lex(0,0);
@@ -1637,7 +1637,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                       << (unknown_tokens == 1 ? "" : "s")
                                       << endl;
                        }
-                       if (engine == lyx_view_->buffer()->params().cite_engine)
+                       if (engine == lyx_view_->buffer()->params().getEngine())
                                break;
 
                        LCursor & cur = view()->cursor();