lyx_mirror/src/frontends/controllers/ControlRef.C
Georg Baum 979fdf7456 Fix strange bibtex problem by converting some more functions to use FileName
instead of std::string

	* src/support/lyxlib.h
	* src/support/getcwd.C
	(getcwd): return a FileName, not a std::string in filesystem encoding

	* src/support/filetools.[Ch]
	(makeAbsPath): return a FileName, not a std::string in undefined encoding

	* src/support/lyxlib.h
	* src/support/tempName.C
	(makeAbsPath): return a FileName, not a std::string in undefined encoding

	* many other files: Adjust to the changes above


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16399 a592a061-630c-0410-9148-cb99ea01b6c8
2006-12-27 10:56:11 +00:00

91 lines
1.8 KiB
C

/**
* \file ControlRef.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlRef.h"
#include "buffer.h"
#include "bufferlist.h"
#include "funcrequest.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
using lyx::docstring;
using std::vector;
using std::string;
namespace lyx {
using support::makeAbsPath;
using support::makeDisplayPath;
namespace frontend {
ControlRef::ControlRef(Dialog & d)
: ControlCommand(d, "ref", "ref")
{}
vector<docstring> const ControlRef::getLabelList(string const & name) const
{
Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
vector<docstring> list;
buf.getLabelList(list);
return list;
}
void ControlRef::gotoRef(string const & ref)
{
kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
kernel().dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
}
void ControlRef::gotoBookmark()
{
kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
}
vector<string> const ControlRef::getBufferList() const
{
vector<string> buffers = theBufferList().getFileNames();
for (vector<string>::iterator it = buffers.begin();
it != buffers.end(); ++it) {
*it = lyx::to_utf8(makeDisplayPath(*it));
}
return buffers;
}
int ControlRef::getBufferNum() const
{
vector<string> buffers = theBufferList().getFileNames();
string const name = kernel().buffer().fileName();
vector<string>::const_iterator cit =
find(buffers.begin(), buffers.end(), name);
if (cit == buffers.end())
return 0;
return int(cit - buffers.begin());
}
string const ControlRef::getBufferName(int num) const
{
return theBufferList().getFileNames()[num];
}
} // namespace frontend
} // namespace lyx