1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
18 #pragma implementation
22 #include "ButtonControllerBase.h"
23 #include "ControlRef.h"
28 #include "bufferlist.h"
34 extern BufferList bufferlist;
36 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
37 : ControlCommand(lv, d, LFUN_REF_INSERT)
39 d_.showRef.connect(slot(this, &ControlRef::showInset));
40 d_.createRef.connect(slot(this, &ControlRef::createInset));
44 vector<string> const ControlRef::getLabelList(string const & name) const
46 Buffer * buffer = bufferlist.getBuffer(name);
48 buffer = lv_.buffer();
49 return buffer->getLabelList();
53 void ControlRef::gotoRef(string const & ref) const
55 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0");
56 lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
60 void ControlRef::gotoBookmark() const
62 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
66 vector<string> const ControlRef::getBufferList() const
68 return bufferlist.getFileNames();
72 int ControlRef::getBufferNum() const
74 vector<string> buffers = bufferlist.getFileNames();
75 string const name = lv_.buffer()->fileName();
76 vector<string>::const_iterator cit =
77 find(buffers.begin(), buffers.end(), name);
78 if (cit == buffers.end())
80 return cit - buffers.begin();