2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insettext.C
|
|
|
|
|
* 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 J<EFBFBD>rgen Vigna
|
2000-02-25 12:06:15 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-02-25 12:06:15 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insettext.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "insetnewline.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#include "BufferView.h"
|
2006-10-19 19:26:43 +00:00
|
|
|
|
#include "coordcache.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2003-11-06 11:56:10 +00:00
|
|
|
|
#include "cursor.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "errorlist.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "funcrequest.h"
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "intl.h"
|
2003-09-16 10:30:59 +00:00
|
|
|
|
#include "LColor.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "lyxfind.h"
|
|
|
|
|
#include "lyxlex.h"
|
2000-06-16 15:13:25 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-11-10 09:06:48 +00:00
|
|
|
|
#include "lyxtext.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "output_docbook.h"
|
|
|
|
|
#include "output_latex.h"
|
|
|
|
|
#include "output_plaintext.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "rowpainter.h"
|
2003-11-20 10:38:12 +00:00
|
|
|
|
#include "lyxrow.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "sgml.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "texrow.h"
|
2003-10-14 13:01:49 +00:00
|
|
|
|
#include "undo.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
|
|
2001-12-18 03:21:10 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-12-18 03:21:10 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
#include "support/lyxalgo.h" // count
|
2001-12-18 03:21:10 +00:00
|
|
|
|
|
2002-08-14 18:38:59 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
2005-02-20 22:46:22 +00:00
|
|
|
|
#include <boost/current_function.hpp>
|
2002-08-14 18:38:59 +00:00
|
|
|
|
|
2006-09-10 10:53:23 +00:00
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using graphics::PreviewLoader;
|
|
|
|
|
|
|
|
|
|
using support::isStrUnsignedInt;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
using boost::bind;
|
|
|
|
|
using boost::ref;
|
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
using std::endl;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::for_each;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::max;
|
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 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::vector;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2003-08-01 12:52:59 +00:00
|
|
|
|
|
2005-02-15 19:53:42 +00:00
|
|
|
|
int InsetText::border_ = 2;
|
|
|
|
|
|
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetText::InsetText(BufferParams const & bp)
|
2004-12-17 16:27:12 +00:00
|
|
|
|
: drawFrame_(false), frame_color_(LColor::insetframe), text_(0)
|
2003-12-01 13:35:49 +00:00
|
|
|
|
{
|
|
|
|
|
paragraphs().push_back(Paragraph());
|
2004-03-18 12:53:43 +00:00
|
|
|
|
paragraphs().back().layout(bp.getLyXTextClass().defaultLayout());
|
2006-02-05 13:20:16 +00:00
|
|
|
|
// Dispose of the infamous L-shaped cursor.
|
|
|
|
|
text_.current_font.setLanguage(bp.language);
|
|
|
|
|
text_.real_current_font.setLanguage(bp.language);
|
2003-10-08 14:29:16 +00:00
|
|
|
|
init();
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetText::InsetText(InsetText const & in)
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
: InsetOld(in), text_()
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2004-12-17 16:27:12 +00:00
|
|
|
|
text_.autoBreakRows_ = in.text_.autoBreakRows_;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
drawFrame_ = in.drawFrame_;
|
|
|
|
|
frame_color_ = in.frame_color_;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
text_.paragraphs() = in.text_.paragraphs();
|
2006-04-05 23:56:29 +00:00
|
|
|
|
// Hand current buffer language down to "cloned" textinsets
|
2006-02-05 13:20:16 +00:00
|
|
|
|
// e.g. tabular cells
|
|
|
|
|
text_.current_font = in.text_.current_font;
|
|
|
|
|
text_.real_current_font = in.text_.real_current_font;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
init();
|
2000-06-12 11:27:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
2005-02-15 19:53:42 +00:00
|
|
|
|
InsetText::InsetText()
|
|
|
|
|
: text_(0)
|
2004-11-23 23:04:52 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-10-08 14:29:16 +00:00
|
|
|
|
void InsetText::init()
|
2000-03-28 16:18:02 +00:00
|
|
|
|
{
|
2004-11-23 23:04:52 +00:00
|
|
|
|
for_each(paragraphs().begin(), paragraphs().end(),
|
|
|
|
|
bind(&Paragraph::setInsetOwner, _1, this));
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-09-07 10:37:05 +00:00
|
|
|
|
void InsetText::clear()
|
2000-07-14 14:57:20 +00:00
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
ParagraphList & pars = paragraphs();
|
2003-03-03 23:19:01 +00:00
|
|
|
|
|
2002-03-04 16:10:47 +00:00
|
|
|
|
// This is a gross hack...
|
2003-12-01 13:35:49 +00:00
|
|
|
|
LyXLayout_ptr old_layout = pars.begin()->layout();
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
pars.clear();
|
|
|
|
|
pars.push_back(Paragraph());
|
|
|
|
|
pars.begin()->setInsetOwner(this);
|
|
|
|
|
pars.begin()->layout(old_layout);
|
2000-07-14 14:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetText::doClone() const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetText(*this));
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetText::write(Buffer const & buf, ostream & os) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "Text\n";
|
2003-12-02 12:39:14 +00:00
|
|
|
|
text_.write(buf, os);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetText::read(Buffer const & buf, LyXLex & lex)
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2005-09-07 10:37:05 +00:00
|
|
|
|
clear();
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-03-12 05:46:35 +00:00
|
|
|
|
// delete the initial paragraph
|
2003-12-01 13:35:49 +00:00
|
|
|
|
Paragraph oldpar = *paragraphs().begin();
|
|
|
|
|
paragraphs().clear();
|
2006-08-13 16:16:43 +00:00
|
|
|
|
ErrorList errorList;
|
|
|
|
|
bool res = text_.read(buf, lex, errorList);
|
2003-12-03 15:27:16 +00:00
|
|
|
|
init();
|
2003-03-12 05:46:35 +00:00
|
|
|
|
|
2003-12-03 15:27:16 +00:00
|
|
|
|
if (!res) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
lex.printError("Missing \\end_inset at this point. "
|
|
|
|
|
"Read: `$$Token'");
|
|
|
|
|
}
|
2003-10-02 12:01:24 +00:00
|
|
|
|
|
|
|
|
|
// sanity check
|
2004-11-30 01:59:49 +00:00
|
|
|
|
// ensure we have at least one paragraph.
|
2003-12-01 13:35:49 +00:00
|
|
|
|
if (paragraphs().empty())
|
|
|
|
|
paragraphs().push_back(oldpar);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
|
2005-02-15 19:53:42 +00:00
|
|
|
|
mi.base.textwidth -= 2 * border_;
|
2003-12-03 18:17:20 +00:00
|
|
|
|
font_ = mi.base.font;
|
2006-02-05 13:20:16 +00:00
|
|
|
|
// Hand font through to contained lyxtext:
|
2003-12-03 18:17:20 +00:00
|
|
|
|
text_.font_ = mi.base.font;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
text_.metrics(mi, dim);
|
2005-02-15 19:53:42 +00:00
|
|
|
|
dim.asc += border_;
|
|
|
|
|
dim.des += border_;
|
|
|
|
|
dim.wid += 2 * border_;
|
|
|
|
|
mi.base.textwidth += 2 * border_;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
dim_ = dim;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-19 16:46:47 +00:00
|
|
|
|
void InsetText::draw(PainterInfo & pi, int x, int y) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2004-11-30 01:59:49 +00:00
|
|
|
|
BOOST_ASSERT(!text_.paragraphs().front().rows().empty());
|
2003-11-25 11:17:27 +00:00
|
|
|
|
// update our idea of where we are
|
2004-01-30 11:41:12 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
2001-08-02 14:55:06 +00:00
|
|
|
|
|
2006-03-10 16:10:35 +00:00
|
|
|
|
text_.background_color_ = backgroundColor();
|
2005-02-15 19:53:42 +00:00
|
|
|
|
text_.draw(pi, x + border_, y);
|
2001-06-14 14:10:25 +00:00
|
|
|
|
|
2005-07-17 01:13:36 +00:00
|
|
|
|
if (drawFrame_) {
|
|
|
|
|
int const w = text_.width() + 2 * border_;
|
|
|
|
|
int const a = text_.ascent() + border_;
|
|
|
|
|
int const h = a + text_.descent() + border_;
|
2006-11-07 15:24:34 +00:00
|
|
|
|
pi.pain.rectangle(x, y - a, (wide() ? text_.maxwidth_ : w), h,
|
2006-06-20 12:39:39 +00:00
|
|
|
|
frameColor());
|
2005-07-17 01:13:36 +00:00
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-06 11:12:49 +00:00
|
|
|
|
void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
2006-03-10 16:10:35 +00:00
|
|
|
|
int const w = text_.width() + 2 * border_;
|
|
|
|
|
int const a = text_.ascent() + border_;
|
|
|
|
|
int const h = a + text_.descent() + border_;
|
2006-11-07 15:24:34 +00:00
|
|
|
|
pi.pain.fillRectangle(x, y - a, (wide() ? text_.maxwidth_ : w), h,
|
2006-06-20 12:39:39 +00:00
|
|
|
|
backgroundColor());
|
2004-02-06 11:12:49 +00:00
|
|
|
|
text_.drawSelection(pi, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
bool InsetText::covers(BufferView const & bv, int x, int y) const
|
2006-10-19 19:26:43 +00:00
|
|
|
|
{
|
|
|
|
|
return bv.coordCache().getInsets().has(this)
|
|
|
|
|
&& x >= xo(bv)
|
2006-11-07 15:24:34 +00:00
|
|
|
|
&& x <= xo(bv) + width() + (wide() ? text_.maxwidth_ : 0)
|
2006-10-19 19:26:43 +00:00
|
|
|
|
&& y >= yo(bv) - ascent()
|
|
|
|
|
&& y <= yo(bv) + descent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const InsetText::editMessage() const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Text Inset");
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void InsetText::edit(LCursor & cur, bool left)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
//lyxerr << "InsetText: edit left/right" << endl;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
int const pit = left ? 0 : paragraphs().size() - 1;
|
2003-12-15 15:33:15 +00:00
|
|
|
|
int const pos = left ? 0 : paragraphs().back().size();
|
2004-11-30 01:59:49 +00:00
|
|
|
|
text_.setCursor(cur.top(), pit, pos);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2003-12-15 15:33:15 +00:00
|
|
|
|
finishUndo();
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
2003-05-16 07:44:00 +00:00
|
|
|
|
|
|
|
|
|
|
2005-07-15 00:39:44 +00:00
|
|
|
|
InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
|
2003-11-04 12:36:59 +00:00
|
|
|
|
{
|
2004-02-13 13:51:12 +00:00
|
|
|
|
return text_.editXY(cur, x, y);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:58:42 +00:00
|
|
|
|
void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
|
2003-11-04 12:36:59 +00:00
|
|
|
|
{
|
2006-10-21 10:56:36 +00:00
|
|
|
|
lyxerr[Debug::ACTION] << BOOST_CURRENT_FUNCTION
|
2006-08-08 13:34:02 +00:00
|
|
|
|
<< " [ cmd.action = "
|
|
|
|
|
<< cmd.action << ']' << endl;
|
2006-09-08 14:08:26 +00:00
|
|
|
|
text_.dispatch(cur, cmd);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
bool InsetText::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|
|
|
|
FuncStatus & status) const
|
|
|
|
|
{
|
2006-09-08 14:08:26 +00:00
|
|
|
|
return text_.getStatus(cur, cmd, status);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 09:29:19 +00:00
|
|
|
|
void InsetText::setChange(Change const & change)
|
|
|
|
|
{
|
|
|
|
|
ParagraphList::iterator pit = paragraphs().begin();
|
|
|
|
|
ParagraphList::iterator end = paragraphs().end();
|
|
|
|
|
for (; pit != end; ++pit) {
|
|
|
|
|
pit->setChange(change);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-24 06:11:45 +00:00
|
|
|
|
void InsetText::acceptChanges()
|
|
|
|
|
{
|
|
|
|
|
ParagraphList::iterator pit = paragraphs().begin();
|
|
|
|
|
ParagraphList::iterator end = paragraphs().end();
|
|
|
|
|
for (; pit != end; ++pit) {
|
|
|
|
|
// FIXME: change tracking (MG)
|
|
|
|
|
// we must handle end-of-par chars!
|
|
|
|
|
pit->acceptChanges(0, pit->size() + 1);
|
2006-10-24 21:38:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetText::rejectChanges()
|
|
|
|
|
{
|
|
|
|
|
ParagraphList::iterator pit = paragraphs().begin();
|
|
|
|
|
ParagraphList::iterator end = paragraphs().end();
|
|
|
|
|
for (; pit != end; ++pit) {
|
|
|
|
|
// FIXME: change tracking (MG)
|
|
|
|
|
// we must handle end-of-par chars!
|
|
|
|
|
pit->rejectChanges(0, pit->size() + 1);
|
2006-10-24 06:11:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetText::latex(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
TexRow texrow;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
latexParagraphs(buf, paragraphs(), os, texrow, runparams);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return texrow.rows();
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetText::plaintext(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-09-26 15:25:14 +00:00
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
ParagraphList::const_iterator beg = paragraphs().begin();
|
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2003-05-27 22:41:04 +00:00
|
|
|
|
ParagraphList::const_iterator it = beg;
|
2005-07-15 19:10:25 +00:00
|
|
|
|
bool ref_printed = false;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream oss;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
for (; it != end; ++it)
|
2006-09-10 08:41:39 +00:00
|
|
|
|
asciiParagraph(buf, *it, oss, runparams, ref_printed);
|
2003-10-31 18:45:43 +00:00
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const str = oss.str();
|
2006-09-10 08:41:39 +00:00
|
|
|
|
os << str;
|
|
|
|
|
// Return how many newlines we issued.
|
|
|
|
|
return int(lyx::count(str.begin(), str.end(), '\n'));
|
2000-09-26 15:25:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-27 18:56:26 +00:00
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int InsetText::docbook(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-10-27 10:04:51 +00:00
|
|
|
|
{
|
2004-10-24 00:02:39 +00:00
|
|
|
|
docbookParagraphs(paragraphs(), buf, os, runparams);
|
2003-10-30 08:47:16 +00:00
|
|
|
|
return 0;
|
2000-10-27 10:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetText::validate(LaTeXFeatures & features) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
for_each(paragraphs().begin(), paragraphs().end(),
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bind(&Paragraph::validate, _1, ref(features)));
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
void InsetText::cursorPos(BufferView const & bv,
|
2006-10-17 16:23:27 +00:00
|
|
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const
|
2003-05-03 18:05:53 +00:00
|
|
|
|
{
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
x = text_.cursorX(*bv.buffer(), sl, boundary) + border_;
|
2005-07-15 15:49:40 +00:00
|
|
|
|
y = text_.cursorY(sl, boundary);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bool InsetText::showInsetDialog(BufferView *) const
|
2000-02-25 12:06:15 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return false;
|
2001-03-26 14:47:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 11:44:58 +00:00
|
|
|
|
void InsetText::setText(docstring const & data, LyXFont const & font, bool trackChanges)
|
2001-01-03 16:04:05 +00:00
|
|
|
|
{
|
2005-09-07 10:37:05 +00:00
|
|
|
|
clear();
|
2004-11-23 23:04:52 +00:00
|
|
|
|
Paragraph & first = paragraphs().front();
|
2002-08-12 00:15:19 +00:00
|
|
|
|
for (unsigned int i = 0; i < data.length(); ++i)
|
2006-10-20 11:44:58 +00:00
|
|
|
|
first.insertChar(i, data[i], font, trackChanges);
|
2001-01-03 16:04:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetText::setAutoBreakRows(bool flag)
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2005-07-17 01:13:36 +00:00
|
|
|
|
if (flag == text_.autoBreakRows_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
text_.autoBreakRows_ = flag;
|
|
|
|
|
if (flag)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// remove previously existing newlines
|
|
|
|
|
ParagraphList::iterator it = paragraphs().begin();
|
|
|
|
|
ParagraphList::iterator end = paragraphs().end();
|
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
for (int i = 0; i < it->size(); ++i)
|
|
|
|
|
if (it->isNewline(i))
|
2006-10-19 17:46:50 +00:00
|
|
|
|
// do not track the change, because the user
|
|
|
|
|
// is not allowed to revert/reject it
|
2006-10-21 17:05:20 +00:00
|
|
|
|
it->eraseChar(i, false);
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
2004-08-14 15:55:22 +00:00
|
|
|
|
void InsetText::setDrawFrame(bool flag)
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2004-08-14 15:55:22 +00:00
|
|
|
|
drawFrame_ = flag;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
|
LColor_color InsetText::frameColor() const
|
2003-09-16 10:30:59 +00:00
|
|
|
|
{
|
|
|
|
|
return LColor::color(frame_color_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
|
void InsetText::setFrameColor(LColor_color col)
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2003-09-16 10:01:29 +00:00
|
|
|
|
frame_color_ = col;
|
2000-06-19 15:33:58 +00:00
|
|
|
|
}
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
2000-09-27 18:13:30 +00:00
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
|
2002-03-21 15:58:54 +00:00
|
|
|
|
{
|
2006-10-20 14:06:18 +00:00
|
|
|
|
// There is little we can do here to keep track of changes.
|
|
|
|
|
// As of 2006/10/20, appendParagraphs is used exclusively by
|
|
|
|
|
// LyXTabular::setMultiColumn. In this context, the paragraph break
|
|
|
|
|
// is lost irreversibly and the appended text doesn't really change
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
ParagraphList & pl = paragraphs();
|
2004-11-24 21:58:42 +00:00
|
|
|
|
|
2003-04-28 16:22:32 +00:00
|
|
|
|
ParagraphList::iterator pit = plist.begin();
|
2004-11-23 23:04:52 +00:00
|
|
|
|
ParagraphList::iterator ins = pl.insert(pl.end(), *pit);
|
2003-04-28 16:22:32 +00:00
|
|
|
|
++pit;
|
2006-03-23 20:11:06 +00:00
|
|
|
|
mergeParagraph(buffer->params(), pl,
|
|
|
|
|
std::distance(pl.begin(), ins) - 1);
|
2003-04-28 16:22:32 +00:00
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
for_each(pit, plist.end(),
|
2006-10-20 14:06:18 +00:00
|
|
|
|
bind(&ParagraphList::push_back, ref(pl), _1));
|
2002-03-21 15:58:54 +00:00
|
|
|
|
}
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-18 16:13:33 +00:00
|
|
|
|
void InsetText::addPreview(PreviewLoader & loader) const
|
2002-08-02 16:39:43 +00:00
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
ParagraphList::const_iterator pit = paragraphs().begin();
|
|
|
|
|
ParagraphList::const_iterator pend = paragraphs().end();
|
2003-04-02 21:19:35 +00:00
|
|
|
|
|
|
|
|
|
for (; pit != pend; ++pit) {
|
2003-05-29 01:13:18 +00:00
|
|
|
|
InsetList::const_iterator it = pit->insetlist.begin();
|
|
|
|
|
InsetList::const_iterator end = pit->insetlist.end();
|
2003-08-04 15:59:01 +00:00
|
|
|
|
for (; it != end; ++it)
|
2003-05-29 01:13:18 +00:00
|
|
|
|
it->inset->addPreview(loader);
|
2002-08-02 16:39:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-12-01 13:35:49 +00:00
|
|
|
|
|
|
|
|
|
|
2005-09-10 06:51:58 +00:00
|
|
|
|
//FIXME: instead of this hack, which only works by chance,
|
|
|
|
|
// cells should have their own insetcell type, which returns CELL_CODE!
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
bool InsetText::neverIndent(Buffer const & buffer) const
|
2005-09-10 06:51:58 +00:00
|
|
|
|
{
|
|
|
|
|
// this is only true for tabular cells
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
return !text_.isMainText(buffer) && lyxCode() == TEXT_CODE;
|
2005-09-10 06:51:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParagraphList const & InsetText::paragraphs() const
|
|
|
|
|
{
|
|
|
|
|
return text_.paragraphs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParagraphList & InsetText::paragraphs()
|
2003-12-01 13:35:49 +00:00
|
|
|
|
{
|
2004-03-28 22:00:22 +00:00
|
|
|
|
return text_.paragraphs();
|
2003-12-01 13:35:49 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|