2002-09-05 14:10:50 +00:00
|
|
|
/**
|
2007-04-25 18:04:04 +00:00
|
|
|
* \file ControlRef.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-26 13:16:57 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-26 13:16:57 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-26 13:16:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlRef.h"
|
2006-09-29 22:06:28 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferList.h"
|
|
|
|
#include "FuncRequest.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
|
|
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
|
|
|
|
|
2006-10-12 10:50:45 +00:00
|
|
|
using lyx::docstring;
|
|
|
|
|
2007-09-16 10:36:57 +00:00
|
|
|
using std::find;
|
2001-09-13 09:57:06 +00:00
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-04-08 22:31:11 +00:00
|
|
|
using support::makeAbsPath;
|
|
|
|
using support::makeDisplayPath;
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
namespace frontend {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
ControlRef::ControlRef(Dialog & d)
|
2007-09-27 18:24:18 +00:00
|
|
|
: ControlCommand(d, "ref")
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-26 13:16:57 +00:00
|
|
|
|
|
|
|
|
2006-10-12 10:50:45 +00:00
|
|
|
vector<docstring> const ControlRef::getLabelList(string const & name) const
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2006-12-27 10:56:11 +00:00
|
|
|
Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
|
2006-10-12 10:50:45 +00:00
|
|
|
vector<docstring> list;
|
2003-08-28 07:41:31 +00:00
|
|
|
buf.getLabelList(list);
|
2003-06-16 11:49:38 +00:00
|
|
|
return list;
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
void ControlRef::gotoRef(string const & ref)
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
|
|
|
|
dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
void ControlRef::gotoBookmark()
|
2001-03-26 13:16:57 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
|
2001-03-26 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
2001-09-13 09:57:06 +00:00
|
|
|
|
|
|
|
vector<string> const ControlRef::getBufferList() const
|
|
|
|
{
|
2006-10-11 17:24:46 +00:00
|
|
|
vector<string> buffers = theBufferList().getFileNames();
|
2001-09-24 16:55:45 +00:00
|
|
|
for (vector<string>::iterator it = buffers.begin();
|
|
|
|
it != buffers.end(); ++it) {
|
2006-09-11 08:54:10 +00:00
|
|
|
*it = lyx::to_utf8(makeDisplayPath(*it));
|
2001-09-24 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return buffers;
|
2001-09-13 09:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ControlRef::getBufferNum() const
|
|
|
|
{
|
2006-10-11 17:24:46 +00:00
|
|
|
vector<string> buffers = theBufferList().getFileNames();
|
2007-09-10 22:32:59 +00:00
|
|
|
string const name = buffer().fileName();
|
2001-09-13 09:57:06 +00:00
|
|
|
vector<string>::const_iterator cit =
|
|
|
|
find(buffers.begin(), buffers.end(), name);
|
|
|
|
if (cit == buffers.end())
|
|
|
|
return 0;
|
2002-03-26 12:12:29 +00:00
|
|
|
return int(cit - buffers.begin());
|
2001-09-13 09:57:06 +00:00
|
|
|
}
|
2002-02-06 15:12:40 +00:00
|
|
|
|
|
|
|
string const ControlRef::getBufferName(int num) const
|
|
|
|
{
|
2006-10-11 17:24:46 +00:00
|
|
|
return theBufferList().getFileNames()[num];
|
2002-02-06 15:12:40 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|