]> git.lyx.org Git - features.git/commitdiff
Move the biblio::CiteEngine enum into bufferparams.h to minimize
authorAngus Leeming <leeming@lyx.org>
Fri, 14 May 2004 13:13:20 +0000 (13:13 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 14 May 2004 13:13:20 +0000 (13:13 +0000)
dependencies on frontends/controllers/biblio.h.
Small clean up of the existing biblio.h interfaces.

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

13 files changed:
src/ChangeLog
src/bufferparams.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlCitation.h
src/frontends/controllers/biblio.C
src/frontends/controllers/biblio.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QCitation.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormCitation.C
src/insets/insetcite.C
src/insets/insetcite.h

index 0e1e715b8e324a31c645f0b53dd7690820a42b63..717f3e20a776d8f78b0b5463c645f5a66c012c91 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-14  Angus Leeming  <leeming@lyx.org>
+
+       * bufferparams.h: move biblio::CiteEngine enum here to minimize
+       dependencies on src/frontends/controllers/biblio.h. Define a
+       CiteEngine_enum wrapper class to enable the enum to be forward
+       declared.
+
 2004-05-12  Angus Leeming  <leeming@lyx.org>
 
        * buffer.C: up LYX_FORMAT to 234.
index 40e82290ac64b2c0928baeef12947966c0e636e9..89511471141b5fdb87b9843234109a33ca1524c7 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "insets/insetquotes.h"
 
-#include "frontends/controllers/biblio.h"
-
 #include "support/copied_ptr.h"
 #include "support/types.h"
 
@@ -39,6 +37,25 @@ class VSpace;
 struct 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_; }
+};
+
+} // namespace biblio
+
+
 /** Buffer parameters.
  *  This class contains all the parameters for this a buffer uses. Some
  *  work needs to be done on this class to make it nice. Now everything
index e5eedaa63656295eb8dd1d6c8c72391aa0c07773..3544d44e27f4a45a3a53502cffa41da55f3c167d 100644 (file)
@@ -1,3 +1,13 @@
+2004-05-14  Angus Leeming  <leeming@lyx.org>
+
+       * ControlCitation.[Ch]: small changes to use the CiteEngine_enum
+       wrapper class.
+
+       * biblio.[Ch]: move the CiteEngine enum into bufferparams.h to
+       minimize dependencies on this file.
+       (getCitationStyle, getCiteCommand): removed. Functionality moved
+       into the CitationStyle struct.
+
 2004-05-12  Angus Leeming  <leeming@lyx.org>
 
        * biblio.C (getEngine): reduced to the trivial.
index 950478db1d9f4dd9053370372f78b26a1ef6b8ee..2770d992fecb2fee74b5bb98379102973eb0d24e 100644 (file)
@@ -13,6 +13,7 @@
 #include "ControlCitation.h"
 
 #include "buffer.h"
+#include "bufferparams.h"
 
 
 using std::string;
@@ -73,7 +74,7 @@ biblio::InfoMap const & ControlCitation::bibkeysInfo() const
 }
 
 
-biblio::CiteEngine ControlCitation::getEngine() const
+biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
        return biblio::getEngine(kernel().buffer());
 }
index 6d8b9e9bd6ef4073d9d506099237231251c0cb53..260707fb0842f2f132c8cdca023d0ef117cf460d 100644 (file)
@@ -14,7 +14,7 @@
 
 
 #include "ControlCommand.h"
-#include "biblio.h" // biblio::InfoMap
+#include "biblio.h"
 
 /** A controller for Citation dialogs.
  */
@@ -37,7 +37,7 @@ public:
        biblio::InfoMap const & bibkeysInfo() const;
 
        ///
-       biblio::CiteEngine getEngine() const;
+       biblio::CiteEngine_enum getEngine() const;
 
        /// Possible citations based on this key
        std::vector<std::string> const getCiteStrings(std::string const & key) const;
index a6992eb957e80336a702f8a619dce953e5c87acf..8fdc33bd2dbb81638e034b9504ab9b1f4d6edc5b 100644 (file)
@@ -513,21 +513,21 @@ unsigned int const nCiteStylesUCase =
 } // namespace anon
 
 
