+
+
+bool ControlBibtex::usingBibtopic() const
+{
+ return kernel().buffer().params().use_bibtopic;
+}
+
+
+bool ControlBibtex::bibtotoc() const
+{
+ return prefixIs(lyx::to_utf8(params()["options"]), "bibtotoc");
+}
+
+
+string const ControlBibtex::getStylefile() const
+{
+ // the different bibtex packages have (and need) their
+ // own "plain" stylefiles
+ biblio::CiteEngine const engine =
+ kernel().buffer().params().getEngine();
+ docstring defaultstyle;
+ switch (engine) {
+ case biblio::ENGINE_BASIC:
+ defaultstyle = lyx::from_ascii("plain");
+ break;
+ case biblio::ENGINE_NATBIB_AUTHORYEAR:
+ defaultstyle = lyx::from_ascii("plainnat");
+ break;
+ case biblio::ENGINE_NATBIB_NUMERICAL:
+ defaultstyle = lyx::from_ascii("plainnat");
+ break;
+ case biblio::ENGINE_JURABIB:
+ defaultstyle = lyx::from_ascii("jurabib");
+ break;
+ }
+
+ docstring bst = params()["options"];
+ if (bibtotoc()){
+ // bibstyle exists?
+ if (contains(bst, ',')) {
+ docstring bibtotoc = lyx::from_ascii("bibtotoc");
+ bst = split(bst, bibtotoc, ',');
+ } else
+ bst.erase();
+ }
+
+ // propose default style file for new insets
+ // existing insets might have (legally) no bst files
+ // (if the class already provides a style)
+ if (bst.empty() && params()["bibfiles"].empty())
+ bst = defaultstyle;
+
+ // FIXME UNICODE
+ return lyx::to_utf8(bst);
+}
+
+} // namespace frontend
+} // namespace lyx