mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
some profiler work, a few cleanups
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8942 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6c79118290
commit
e5c1dd967b
@ -1,3 +1,14 @@
|
||||
2004-08-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* text2.C (setCounter): reduce number of calls to pars_[pit]
|
||||
|
||||
* text.C (singleWidth): add an assert, fix a test
|
||||
|
||||
* rowpainter.C (paintText): reduce number of calls to singleWidth
|
||||
|
||||
* paragraph.C (isHfill):
|
||||
(isNewline): ws only
|
||||
|
||||
2004-08-14 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* text.C:
|
||||
|
@ -1,5 +1,7 @@
|
||||
2004-08-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* insettabular.C (draw): whitespace
|
||||
|
||||
* insetnewline.C (draw): use PainterInfo::ltr_pos instead of ownerPar.
|
||||
|
||||
2004-08-14 André Pönitz <poenitz@gmx.net>
|
||||
|
@ -270,12 +270,11 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
for (int i = 0; i < tabular.rows(); ++i) {
|
||||
int nx = x;
|
||||
idx = tabular.getCellNumber(i, 0);
|
||||
if (y + tabular.getDescentOfRow(i) <= 0 &&
|
||||
y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
|
||||
{
|
||||
y += tabular.getDescentOfRow(i) +
|
||||
tabular.getAscentOfRow(i + 1) +
|
||||
tabular.getAdditionalHeight(i + 1);
|
||||
if (y + tabular.getDescentOfRow(i) <= 0
|
||||
&& y - tabular.getAscentOfRow(i) < pi.pain.paperHeight()) {
|
||||
y += tabular.getDescentOfRow(i)
|
||||
+ tabular.getAscentOfRow(i + 1)
|
||||
+ tabular.getAdditionalHeight(i + 1);
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < tabular.columns(); ++j) {
|
||||
@ -965,6 +964,7 @@ void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const
|
||||
|
||||
InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
|
||||
{
|
||||
lyxerr << "# InsetTabular::setPos() x=" << x << " y=" << y << endl;
|
||||
int idx_min = 0;
|
||||
int dist_min = 1000000;
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
|
@ -1481,15 +1481,15 @@ bool IsInsetChar(char c)
|
||||
|
||||
bool Paragraph::isHfill(pos_type pos) const
|
||||
{
|
||||
return
|
||||
isInset(pos) && getInset(pos)->lyxCode() == InsetBase::HFILL_CODE;
|
||||
return isInset(pos)
|
||||
&& getInset(pos)->lyxCode() == InsetBase::HFILL_CODE;
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::isNewline(pos_type pos) const
|
||||
{
|
||||
return
|
||||
isInset(pos) && getInset(pos)->lyxCode() == InsetBase::NEWLINE_CODE;
|
||||
return isInset(pos)
|
||||
&& getInset(pos)->lyxCode() == InsetBase::NEWLINE_CODE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -767,15 +767,16 @@ void RowPainter::paintText()
|
||||
if (x_ > bv_.workWidth())
|
||||
break;
|
||||
|
||||
pos_type pos = text_.bidi.vis2log(vpos);
|
||||
pos_type const pos = text_.bidi.vis2log(vpos);
|
||||
|
||||
if (pos >= par_.size()) {
|
||||
++vpos;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x_ + singleWidth(pos) < 0) {
|
||||
x_ += singleWidth(pos);
|
||||
const int width_pos = singleWidth(pos);
|
||||
if (x_ + width_pos < 0) {
|
||||
x_ += width_pos;
|
||||
++vpos;
|
||||
continue;
|
||||
}
|
||||
@ -803,7 +804,7 @@ void RowPainter::paintText()
|
||||
int const lwidth = font_metrics::width(layout->labelsep,
|
||||
getLabelFont());
|
||||
|
||||
x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
|
||||
x_ += label_hfill_ + lwidth - width_pos;
|
||||
}
|
||||
|
||||
if (par_.isHfill(pos)) {
|
||||
@ -833,7 +834,7 @@ void RowPainter::paintText()
|
||||
x_ += 2;
|
||||
++vpos;
|
||||
} else if (par_.isSeparator(pos)) {
|
||||
x_ += singleWidth(pos);
|
||||
x_ += width_pos;
|
||||
if (pos >= body_pos)
|
||||
x_ += separator_;
|
||||
++vpos;
|
||||
|
14
src/text.C
14
src/text.C
@ -448,15 +448,11 @@ int LyXText::singleWidth(Paragraph const & par, pos_type pos) const
|
||||
int LyXText::singleWidth(Paragraph const & par,
|
||||
pos_type pos, char c, LyXFont const & font) const
|
||||
{
|
||||
if (pos >= par.size()) {
|
||||
lyxerr << "in singleWidth(), pos: " << pos << endl;
|
||||
BOOST_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
BOOST_ASSERT(pos < par.size());
|
||||
|
||||
// The most common case is handled first (Asger)
|
||||
if (IsPrintable(c)) {
|
||||
if (!font.language()->RightToLeft()) {
|
||||
if (font.language()->RightToLeft()) {
|
||||
if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
|
||||
lyxrc.font_norm_type == LyXRC::ISO_10646_1)
|
||||
&& font.language()->lang() == "arabic") {
|
||||
@ -465,7 +461,7 @@ int LyXText::singleWidth(Paragraph const & par,
|
||||
else
|
||||
c = par.transformChar(c, pos);
|
||||
} else if (font.language()->lang() == "hebrew" &&
|
||||
Encodings::IsComposeChar_hebrew(c))
|
||||
Encodings::IsComposeChar_hebrew(c))
|
||||
return 0;
|
||||
}
|
||||
return font_metrics::width(c, font);
|
||||
@ -2121,5 +2117,9 @@ int LyXText::dist(int x, int y) const
|
||||
else if (y > yo_ + descent())
|
||||
yy = y - yo_ - descent();
|
||||
|
||||
lyxerr << " xo_=" << xo_ << " yo_=" << yo_
|
||||
<< " width_=" << width_ << " ascent=" << ascent()
|
||||
<< " descent=" << descent()
|
||||
<< " dist=" << xx+yy <<endl;
|
||||
return xx + yy;
|
||||
}
|
||||
|
47
src/text2.C
47
src/text2.C
@ -708,22 +708,23 @@ void resetEnumCounterIfNeeded(ParagraphList & pars, par_type pit,
|
||||
// set the counter of a paragraph. This includes the labels
|
||||
void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
{
|
||||
Paragraph & par = pars_[pit];
|
||||
BufferParams const & bufparams = buf.params();
|
||||
LyXTextClass const & textclass = bufparams.getLyXTextClass();
|
||||
LyXLayout_ptr const & layout = pars_[pit].layout();
|
||||
LyXLayout_ptr const & layout = par.layout();
|
||||
par_type first_pit = 0;
|
||||
Counters & counters = textclass.counters();
|
||||
|
||||
// Always reset
|
||||
pars_[pit].itemdepth = 0;
|
||||
par.itemdepth = 0;
|
||||
|
||||
if (pit == first_pit) {
|
||||
pars_[pit].params().appendix(pars_[pit].params().startOfAppendix());
|
||||
par.params().appendix(par.params().startOfAppendix());
|
||||
} else {
|
||||
pars_[pit].params().appendix(pars_[pit - 1].params().appendix());
|
||||
if (!pars_[pit].params().appendix() &&
|
||||
pars_[pit].params().startOfAppendix()) {
|
||||
pars_[pit].params().appendix(true);
|
||||
par.params().appendix(pars_[pit - 1].params().appendix());
|
||||
if (!par.params().appendix() &&
|
||||
par.params().startOfAppendix()) {
|
||||
par.params().appendix(true);
|
||||
textclass.counters().reset();
|
||||
}
|
||||
|
||||
@ -732,13 +733,13 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
}
|
||||
|
||||
// erase what was there before
|
||||
pars_[pit].params().labelString(string());
|
||||
par.params().labelString(string());
|
||||
|
||||
if (layout->margintype == MARGIN_MANUAL) {
|
||||
if (pars_[pit].params().labelWidthString().empty())
|
||||
pars_[pit].setLabelWidthString(layout->labelstring());
|
||||
if (par.params().labelWidthString().empty())
|
||||
par.setLabelWidthString(layout->labelstring());
|
||||
} else {
|
||||
pars_[pit].setLabelWidthString(string());
|
||||
par.setLabelWidthString(string());
|
||||
}
|
||||
|
||||
// is it a layout that has an automatic label?
|
||||
@ -746,16 +747,16 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
BufferParams const & bufparams = buf.params();
|
||||
LyXTextClass const & textclass = bufparams.getLyXTextClass();
|
||||
counters.step(layout->counter);
|
||||
string label = expandLabel(textclass, layout, pars_[pit].params().appendix());
|
||||
pars_[pit].params().labelString(label);
|
||||
string label = expandLabel(textclass, layout, par.params().appendix());
|
||||
par.params().labelString(label);
|
||||
} else if (layout->labeltype == LABEL_ITEMIZE) {
|
||||
// At some point of time we should do something more
|
||||
// clever here, like:
|
||||
// pars_[pit].params().labelString(
|
||||
// bufparams.user_defined_bullet(pars_[pit].itemdepth).getText());
|
||||
// par.params().labelString(
|
||||
// bufparams.user_defined_bullet(par.itemdepth).getText());
|
||||
// for now, use a simple hardcoded label
|
||||
string itemlabel;
|
||||
switch (pars_[pit].itemdepth) {
|
||||
switch (par.itemdepth) {
|
||||
case 0:
|
||||
itemlabel = "*";
|
||||
break;
|
||||
@ -770,7 +771,7 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
break;
|
||||
}
|
||||
|
||||
pars_[pit].params().labelString(itemlabel);
|
||||
par.params().labelString(itemlabel);
|
||||
} else if (layout->labeltype == LABEL_ENUMERATE) {
|
||||
// Maybe we have to reset the enumeration counter.
|
||||
resetEnumCounterIfNeeded(pars_, pit, first_pit, counters);
|
||||
@ -780,7 +781,7 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
// (Lgb)
|
||||
string enumcounter = "enum";
|
||||
|
||||
switch (pars_[pit].itemdepth) {
|
||||
switch (par.itemdepth) {
|
||||
case 2:
|
||||
enumcounter += 'i';
|
||||
case 1:
|
||||
@ -798,13 +799,13 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
|
||||
counters.step(enumcounter);
|
||||
|
||||
pars_[pit].params().labelString(counters.enumLabel(enumcounter));
|
||||
par.params().labelString(counters.enumLabel(enumcounter));
|
||||
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
|
||||
counters.step("bibitem");
|
||||
int number = counters.value("bibitem");
|
||||
if (pars_[pit].bibitem()) {
|
||||
pars_[pit].bibitem()->setCounter(number);
|
||||
pars_[pit].params().labelString(layout->labelstring());
|
||||
if (par.bibitem()) {
|
||||
par.bibitem()->setCounter(number);
|
||||
par.params().labelString(layout->labelstring());
|
||||
}
|
||||
// In biblio should't be following counters but...
|
||||
} else {
|
||||
@ -853,7 +854,7 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
|
||||
s = _("Senseless: ");
|
||||
}
|
||||
}
|
||||
pars_[pit].params().labelString(s);
|
||||
par.params().labelString(s);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user