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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmü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"
|
2012-12-02 09:41:49 +00:00
|
|
|
#include "ColorSet.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"
|
2008-06-18 18:16:50 +00:00
|
|
|
#include "InsetIterator.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2010-02-13 16:22:39 +00:00
|
|
|
#include "LyXRC.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#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"
|
2008-06-18 18:16:50 +00:00
|
|
|
#include "support/gettext.h"
|
2015-11-26 20:21:21 +00:00
|
|
|
#include "support/lstrings.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;
|
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-09-09 15:27:44 +00:00
|
|
|
NoteTranslator const & notetranslator()
|
|
|
|
{
|
2013-10-07 22:59:05 +00:00
|
|
|
static NoteTranslator const translator = init_notetranslator();
|
2003-12-10 17:28:14 +00:00
|
|
|
return translator;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-01-19 23:59:57 +00:00
|
|
|
// InsetNote
|
2008-03-05 00:21:05 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetNote::InsetNote(Buffer * buf, string const & label)
|
2017-10-16 08:12:21 +00:00
|
|
|
: InsetCollapsible(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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-28 22:33:04 +00:00
|
|
|
docstring InsetNote::layoutName() const
|
2007-08-13 12:13:17 +00:00
|
|
|
{
|
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);
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::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);
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::read(lex);
|
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
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2003-08-05 08:07:07 +00:00
|
|
|
|
2014-11-13 01:31:38 +00:00
|
|
|
case LFUN_INSET_MODIFY: {
|
|
|
|
// Do not do anything if converting to the same type of Note.
|
|
|
|
// A quick break here is done instead of disabling the LFUN
|
|
|
|
// because disabling the LFUN would lead to a greyed out
|
|
|
|
// entry, which might confuse users.
|
|
|
|
// In the future, we might want to have a radio button for
|
|
|
|
// switching between notes.
|
|
|
|
InsetNoteParams params;
|
|
|
|
string2params(to_utf8(cmd.argument()), params);
|
|
|
|
if (params_.type == params.type)
|
|
|
|
break;
|
|
|
|
|
2015-03-12 14:57:29 +00:00
|
|
|
cur.recordUndoInset(this);
|
2008-03-27 22:26:24 +00:00
|
|
|
string2params(to_utf8(cmd.argument()), params_);
|
2009-08-25 00:04:47 +00:00
|
|
|
setButtonLabel();
|
2010-07-09 14:37:00 +00:00
|
|
|
// what we really want here is a TOC update, but that means
|
|
|
|
// a full buffer update
|
|
|
|
cur.forceBufferUpdate();
|
2004-02-16 11:58:51 +00:00
|
|
|
break;
|
2014-11-13 01:31:38 +00:00
|
|
|
}
|
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:
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::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
|
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2005-04-22 08:57:22 +00:00
|
|
|
|
|
|
|
case LFUN_INSET_MODIFY:
|
2008-03-24 13:33:48 +00:00
|
|
|
// disallow comment and greyed out in commands
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(!cur.paragraph().layout().isCommand() ||
|
2008-03-24 13:33:48 +00:00
|
|
|
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:
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(true);
|
2005-04-22 08:57:22 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::getStatus(cur, cmd, flag);
|
2005-04-22 08:57:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-24 13:33:48 +00:00
|
|
|
|
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;
|
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::isMacroScope();
|
2007-12-21 20:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-10 20:02:48 +00:00
|
|
|
void InsetNote::latex(otexstream & 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)
|
2011-02-10 20:02:48 +00:00
|
|
|
return;
|
2003-12-10 17:28:14 +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);
|
2017-07-03 17:53:14 +00:00
|
|
|
}
|
2003-12-10 17:28:14 +00:00
|
|
|
|
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.
|
2011-02-10 20:02:48 +00:00
|
|
|
// The {} will be automatically added, but only if needed, for all
|
|
|
|
// insets whose InsetLayout Display tag is false. This is achieved
|
|
|
|
// by telling otexstream to protect an immediately following space
|
|
|
|
// and is done for both comment and greyedout insets.
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::latex(os, runparams);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
2007-03-18 10:59:16 +00:00
|
|
|
runparams_in.encoding = runparams.encoding;
|
2003-07-08 14:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetNote::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const & runparams_in, size_t max_length) 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";
|
2013-03-08 19:52:18 +00:00
|
|
|
InsetText::plaintext(os, runparams, max_length);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-25 21:58:18 +00:00
|
|
|
docstring InsetNote::xhtml(XHTMLStream & xs, OutputParams const & rp) const
|
2009-06-05 19:58:23 +00:00
|
|
|
{
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-05 19:58:23 +00:00
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::xhtml(xs, rp);
|
2009-06-05 19:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
void InsetNote::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
2008-12-12 15:38:52 +00:00
|
|
|
switch (params_.type) {
|
|
|
|
case InsetNoteParams::Comment:
|
2011-12-06 20:44:37 +00:00
|
|
|
if (features.runparams().flavor == OutputParams::HTML)
|
|
|
|
// we do output this but set display to "none" by default,
|
|
|
|
// but people might want to use it.
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::validate(features);
|
2016-09-21 14:11:53 +00:00
|
|
|
else
|
|
|
|
// Only do the requires
|
|
|
|
features.useInsetLayout(getLayout());
|
2008-12-12 15:38:52 +00:00
|
|
|
break;
|
|
|
|
case InsetNoteParams::Greyedout:
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::validate(features);
|
2008-12-12 15:38:52 +00:00
|
|
|
break;
|
|
|
|
case InsetNoteParams::Note:
|
|
|
|
break;
|
2003-07-29 12:20:04 +00:00
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-29 14:48:55 +00:00
|
|
|
string InsetNote::contextMenuName() const
|
2008-03-24 13:33:48 +00:00
|
|
|
{
|
2011-10-29 14:48:55 +00:00
|
|
|
return "context-note";
|
2008-03-24 13:33:48 +00:00
|
|
|
}
|
|
|
|
|
2010-02-13 16:22:39 +00:00
|
|
|
bool InsetNote::allowSpellCheck() const
|
|
|
|
{
|
|
|
|
return (params_.type == InsetNoteParams::Greyedout || lyxrc.spellcheck_notes);
|
|
|
|
}
|
|
|
|
|
2012-12-02 09:41:49 +00:00
|
|
|
FontInfo InsetNote::getFont() const
|
|
|
|
{
|
|
|
|
FontInfo font = getLayout().font();
|
|
|
|
// FIXME: This hardcoded color is a hack!
|
|
|
|
if (params_.type == InsetNoteParams::Greyedout
|
|
|
|
&& buffer().params().notefontcolor != lyx::rgbFromHexName("#cccccc")) {
|
|
|
|
ColorCode c = lcolor.getFromLyXName("notefontcolor");
|
|
|
|
if (c != Color_none)
|
|
|
|
font.setColor(c);
|
|
|
|
}
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
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);
|
2008-04-02 23:06:22 +00:00
|
|
|
Lexer lex;
|
2003-07-08 14:19:25 +00:00
|
|
|
lex.setStream(data);
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.setContext("InsetNote::string2params");
|
2009-02-19 04:18:31 +00:00
|
|
|
lex >> "note";
|
|
|
|
// There are cases, such as when we are called via getStatus() from
|
|
|
|
// Dialog::canApply(), where we are just called with "note" rather
|
|
|
|
// than a full "note Note TYPE".
|
|
|
|
if (!lex.isOK())
|
|
|
|
return;
|
|
|
|
lex >> "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
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|