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
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
InsetNote::InsetNote(BufferParams const & bp, string const & label)
|
2002-03-03 20:25:07 +00:00
|
|
|
|
: InsetCollapsable(bp)
|
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-05-26 09:13:55 +00:00
|
|
|
|
InsetNote::InsetNote(InsetNote const & in)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
: InsetCollapsable(in), params_(in.params_)
|
2007-11-03 00:35:07 +00:00
|
|
|
|
{}
|
2001-07-27 12:03:36 +00:00
|
|
|
|
|
|
|
|
|
|
2003-09-22 07:39:46 +00:00
|
|
|
|
InsetNote::~InsetNote()
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
InsetNoteMailer(*this).hideDialog();
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * InsetNote::clone() const
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
|
return new InsetNote(*this);
|
2001-07-27 12:03:36 +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
|
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
InsetNoteMailer(const_cast<InsetNote &>(*this)).showDialog(bv);
|
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:
|
2006-10-21 00:16:43 +00:00
|
|
|
|
InsetNoteMailer::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:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetNoteMailer(*this).updateDialog(&cur.bv());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
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:
|
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
|
|
|
|
flag.enabled(true);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetNote::updateLabels(ParIterator const & it)
|
2007-08-12 21:43:58 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
TextClass const & tclass = buffer().params().textClass();
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
string const InsetNoteMailer::name_("note");
|
2003-12-10 14:49:51 +00:00
|
|
|
|
|
|
|
|
|
InsetNoteMailer::InsetNoteMailer(InsetNote & inset)
|
|
|
|
|
: inset_(inset)
|
|
|
|
|
{}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-23 09:54:21 +00:00
|
|
|
|
string const InsetNoteMailer::inset2string(Buffer const &) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
return params2string(inset_.params());
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-10 14:49:51 +00:00
|
|
|
|
string const InsetNoteMailer::params2string(InsetNoteParams const & params)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream data;
|
2003-12-10 14:49:51 +00:00
|
|
|
|
data << name_ << ' ';
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNoteMailer::string2params(string const & in,
|
2003-12-10 14:49:51 +00:00
|
|
|
|
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;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
if (!lex || name != name_)
|
|
|
|
|
return print_mailer_error("InsetNoteMailer", in, 1, name_);
|
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;
|
|
|
|
|
if (!lex || id != "Note")
|
|
|
|
|
return print_mailer_error("InsetBoxMailer", in, 2, "Note");
|
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
|