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;
|
|
|
|
|
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)
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
: ControlCommand(d, "ref", "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
|