mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
General cleanup: Text is (or should be) nothing more than InsetText private implementation. We need access to the owner InsetText property in many cases where we instead take the Paragraph owner inset, which is the same of course. Next step is to avoid this indirection whenever possible.
I also updated InsetMathMBox so that it remains compilable, even if not used. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30940 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5444f386e0
commit
e8674d6141
@ -41,13 +41,17 @@ class Spacing;
|
||||
class Text {
|
||||
public:
|
||||
/// constructor
|
||||
explicit Text();
|
||||
explicit Text(InsetText * owner)
|
||||
: autoBreakRows_(false), owner_(owner)
|
||||
{}
|
||||
|
||||
/// \return true if there's no content at all.
|
||||
/// \warning a non standard layout on an empty paragraph doesn't
|
||||
// count as empty.
|
||||
bool empty() const;
|
||||
|
||||
InsetText const * inset() { return owner_; }
|
||||
|
||||
///
|
||||
FontInfo layoutFont(Buffer const & buffer, pit_type pit) const;
|
||||
///
|
||||
@ -344,6 +348,9 @@ private:
|
||||
void pasteString(Cursor & cur, docstring const & str,
|
||||
bool asParagraphs);
|
||||
|
||||
/// Owner Inset.
|
||||
InsetText * owner_;
|
||||
|
||||
/// position of the text in the buffer.
|
||||
DocIterator macrocontext_position_;
|
||||
};
|
||||
|
@ -63,11 +63,6 @@ using namespace std;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
Text::Text()
|
||||
: autoBreakRows_(false)
|
||||
{}
|
||||
|
||||
|
||||
bool Text::isMainText(Buffer const & buffer) const
|
||||
{
|
||||
return &buffer.text() == this;
|
||||
|
@ -76,7 +76,7 @@ using graphics::PreviewLoader;
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
InsetText::InsetText(Buffer const & buf, UsePlain type)
|
||||
: drawFrame_(false), frame_color_(Color_insetframe)
|
||||
: drawFrame_(false), frame_color_(Color_insetframe), text_(this)
|
||||
{
|
||||
setBuffer(const_cast<Buffer &>(buf));
|
||||
initParagraphs(type);
|
||||
@ -84,7 +84,7 @@ InsetText::InsetText(Buffer const & buf, UsePlain type)
|
||||
|
||||
|
||||
InsetText::InsetText(InsetText const & in)
|
||||
: Inset(in), text_()
|
||||
: Inset(in), text_(this)
|
||||
{
|
||||
text_.autoBreakRows_ = in.text_.autoBreakRows_;
|
||||
drawFrame_ = in.drawFrame_;
|
||||
|
@ -32,14 +32,15 @@ using namespace std;
|
||||
namespace lyx {
|
||||
|
||||
|
||||
InsetMathMBox::InsetMathMBox()
|
||||
InsetMathMBox::InsetMathMBox(Buffer const & buffer) : text_(buffer)
|
||||
{
|
||||
text_.paragraphs().clear();
|
||||
text_.paragraphs().push_back(Paragraph());
|
||||
}
|
||||
|
||||
|
||||
InsetMathMBox::InsetMathMBox(Layout const & layout)
|
||||
InsetMathMBox::InsetMathMBox(Buffer const & buffer, Layout const & layout)
|
||||
: text_(buffer)
|
||||
{
|
||||
text_.paragraphs().clear();
|
||||
text_.paragraphs().push_back(Paragraph());
|
||||
@ -55,7 +56,7 @@ Inset * InsetMathMBox::clone() const
|
||||
|
||||
void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
|
||||
TextMetrics & tm = mi.base.bv->textMetrics(&text_.text());
|
||||
tm.metrics(mi, dim);
|
||||
metricsMarkers2(dim);
|
||||
}
|
||||
@ -63,7 +64,7 @@ void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
pi.base.bv->textMetrics(&text_).draw(pi, x + 1, y);
|
||||
pi.base.bv->textMetrics(&text_.text()).draw(pi, x + 1, y);
|
||||
drawMarkers(pi, x, y);
|
||||
}
|
||||
|
||||
@ -74,13 +75,13 @@ void InsetMathMBox::write(WriteStream & ws) const
|
||||
ws << "\\mbox{\n";
|
||||
TexRow texrow;
|
||||
OutputParams runparams(&buffer().params().encoding());
|
||||
latexParagraphs(buffer(), text_, ws.os(), texrow, runparams);
|
||||
latexParagraphs(buffer(), text_.text(), ws.os(), texrow, runparams);
|
||||
ws.addlines(texrow.rows());
|
||||
ws << "}";
|
||||
} else {
|
||||
ws << "\\mbox{\n";
|
||||
ostringstream os;
|
||||
text_.write(buffer(), os);
|
||||
text_.text().write(buffer(), os);
|
||||
ws.os() << from_utf8(os.str());
|
||||
ws << "}";
|
||||
}
|
||||
@ -91,7 +92,7 @@ int InsetMathMBox::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
os << "\\mbox{\n";
|
||||
TexRow texrow;
|
||||
latexParagraphs(buffer(), text_, os, texrow, runparams);
|
||||
latexParagraphs(buffer(), text_.text(), os, texrow, runparams);
|
||||
os << "}";
|
||||
return texrow.rows();
|
||||
}
|
||||
@ -99,21 +100,21 @@ int InsetMathMBox::latex(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
void InsetMathMBox::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
text_.dispatch(cur, cmd);
|
||||
text_.text().dispatch(cur, cmd);
|
||||
}
|
||||
|
||||
|
||||
Text * InsetMathMBox::getText(int) const
|
||||
{
|
||||
return &text_;
|
||||
return &text_.text();
|
||||
}
|
||||
|
||||
|
||||
void InsetMathMBox::cursorPos(BufferView const & bv,
|
||||
CursorSlice const & sl, bool boundary, int & x, int & y) const
|
||||
{
|
||||
x = bv.textMetrics(&text_).cursorX(sl, boundary);
|
||||
y = bv.textMetrics(&text_).cursorY(sl, boundary);
|
||||
x = bv.textMetrics(&text_.text()).cursorX(sl, boundary);
|
||||
y = bv.textMetrics(&text_.text()).cursorY(sl, boundary);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
#define MATH_MBOXINSET_H
|
||||
|
||||
#include "InsetMath.h"
|
||||
#include "Text.h"
|
||||
|
||||
#include "insets/InsetText.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
@ -30,8 +31,8 @@ class BufferView;
|
||||
class InsetMathMBox : public InsetMath {
|
||||
public:
|
||||
///
|
||||
explicit InsetMathMBox();
|
||||
explicit InsetMathMBox(Layout const & layout);
|
||||
explicit InsetMathMBox(Buffer const & buffer);
|
||||
explicit InsetMathMBox(Buffer const & buffer, Layout const & layout);
|
||||
|
||||
/// this stores metrics information in cache_
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
@ -58,7 +59,7 @@ protected:
|
||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
|
||||
///
|
||||
mutable Text text_;
|
||||
mutable InsetText text_;
|
||||
|
||||
private:
|
||||
virtual Inset * clone() const;
|
||||
|
Loading…
Reference in New Issue
Block a user