2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetNote.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Angus Leeming
|
2003-08-01 15:36:47 +00:00
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-07-20 09:57:23 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetNote.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
|
2007-05-01 08:26:40 +00:00
|
|
|
|
#include "Buffer.h"
|
2007-08-12 21:43:58 +00:00
|
|
|
|
#include "BufferParams.h"
|
2001-07-20 09:57:23 +00:00
|
|
|
|
#include "BufferView.h"
|
2007-08-13 12:13:17 +00:00
|
|
|
|
#include "BufferParams.h"
|
2007-08-12 21:43:58 +00:00
|
|
|
|
#include "Counters.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "DispatchResult.h"
|
|
|
|
|
#include "Exporter.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2005-04-22 08:57:22 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
#include "OutputParams.h"
|
2008-02-11 13:06:01 +00:00
|
|
|
|
#include "ParIterator.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
|
#include "TextClass.h"
|
2008-02-11 13:06:01 +00:00
|
|
|
|
#include "TocBackend.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
|
2008-02-14 07:30:33 +00:00
|
|
|
|
#include "support/debug.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
|
#include "support/docstream.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
|
#include "support/Translator.h"
|
2001-07-20 09:57:23 +00:00
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
|
#include "frontends/Application.h"
|
|
|
|
|
|
2007-08-12 08:57:17 +00:00
|
|
|
|
#include <algorithm>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-09-09 18:52:00 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
typedef Translator<string, InsetNoteParams::Type> NoteTranslator;
|
2006-12-22 09:23:10 +00:00
|
|
|
|
typedef Translator<docstring, InsetNoteParams::Type> NoteTranslatorLoc;
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const init_notetranslator()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
NoteTranslator translator("Note", InsetNoteParams::Note);
|
|
|
|
|
translator.addPair("Comment", InsetNoteParams::Comment);
|
|
|
|
|
translator.addPair("Greyedout", InsetNoteParams::Greyedout);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-22 09:23:10 +00:00
|
|
|
|
NoteTranslatorLoc const init_notetranslator_loc()
|
2006-09-09 15:27:44 +00:00
|
|
|
|
{
|
2007-12-05 18:19:55 +00:00
|
|
|
|
NoteTranslatorLoc translator(_("Note[[InsetNote]]"), InsetNoteParams::Note);
|
2006-12-22 09:23:10 +00:00
|
|
|
|
translator.addPair(_("Comment"), InsetNoteParams::Comment);
|
|
|
|
|
translator.addPair(_("Greyed out"), InsetNoteParams::Greyedout);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const & notetranslator()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
static NoteTranslator translator = init_notetranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-22 09:23:10 +00:00
|
|
|
|
NoteTranslatorLoc const & notetranslator_loc()
|
2006-09-09 15:27:44 +00:00
|
|
|
|
{
|
2006-12-22 09:23:10 +00:00
|
|
|
|
static NoteTranslatorLoc translator = init_notetranslator_loc();
|
2003-12-10 17:28:14 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // anon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetNoteParams::InsetNoteParams()
|
|
|
|
|
: type(Note)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNoteParams::write(ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
string const label = notetranslator().find(type);
|
|
|
|
|
os << "Note " << label << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetNoteParams::read(Lexer & lex)
|
2003-12-10 17:28:14 +00:00
|
|
|
|
{
|
|
|
|
|
string label;
|
|
|
|
|
lex >> label;
|
2007-03-26 13:43:49 +00:00
|
|
|
|
if (lex)
|
2003-12-10 17:28:14 +00:00
|
|
|
|
type = notetranslator().find(label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-05 00:21:05 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// InsetNode
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2008-03-04 22:28:18 +00:00
|
|
|
|
InsetNote::InsetNote(Buffer const & buf, string const & label)
|
|
|
|
|
: InsetCollapsable(buf)
|
2001-07-23 09:11:14 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
params_.type = notetranslator().find(label);
|
2001-07-23 09:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
|
2003-09-22 07:39:46 +00:00
|
|
|
|
InsetNote::~InsetNote()
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2008-03-27 22:26:24 +00:00
|
|
|
|
hideDialogs("note", this);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring InsetNote::editMessage() const
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Note Inset");
|
2001-07-20 09:57:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-13 12:13:17 +00:00
|
|
|
|
docstring InsetNote::name() const
|
|
|
|
|
{
|
2008-02-14 07:30:33 +00:00
|
|
|
|
return from_ascii("Note:" + notetranslator().find(params_.type));
|
2007-08-13 12:13:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-05-18 20:00:19 +00:00
|
|
|
|
Inset::DisplayType InsetNote::display() const
|
|
|
|
|
{
|
2007-12-04 09:25:50 +00:00
|
|
|
|
return Inline;
|
2007-05-18 20:00:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetNote::write(ostream & os) const
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
2003-07-08 14:19:25 +00:00
|
|
|
|
params_.write(os);
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::write(os);
|
2001-07-20 09:57:23 +00:00
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetNote::read(Lexer & lex)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
params_.read(lex);
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::read(lex);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNote::setButtonLabel()
|
|
|
|
|
{
|
2006-12-22 09:23:10 +00:00
|
|
|
|
docstring const label = notetranslator_loc().find(params_.type);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
setLabel(label);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
2003-07-15 23:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InsetNote::showInsetDialog(BufferView * bv) const
|
|
|
|
|
{
|
2008-03-27 22:26:24 +00:00
|
|
|
|
bv->showDialog("note", params2string(params()),
|
|
|
|
|
const_cast<InsetNote *>(this));
|
2003-07-15 23:52:05 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
case LFUN_INSET_MODIFY:
|
2008-03-27 22:26:24 +00:00
|
|
|
|
string2params(to_utf8(cmd.argument()), params_);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
// get a bp from cur:
|
|
|
|
|
setLayout(cur.buffer().params());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
2008-03-27 22:26:24 +00:00
|
|
|
|
cur.bv().updateDialog("note", params2string(params()));
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
default:
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2005-04-22 08:57:22 +00:00
|
|
|
|
FuncStatus & flag) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_MODIFY:
|
2008-03-24 13:33:48 +00:00
|
|
|
|
// disallow comment and greyed out in commands
|
|
|
|
|
flag.enabled(!cur.paragraph().layout().isCommand() ||
|
|
|
|
|
cmd.getArg(2) == "Note");
|
|
|
|
|
if (cmd.getArg(0) == "note") {
|
|
|
|
|
InsetNoteParams params;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
string2params(to_utf8(cmd.argument()), params);
|
2008-03-24 13:33:48 +00:00
|
|
|
|
flag.setOnOff(params_.type == params.type);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
|
|
|
|
flag.enabled(true);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-24 13:33:48 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetNote::updateLabels(ParIterator const & it)
|
2007-08-12 21:43:58 +00:00
|
|
|
|
{
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const & tclass = buffer().params().documentClass();
|
2007-08-12 21:43:58 +00:00
|
|
|
|
Counters savecnt = tclass.counters();
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::updateLabels(it);
|
2007-08-12 21:43:58 +00:00
|
|
|
|
tclass.counters() = savecnt;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetNote::addToToc(ParConstIterator const & cpit) const
|
2008-02-11 13:06:01 +00:00
|
|
|
|
{
|
2008-02-15 08:39:58 +00:00
|
|
|
|
ParConstIterator pit = cpit;
|
|
|
|
|
pit.push_back(*this);
|
2008-02-11 13:06:01 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
Toc & toc = buffer().tocBackend().toc("note");
|
2008-02-14 15:29:22 +00:00
|
|
|
|
docstring str;
|
|
|
|
|
str = notetranslator_loc().find(params_.type) + from_ascii(": ")
|
|
|
|
|
+ getNewLabel(str);
|
2008-02-11 13:06:01 +00:00
|
|
|
|
toc.push_back(TocItem(pit, 0, str));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
bool InsetNote::isMacroScope() const
|
2007-12-21 20:42:46 +00:00
|
|
|
|
{
|
|
|
|
|
// LyX note has no latex output
|
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return true;
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
return InsetCollapsable::isMacroScope();
|
2007-12-21 20:42:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetNote::latex(odocstream & os, OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
2007-08-20 04:58:29 +00:00
|
|
|
|
}
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream ss;
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::latex(ss, runparams);
|
2006-08-15 15:12:26 +00:00
|
|
|
|
// the space after the comment in 'a[comment] b' will be eaten by the
|
|
|
|
|
// comment environment since the space before b is ignored with the
|
|
|
|
|
// following latex output:
|
|
|
|
|
//
|
|
|
|
|
// a%
|
|
|
|
|
// \begin{comment}
|
|
|
|
|
// comment
|
|
|
|
|
// \end{comment}
|
|
|
|
|
// b
|
|
|
|
|
//
|
|
|
|
|
// Adding {} before ' b' fixes this.
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
|
|
|
|
ss << "{}";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
docstring const str = ss.str();
|
2003-12-10 17:28:14 +00:00
|
|
|
|
os << str;
|
2007-03-18 10:59:16 +00:00
|
|
|
|
runparams_in.encoding = runparams.encoding;
|
2003-12-10 17:28:14 +00:00
|
|
|
|
// Return how many newlines we issued.
|
2007-12-12 19:28:07 +00:00
|
|
|
|
return int(count(str.begin(), str.end(), '\n'));
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetNote::plaintext(odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
2003-07-27 13:02:26 +00:00
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
}
|
2008-02-27 20:43:16 +00:00
|
|
|
|
os << '[' << buffer().B_("note") << ":\n";
|
|
|
|
|
InsetText::plaintext(os, runparams);
|
2007-02-15 22:59:06 +00:00
|
|
|
|
os << "\n]";
|
2003-07-27 13:02:26 +00:00
|
|
|
|
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetNote::docbook(odocstream & os, OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
2007-02-15 22:59:06 +00:00
|
|
|
|
os << "<remark>\n";
|
2006-01-09 21:00:24 +00:00
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
}
|
2007-02-15 22:59:06 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int const n = InsetText::docbook(os, runparams);
|
2007-02-15 22:59:06 +00:00
|
|
|
|
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
|
|
|
|
os << "\n</remark>\n";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
// Return how many newlines we issued.
|
2007-02-15 22:59:06 +00:00
|
|
|
|
//return int(count(str.begin(), str.end(), '\n'));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
return n + 1 + 2;
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNote::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
features.require("verbatim");
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Greyedout) {
|
2003-07-08 14:19:25 +00:00
|
|
|
|
features.require("color");
|
2003-07-29 12:20:04 +00:00
|
|
|
|
features.require("lyxgreyedout");
|
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::validate(features);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-24 13:33:48 +00:00
|
|
|
|
docstring InsetNote::contextMenu(BufferView const &, int, int) const
|
|
|
|
|
{
|
|
|
|
|
return from_ascii("context-note");
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
|
string InsetNote::params2string(InsetNoteParams const & params)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream data;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data << "note" << ' ';
|
2003-07-08 14:19:25 +00:00
|
|
|
|
params.write(data);
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return data.str();
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
|
void InsetNote::string2params(string const & in, InsetNoteParams & params)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
params = InsetNoteParams();
|
|
|
|
|
|
|
|
|
|
if (in.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream data(in);
|
2007-04-26 11:30:54 +00:00
|
|
|
|
Lexer lex(0,0);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
lex.setStream(data);
|
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
string name;
|
|
|
|
|
lex >> name;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
if (!lex || name != "note") {
|
|
|
|
|
LYXERR0("Expected arg 1 to be \"note\" in " << in);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
// This is part of the inset proper that is usually swallowed
|
2007-04-29 23:33:02 +00:00
|
|
|
|
// by Text::readInset
|
2003-12-11 15:23:15 +00:00
|
|
|
|
string id;
|
|
|
|
|
lex >> id;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
if (!lex || id != "Note") {
|
|
|
|
|
LYXERR0("Expected arg 1 to be \"Note\" in " << in);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
params.read(lex);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|