-CitationStyle const getCitationStyle(string const & command)
+CitationStyle::CitationStyle(string const & command)
+       : style(CITE), full(false), forceUCase(false)
 {
-       if (command.empty()) return CitationStyle();
+       if (command.empty())
+               return;
 
-       CitationStyle cs;
        string cmd = command;
-
        if (cmd[0] == 'C') {
-               cs.forceUCase = true;
+               forceUCase = true;
                cmd[0] = 'c';
        }
 
-       size_t n = cmd.size() - 1;
-       if (cmd[n] == '*') {
-               cs.full = true;
+       string::size_type const n = cmd.size() - 1;
+       if (cmd != "cite" && cmd[n] == '*') {
+               full = true;
                cmd = cmd.substr(0,n);
        }
 
@@ -536,25 +536,23 @@ CitationStyle const getCitationStyle(string const & command)
 
        if (ptr != last) {
                size_t idx = ptr - citeCommands;
-               cs.style = citeStyles[idx];
+               style = citeStyles[idx];
        }
-
-       return cs;
 }
 
 
-string const getCiteCommand(CiteStyle command, bool full, bool forceUCase)
+string const CitationStyle::asLatexStr() const
 {
-       string cite = citeCommands[command];
+       string cite = citeCommands[style];
        if (full) {
                CiteStyle const * last = citeStylesFull + nCiteStylesFull;
-               if (std::find(citeStylesFull, last, command) != last)
+               if (std::find(citeStylesFull, last, style) != last)
                        cite += '*';
        }
 
        if (forceUCase) {
                CiteStyle const * last = citeStylesUCase + nCiteStylesUCase;
-               if (std::find(citeStylesUCase, last, command) != last)
+               if (std::find(citeStylesUCase, last, style) != last)
                        cite[0] = 'C';
        }
 
@@ -562,13 +560,13 @@ string const getCiteCommand(CiteStyle command, bool full, bool forceUCase)
 }
 
 
-CiteEngine getEngine(Buffer const & buffer)
+CiteEngine_enum getEngine(Buffer const & buffer)
 {
        return buffer.params().cite_engine;
 }
 
 
-vector<CiteStyle> const getCiteStyles(CiteEngine engine)
+vector<CiteStyle> const getCiteStyles(CiteEngine_enum const & engine)
 {
        unsigned int nStyles = 0;
        unsigned int start = 0;
index e079c66e01b1a7db0c146eab4d0e383b0e190aa1..602ad6b2fc8a63f5736323fa4a2c4a56034a309d 100644 (file)
@@ -21,14 +21,9 @@ class Buffer;
 /** Functions of use to citation and bibtex GUI controllers and views */
 namespace biblio {
 
-enum CiteEngine {
-       ENGINE_BASIC,
-       ENGINE_NATBIB_AUTHORYEAR,
-       ENGINE_NATBIB_NUMERICAL,
-       ENGINE_JURABIB
-};
+class CiteEngine_enum;
 
-CiteEngine getEngine(Buffer const &);
+CiteEngine_enum getEngine(Buffer const &);
 
 
 enum CiteStyle {
@@ -98,10 +93,15 @@ searchKeys(InfoMap const & map,
           Direction,
           bool caseSensitive=false);
 
-/// Type returned by getCitationStyle, below
+
 struct CitationStyle {
        ///
-       CitationStyle() : style(CITE), full(false), forceUCase(false) {}
+       CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
+               : style(s), full(f), forceUCase(force) {}
+       /// \param latex_str a LaTeX command, "cite", "Citep*", etc
+       CitationStyle(std::string const & latex_str);
+       ///
+       std::string const asLatexStr() const;
        ///
        CiteStyle style;
        ///
@@ -110,20 +110,9 @@ struct CitationStyle {
        bool forceUCase;
 };
 
-/// Given the LaTeX command, return the appropriate CitationStyle
-CitationStyle const getCitationStyle(std::string const & command);
-
-/** Returns the LaTeX citation command
-
-User supplies :
-The CiteStyle enum,
-a flag forcing the full author list,
-a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
-*/
-std::string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
 
 /// Returns a vector of available Citation styles.
-std::vector<CiteStyle> const getCiteStyles(CiteEngine);
+std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
 
 /**
    "Translates" the available Citation Styles into strings for this key.
index e0c7819acb7e5e3d9844700a5f413982254e6e5a..b112b29158f20292c1328d5b093cc3613393bc30 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-14  Angus Leeming  <leeming@lyx.org>
+
+       * QCitation.C: small changes due to the changes in biblio.h.
+
 2004-05-12  Angus Leeming  <leeming@lyx.org>
 
        * QDocument.C (apply, update): get, set data with
index 87e0b569cf7d44fc042c343f2023027500ed087b..0cb80c675eb8b6d23745611c6c6685fbfeaf8ae3 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <config.h>
 
+#include "bufferparams.h"
 #include "debug.h"
 #include "ui/QCitationFindDialogBase.h"
 #include "QCitationDialog.h"
@@ -55,7 +56,8 @@ void QCitation::apply()
        bool const force = dialog_->forceuppercaseCB->isChecked();
 
        string const command =
-               biblio::getCiteCommand(styles[choice], full, force);
+               biblio::CitationStyle(styles[choice], full, force)
+               .asLatexStr();
 
        controller().params().setCmdName(command);
        controller().params().setContents(getStringFromVector(citekeys));
@@ -158,7 +160,7 @@ void QCitation::updateStyle()
        // Find the style of the citekeys
        vector<biblio::CiteStyle> const & styles =
                ControlCitation::getCiteStyles();
-       biblio::CitationStyle cs = biblio::getCitationStyle(command);
+       biblio::CitationStyle const cs(command);
 
        vector<biblio::CiteStyle>::const_iterator cit =
                find(styles.begin(), styles.end(), cs.style);
index f02cb5e4408f198926dbb4e3e53e4ba5e7474feb..df23702bc721441057a412c9fadff0eb80d5d3ca 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-14  Angus Leeming  <leeming@lyx.org>
+
+       * FormCitation.C: small changes due to the changes in biblio.h.
+
 2004-05-12  Angus Leeming  <leeming@lyx.org>
 
        * FormDocument.[Ch], forms/form_document.fd: get, set data with
index 10c855ac75a573682b342a41b02ad284e430ab72..f0dc375f0cebff224232923559623c1e08f5936d 100644 (file)
@@ -19,6 +19,8 @@
 #include "xforms_helpers.h"
 #include "xformsBC.h"
 
+#include "bufferparams.h"
+
 #include "support/lstrings.h"
 
 #include "lyx_forms.h"
@@ -69,7 +71,7 @@ void updateStyle(FD_citation * dialog, string command)
        // Find the style of the citekeys
        vector<biblio::CiteStyle> const & styles =
                ControlCitation::getCiteStyles();
-       biblio::CitationStyle cs = biblio::getCitationStyle(command);
+       biblio::CitationStyle const cs(command);
 
        vector<biblio::CiteStyle>::const_iterator cit =
                find(styles.begin(), styles.end(), cs.style);
@@ -109,7 +111,10 @@ void FormCitation::apply()
                bool const force =
                        fl_get_button(dialog_->check_force_uppercase);
 
-               command = biblio::getCiteCommand(styles[choice], full, force);
+               command =
+                       biblio::CitationStyle(styles[choice], full, force)
+                       .asLatexStr();
+
        }
 
        controller().params().setCmdName(command);
index 5d09732bec9acd39f12978d7bf0a61597c6f6132..203b96b8d1e239fe8bdee2ccae07717b61df3583 100644 (file)
@@ -20,6 +20,8 @@
 #include "funcrequest.h"
 #include "LaTeXFeatures.h"
 
+#include "frontends/controllers/biblio.h"
+
 #include "support/lstrings.h"
 
 using lyx::support::ascii_lowercase;
index 6025d8ecfe390299656f1c9d12913f8d071f5fc1..12b8b1d3bb93140c05cd5b696d82710858ce1132 100644 (file)
@@ -15,7 +15,8 @@
 
 
 #include "insetcommand.h"
-#include "frontends/controllers/biblio.h"
+#include "bufferparams.h"
+
 
 /** Used to insert citations
  */