lyx_mirror/src/frontends/controllers/ControlRef.cpp
Richard Heck 0787ade6c0 This is the first part of a cleanup of how we handle the InsetCommand hierarchy. This part starts to disentangle the type of the inset from the command that a single instance of the inset represents. This involves two sorts of changes:
(i) The file format is changed, so that command insets are represented as:
    \begin_inset CommandInset insetype
    LatexCommand command
    ...
    \end_inset
This involves some lyx2lyx and changes to the readInset() routine in factory.cpp
(ii) The InsetCommand and InsetCommandParams classes also have to be changed, as the command name was used in these classes for various purposes for which the inset type ought really to be used.
Further clean-up to come.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20544 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-27 18:24:18 +00:00

92 lines
1.8 KiB
C++

/**
* \file ControlRef.cpp
* 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::find;
using std::vector;
using std::string;
namespace lyx {
using support::makeAbsPath;
using support::makeDisplayPath;
namespace frontend {
ControlRef::ControlRef(Dialog & d)
: ControlCommand(d, "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)
{
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
}
void ControlRef::gotoBookmark()
{
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 = 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