+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.
#include "insets/insetquotes.h"
-#include "frontends/controllers/biblio.h"
-
#include "support/copied_ptr.h"
#include "support/types.h"
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
+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.
#include "ControlCitation.h"
#include "buffer.h"
+#include "bufferparams.h"
using std::string;
}
-biblio::CiteEngine ControlCitation::getEngine() const
+biblio::CiteEngine_enum ControlCitation::getEngine() const
{
return biblio::getEngine(kernel().buffer());
}
#include "ControlCommand.h"
-#include "biblio.h" // biblio::InfoMap
+#include "biblio.h"
/** A controller for Citation dialogs.
*/
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;
} // 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);
}
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';
}
}
-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;
/** 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 {
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;
///
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.
+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
#include <config.h>
+#include "bufferparams.h"
#include "debug.h"
#include "ui/QCitationFindDialogBase.h"
#include "QCitationDialog.h"
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));
// 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);
+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
#include "xforms_helpers.h"
#include "xformsBC.h"
+#include "bufferparams.h"
+
#include "support/lstrings.h"
#include "lyx_forms.h"
// 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);
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);
#include "funcrequest.h"
#include "LaTeXFeatures.h"
+#include "frontends/controllers/biblio.h"
+
#include "support/lstrings.h"
using lyx::support::ascii_lowercase;
#include "insetcommand.h"
-#include "frontends/controllers/biblio.h"
+#include "bufferparams.h"
+
/** Used to insert citations
*/