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"
29 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
35 extern BufferList bufferlist;
37 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
38 : ControlCommand(lv, d, LFUN_REF_INSERT)
40 d_.showRef.connect(slot(this, &ControlRef::showInset));
41 d_.createRef.connect(slot(this, &ControlRef::createInset));
45 vector<string> const ControlRef::getLabelList(string const & name) const
47 Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name));
49 buffer = lv_.buffer();
50 return buffer->getLabelList();
54 void ControlRef::gotoRef(string const & ref) const
56 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0");
57 lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
61 void ControlRef::gotoBookmark() const
63 lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
67 vector<string> const ControlRef::getBufferList() const
70 vector<string> buffers = bufferlist.getFileNames();
71 for (vector<string>::iterator it = buffers.begin();
72 it != buffers.end(); ++it) {
73 *it = MakeDisplayPath(*it);
80 int ControlRef::getBufferNum() const
82 vector<string> buffers = bufferlist.getFileNames();
83 string const name = lv_.buffer()->fileName();
84 vector<string>::const_iterator cit =
85 find(buffers.begin(), buffers.end(), name);
86 if (cit == buffers.end())
88 return cit - buffers.begin();
91 string const ControlRef::getBufferName(int num) const
93 return bufferlist.getFileNames()[num];