#include "lyxfunc.h"
#include "commandtags.h"
#include "gettext.h"
+#include "LaTeXFeatures.h"
+
+using std::ostream;
+using std::endl;
extern BufferView * current_view;
: master(bf)
{
scanCommand(cmd);
- if (getCmdName() == "ref")
- flag = InsetRef::REF;
- else
- flag = InsetRef::PAGE_REF;
+ GenerateFlag();
}
setCmdName(inscmd.getCmdName());
setContents(inscmd.getContents());
setOptions(inscmd.getOptions());
+ GenerateFlag();
+}
+
+
+void InsetRef::GenerateFlag()
+{
if (getCmdName() == "ref")
- flag = InsetRef::REF;
+ flag = REF;
+ else if (getCmdName() == "pageref")
+ flag = PAGE_REF;
+ else if (getCmdName() == "vref")
+ flag = VREF;
+ else if (getCmdName() == "vpageref")
+ flag = VPAGE_REF;
+ else if (getCmdName() == "prettyref")
+ flag = PRETTY_REF;
+ else {
+ lyxerr << "ERROR (InsetRef::GenerateFlag): Unknown command name "
+ << getCmdName() << endl;
+ flag = REF;
+ }
+}
+
+
+void InsetRef::Toggle() {
+ static string const cmd_names[REF_LAST+1]
+ = {"ref", "pageref", "vref", "vpageref", "prettyref"};
+
+ if (flag == REF_LAST)
+ flag = REF_FIRST;
else
- flag = InsetRef::PAGE_REF;
+ flag = static_cast<Ref_Flags>(flag + 1);
+ setCmdName(cmd_names[flag]);
}
-void InsetRef::Edit(int, int)
+void InsetRef::Edit(BufferView * bv, int, int, unsigned int)
{
- current_view->owner()->getLyXFunc()
- ->Dispatch(LFUN_REFGOTO, getContents().c_str());
+ bv->owner()->getLyXFunc()->
+ Dispatch(LFUN_REFGOTO, getContents().c_str());
}
string InsetRef::getScreenLabel() const
{
- string temp;
- if (flag == InsetRef::PAGE_REF)
- temp += _("Page: ");
- else
- temp += _("Ref: ");
- temp += getContents();
+ static char const * labels[REF_LAST+1]
+ = { N_("Ref: "), N_("Page: "), N_("TextRef: "), N_("TextPage: "),
+ N_("PrettyRef: ")};
+ string temp = _(labels[flag]) + getContents();
if(!current_view->buffer()->isLatex()
&& !getOptions().empty()) {
temp += "||";
}
-int InsetRef::Latex(ostream & os, signed char /*fragile*/) const
+int InsetRef::Latex(Buffer const *, ostream & os,
+ bool /*fragile*/, bool /*fs*/) const
{
if(getOptions().empty())
os << escape(getCommand());
}
-int InsetRef::Latex(string & file, signed char /*fragile*/) const
+int InsetRef::Ascii(Buffer const *, ostream & os) const
{
- if(getOptions().empty())
- file += escape(getCommand());
- else {
- string ns;
- InsetCommand clone = InsetCommand(getCmdName(),
- getContents(), ns);
- file += escape(clone.getCommand());
- }
+ os << "[" << getContents() << "]";
return 0;
}
-int InsetRef::Linuxdoc(string & file) const
+int InsetRef::Linuxdoc(Buffer const *, ostream & os) const
{
- file += "<ref id=\"" + getContents()
- + "\" name=\""+ getOptions() +"\" >" ;
-
+ os << "<ref id=\"" << getContents()
+ << "\" name=\"" << getOptions() << "\" >";
return 0;
}
-int InsetRef::DocBook(string & file) const
+int InsetRef::DocBook(Buffer const *, ostream & os) const
{
- file += "<link linkend=\"" + getContents()
- + "\">"+ getOptions() +"</link>" ;
-
+ os << "<link linkend=\"" << getContents()
+ << "\">" << getOptions() << "</link>";
return 0;
}
}
return enc;
}
+
+void InsetRef::Validate(LaTeXFeatures & features) const
+{
+ switch (flag) {
+ case VREF:
+ case VPAGE_REF:
+ features.varioref = true;
+ break;
+ case PRETTY_REF:
+ features.prettyref = true;
+ break;
+ case REF:
+ case PAGE_REF:
+ break;
+ }
+}