]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
How about if we write a script to do some of this and stop doing it
[lyx.git] / src / insets / InsetRef.cpp
index c2c3358ddd438133ee2458115123a82ca14bd088..7e0eb6db33f8dc78092998e30294916cd70ab800 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.
  */
 #include "InsetRef.h"
 
 #include "Buffer.h"
-#include "buffer_funcs.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "LaTeXFeatures.h"
 #include "LyXFunc.h"
 #include "OutputParams.h"
+#include "output_xhtml.h"
 #include "ParIterator.h"
 #include "sgml.h"
 #include "TocBackend.h"
@@ -33,8 +33,8 @@ using namespace std;
 namespace lyx {
 
 
-InsetRef::InsetRef(Buffer const & buf, InsetCommandParams const & p)
-       : InsetCommand(p, "ref"), isLatex(buf.isLatex())
+InsetRef::InsetRef(Buffer * buf, InsetCommandParams const & p)
+       : InsetCommand(buf, p, "ref"), isLatex(buf->isLatex())
 {}
 
 
@@ -43,14 +43,6 @@ InsetRef::InsetRef(InsetRef const & ir)
 {}
 
 
-void InsetRef::initView()
-{
-       // We need an update of the Buffer reference cache. This is achieved by
-       // updateLabel().
-       lyx::updateLabels(buffer());
-}
-
-
 bool InsetRef::isCompatibleCommand(string const & s) {
        //FIXME This is likely not the best way to handle this.
        //But this stuff is hardcoded elsewhere already.
@@ -74,24 +66,6 @@ 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
 {
        return screen_label_;
@@ -142,13 +116,27 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-void InsetRef::textString(odocstream & os) const
+docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
+{
+       // FIXME What we'd really like to do is to be able to output some
+       // appropriate sort of text here. But to do that, we need to associate
+       // some sort of counter with the label, and we don't have that yet.
+       docstring const ref = html::cleanAttr(getParam("reference"));
+       string const attr = "href=\"#" + to_utf8(ref) + "\"";
+       xs << StartTag("a", attr);
+       xs << ref;
+       xs << EndTag("a");
+       return docstring();
+}
+
+
+void InsetRef::tocString(odocstream & os) const
 {
        plaintext(os, OutputParams(0));
 }
 
 
-void InsetRef::updateLabels(ParIterator const & it)
+void InsetRef::updateLabels(ParIterator const & it, bool)
 {
        docstring const & label = getParam("reference");
        // register this inset into the buffer reference cache.
@@ -160,7 +148,7 @@ void InsetRef::updateLabels(ParIterator const & it)
                        break;
                }
        }
-       screen_label_ += getParam("reference");
+       screen_label_ += label;
 
        if (!isLatex && !getParam("name").empty()) {
                screen_label_ += "||";
@@ -169,7 +157,7 @@ void InsetRef::updateLabels(ParIterator const & it)
 }
 
 
-void InsetRef::addToToc(ParConstIterator const & cpit) const
+void InsetRef::addToToc(DocIterator const & cpit)
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))