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"
25 #include "frontends/LyXView.h"
28 #include "bufferlist.h"
29 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
36 extern BufferList bufferlist;
38 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
39 : ControlCommand(lv, d, LFUN_REF_INSERT)
41 d_.showRef.connect(slot(this, &ControlRef::showInset));
42 d_.createRef.connect(slot(this, &ControlRef::createInset));
46 vector<string> const ControlRef::getLabelList(string const & name) const
48 Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
50 buffer = lv_.buffer();
51 return buffer->getLabelList();
55 void ControlRef::gotoRef(string const & ref) const
57 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0");
58 lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
62 void ControlRef::gotoBookmark() const
64 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
68 vector<string> const ControlRef::getBufferList() const
71 vector<string> buffers = bufferlist.getFileNames();
72 for (vector<string>::iterator it = buffers.begin();
73 it != buffers.end(); ++it) {
74 *it = MakeDisplayPath(*it);
81 int ControlRef::getBufferNum() const
83 vector<string> buffers = bufferlist.getFileNames();
84 string const name = lv_.buffer()->fileName();
85 vector<string>::const_iterator cit =
86 find(buffers.begin(), buffers.end(), name);
87 if (cit == buffers.end())
89 return int(cit - buffers.begin());
92 string const ControlRef::getBufferName(int num) const
94 return bufferlist.getFileNames()[num];