]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetRef.cpp
index 88c76fa5530b5e8a2fe9f48216d884a2f4025a8e..afc123ee7752a6274be211ce65ce56f11af25197 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author José Matos
+ * \author José Matos
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -32,7 +32,7 @@ using namespace std;
 namespace lyx {
 
 
-InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
+InsetRef::InsetRef(Buffer const & buf, InsetCommandParams const & p)
        : InsetCommand(p, "ref"), isLatex(buf.isLatex())
 {}
 
@@ -65,40 +65,9 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
 }
 
 
-void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
-{
-       switch (cmd.action) {
-       case LFUN_MOUSE_RELEASE:
-               // Eventually trigger dialog with button 3 not 1
-               if (cmd.button() == mouse_button::button3)
-                       lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
-                                                 getParam("reference")));
-               else
-                       InsetCommand::doDispatch(cur, cmd);
-               break;
-
-       default:
-               InsetCommand::doDispatch(cur, cmd);
-       }
-}
-
-
 docstring InsetRef::screenLabel() const
 {
-       docstring temp;
-       for (int i = 0; !types[i].latex_name.empty(); ++i) {
-               if (getCmdName() == types[i].latex_name) {
-                       temp = _(types[i].short_gui_name);
-                       break;
-               }
-       }
-       temp += getParam("reference");
-
-       if (!isLatex && !getParam("name").empty()) {
-               temp += "||";
-               temp += getParam("name");
-       }
-       return temp;
+       return screen_label_;
 }
 
 
@@ -146,7 +115,7 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-void InsetRef::textString(odocstream & os) const
+void InsetRef::tocString(odocstream & os) const
 {
        plaintext(os, OutputParams(0));
 }
@@ -155,20 +124,35 @@ void InsetRef::textString(odocstream & os) const
 void InsetRef::updateLabels(ParIterator const & it)
 {
        docstring const & label = getParam("reference");
+       // register this inset into the buffer reference cache.
        buffer().references(label).push_back(make_pair(this, it));
+
+       for (int i = 0; !types[i].latex_name.empty(); ++i) {
+               if (getCmdName() == types[i].latex_name) {
+                       screen_label_ = _(types[i].short_gui_name);
+                       break;
+               }
+       }
+       screen_label_ += getParam("reference");
+
+       if (!isLatex && !getParam("name").empty()) {
+               screen_label_ += "||";
+               screen_label_ += getParam("name");
+       }
 }
 
 
-void InsetRef::addToToc(ParConstIterator const & cpit) const
+void InsetRef::addToToc(DocIterator const & cpit)
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))
                // This InsetRef has already been taken care of in InsetLabel::addToToc().
                return;
 
+       // It seems that this reference does not point to any valid label.
+       screen_label_ = _("BROKEN: ") + screen_label_;
        Toc & toc = buffer().tocBackend().toc("label");
-       docstring const reflabel = _("BROKEN: ") + screenLabel();
-       toc.push_back(TocItem(cpit, 0, reflabel));
+       toc.push_back(TocItem(cpit, 0, screen_label_));
 }