2001-07-20 09:57:23 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1998 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetnote.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "lyxfont.h"
|
2001-11-26 18:03:23 +00:00
|
|
|
#include "language.h"
|
2001-07-23 09:11:14 +00:00
|
|
|
#include "buffer.h"
|
2001-07-20 09:57:23 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
#include "support/LOstream.h"
|
2001-07-24 10:13:19 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-07-20 09:57:23 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
|
2001-11-27 10:34:16 +00:00
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
void InsetNote::init()
|
2001-07-20 09:57:23 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
font.setColor(LColor::note);
|
|
|
|
setLabelFont(font);
|
2002-02-12 10:01:52 +00:00
|
|
|
setBackgroundColor(LColor::notebg);
|
2001-07-20 09:57:23 +00:00
|
|
|
setLabel(_("note"));
|
|
|
|
setInsetName("Note");
|
|
|
|
}
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
InsetNote::InsetNote(BufferParams const & bp)
|
|
|
|
: InsetCollapsable(bp)
|
2001-07-23 09:11:14 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
2001-07-27 12:03:36 +00:00
|
|
|
InsetNote::InsetNote(InsetNote const & in, bool same_id)
|
|
|
|
: InsetCollapsable(in, same_id)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Inset * InsetNote::clone(Buffer const &, bool same_id) const
|
|
|
|
{
|
|
|
|
return new InsetNote(*const_cast<InsetNote *>(this), same_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-18 15:01:09 +00:00
|
|
|
// This constructor is used for reading old InsetInfo
|
2001-07-23 09:11:14 +00:00
|
|
|
InsetNote::InsetNote(Buffer const * buf, string const & contents,
|
|
|
|
bool collapsed)
|
2002-03-03 20:25:07 +00:00
|
|
|
: InsetCollapsable(buf->params, collapsed)
|
2001-07-23 09:11:14 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
|
|
|
|
Paragraph * par = inset.paragraph();
|
2001-08-18 15:01:09 +00:00
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
|
|
|
|
|
|
|
|
// Since XForms doesn't support RTL, we can assume that old notes
|
|
|
|
// in RTL documents are written in English.
|
|
|
|
if (font.language()->RightToLeft())
|
|
|
|
font.setLanguage(default_language);
|
|
|
|
|
2001-11-28 17:00:55 +00:00
|
|
|
lyx::pos_type pos = 0;
|
2001-08-18 15:01:09 +00:00
|
|
|
buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
|
2001-07-20 09:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const InsetNote::editMessage() const
|
|
|
|
{
|
|
|
|
return _("Opened Note Inset");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNote::write(Buffer const *buf, ostream & os) const
|
|
|
|
{
|
2001-07-20 12:40:38 +00:00
|
|
|
os << getInsetName() << "\n";
|
2001-07-20 09:57:23 +00:00
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
}
|