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"
|
2003-12-10 17:28:14 +00:00
|
|
|
|
#include "debug.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"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
#include "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"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
|
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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-09-09 18:52:00 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::ostringstream;
|
2001-07-20 09:57:23 +00:00
|
|
|
|
|
2001-11-27 10:34:16 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
typedef Translator<std::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);
|
2006-06-03 16:46:27 +00:00
|
|
|
|
translator.addPair("Framed", InsetNoteParams::Framed);
|
|
|
|
|
translator.addPair("Shaded", InsetNoteParams::Shaded);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-22 09:23:10 +00:00
|
|
|
|
NoteTranslatorLoc const init_notetranslator_loc()
|
2006-09-09 15:27:44 +00:00
|
|
|
|
{
|
2006-12-22 09:23:10 +00:00
|
|
|
|
NoteTranslatorLoc translator(_("Note"), InsetNoteParams::Note);
|
|
|
|
|
translator.addPair(_("Comment"), InsetNoteParams::Comment);
|
|
|
|
|
translator.addPair(_("Greyed out"), InsetNoteParams::Greyedout);
|
|
|
|
|
translator.addPair(_("Framed"), InsetNoteParams::Framed);
|
|
|
|
|
translator.addPair(_("Shaded"), InsetNoteParams::Shaded);
|
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);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
setLayout(bp);
|
|
|
|
|
setButtonLabel();
|
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_)
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
2007-08-13 12:13:17 +00:00
|
|
|
|
setButtonLabel();
|
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-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetNote::doClone() const
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetNote(*this));
|
2001-07-27 12:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const 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
|
|
|
|
|
{
|
|
|
|
|
return from_ascii(string("Note") + string(":") + string(notetranslator().find(params_.type)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-05-18 20:00:19 +00:00
|
|
|
|
Inset::DisplayType InsetNote::display() const
|
|
|
|
|
{
|
|
|
|
|
switch (params_.type) {
|
|
|
|
|
case InsetNoteParams::Framed:
|
|
|
|
|
case InsetNoteParams::Shaded:
|
|
|
|
|
return AlignLeft;
|
|
|
|
|
default:
|
|
|
|
|
return Inline;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetNote::write(Buffer const & buf, ostream & os) const
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
2003-07-08 14:19:25 +00:00
|
|
|
|
params_.write(os);
|
2001-07-20 09:57:23 +00:00
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetNote::read(Buffer const & buf, Lexer & lex)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
params_.read(lex);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
InsetCollapsable::read(buf, lex);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
setLayout(buf.params());
|
2003-07-08 14:19:25 +00:00
|
|
|
|
setButtonLabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2007-08-18 23:26:07 +00:00
|
|
|
|
// isn't this an identity? - MV
|
2007-08-13 12:13:17 +00:00
|
|
|
|
setLabelFont(layout_.labelfont);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
2003-07-15 23:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
2007-06-12 13:45:49 +00:00
|
|
|
|
Color_color InsetNote::backgroundColor() const
|
|
|
|
|
{
|
|
|
|
|
Color_color c;
|
|
|
|
|
switch (params_.type) {
|
|
|
|
|
case InsetNoteParams::Note:
|
|
|
|
|
c = Color::notebg;
|
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Comment:
|
|
|
|
|
c = Color::commentbg;
|
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Greyedout:
|
|
|
|
|
c = Color::greyedoutbg;
|
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Framed:
|
|
|
|
|
c = Color::greyedoutbg;
|
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Shaded:
|
|
|
|
|
c = Color::shadedbg;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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());
|
2003-07-08 14:19:25 +00:00
|
|
|
|
setButtonLabel();
|
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-08-05 08:07:07 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button3 && hitButton(cmd))
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetNoteMailer(*this).showDialog(&cur.bv());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
else
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
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
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-12 21:43:58 +00:00
|
|
|
|
void InsetNote::updateLabels(Buffer const & buf, ParIterator const & it)
|
|
|
|
|
{
|
|
|
|
|
TextClass const & tclass = buf.params().getTextClass();
|
|
|
|
|
Counters savecnt = tclass.counters();
|
|
|
|
|
InsetCollapsable::updateLabels(buf, it);
|
|
|
|
|
tclass.counters() = savecnt;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetNote::latex(Buffer const & buf, odocstream & os,
|
2006-04-05 23:56:29 +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;
|
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
string type;
|
2006-01-09 21:00:24 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
2003-12-10 17:28:14 +00:00
|
|
|
|
type = "comment";
|
2006-01-09 21:00:24 +00:00
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
} else if (params_.type == InsetNoteParams::Greyedout)
|
2003-12-10 17:28:14 +00:00
|
|
|
|
type = "lyxgreyedout";
|
2006-06-03 16:46:27 +00:00
|
|
|
|
else if (params_.type == InsetNoteParams::Framed)
|
|
|
|
|
type = "framed";
|
|
|
|
|
else if (params_.type == InsetNoteParams::Shaded)
|
|
|
|
|
type = "shaded";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream ss;
|
|
|
|
|
ss << "%\n\\begin{" << from_ascii(type) << "}\n";
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::latex(buf, ss, runparams);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
ss << "\n\\end{" << from_ascii(type) << "}\n";
|
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-08-12 08:57:17 +00:00
|
|
|
|
return int(std::count(str.begin(), str.end(), '\n'));
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-15 22:59:06 +00:00
|
|
|
|
int InsetNote::plaintext(Buffer const & buf, 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);
|
|
|
|
|
}
|
2007-05-01 08:26:40 +00:00
|
|
|
|
os << '[' << buf.B_("note") << ":\n";
|
2007-02-15 22:59:06 +00:00
|
|
|
|
InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-15 22:59:06 +00:00
|
|
|
|
int InsetNote::docbook(Buffer const & buf, 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;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
int const n = InsetText::docbook(buf, os, runparams);
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
2006-06-03 16:46:27 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Shaded) {
|
|
|
|
|
features.require("color");
|
|
|
|
|
features.require("framed");
|
2006-09-09 15:27:44 +00:00
|
|
|
|
}
|
2007-05-20 02:53:19 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Framed)
|
2006-06-03 16:46:27 +00:00
|
|
|
|
features.require("framed");
|
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
|