mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
parlist-10-a.diff + a bit more
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6805 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2da34093a2
commit
b94ed208a5
@ -1,3 +1,31 @@
|
||||
2003-04-14 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* text2.C (setCharFont): adjust
|
||||
(setCounter): adjust
|
||||
|
||||
* text.C (leftMargin): adjust
|
||||
(setHeightOfRow): adjust
|
||||
|
||||
* rowpainter.C (paintFirst): adjust
|
||||
(paintLast): adjust
|
||||
|
||||
* paragraph_pimpl.C (realizeFont): adjust
|
||||
|
||||
* paragraph.C (isFirstInSequence): move from here...
|
||||
* paragraph_funcs.C (isFirstInSequence): ...to here
|
||||
|
||||
* paragraph.C (outerHook): move from here...
|
||||
* paragraph_funcs.C (outerHook): ...to here
|
||||
|
||||
* paragraph.C (depthHook): move from here...
|
||||
* paragraph_funcs.C (depthHook): ...to here
|
||||
|
||||
* paragraph.C (getEndLabel): move from here...
|
||||
* paragraph_funcs.C (getEndLabel): ...to here
|
||||
|
||||
* text2.C (realizeFont): move from here...
|
||||
* paragraph_funcs.C (realizeFont): ...to here
|
||||
|
||||
2003-04-14 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* text3.C (gotoNextInset): use separate tmp vars for par and pos.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ParameterStruct.h"
|
||||
#include "gettext.h"
|
||||
#include "changes.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "insets/insetbibitem.h"
|
||||
#include "insets/insetoptarg.h"
|
||||
@ -689,35 +690,6 @@ bool Paragraph::hasSameLayout(Paragraph const * par) const
|
||||
}
|
||||
|
||||
|
||||
int Paragraph::getEndLabel() const
|
||||
{
|
||||
Paragraph const * par = this;
|
||||
depth_type par_depth = getDepth();
|
||||
while (par) {
|
||||
LyXLayout_ptr const & layout = par->layout();
|
||||
int const endlabeltype = layout->endlabeltype;
|
||||
|
||||
if (endlabeltype != END_LABEL_NO_LABEL) {
|
||||
if (!next_)
|
||||
return endlabeltype;
|
||||
|
||||
depth_type const next_depth = next_->getDepth();
|
||||
if (par_depth > next_depth ||
|
||||
(par_depth == next_depth
|
||||
&& layout != next_->layout()))
|
||||
return endlabeltype;
|
||||
break;
|
||||
}
|
||||
if (par_depth == 0)
|
||||
break;
|
||||
par = par->outerHook();
|
||||
if (par)
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
return END_LABEL_NO_LABEL;
|
||||
}
|
||||
|
||||
|
||||
Paragraph::depth_type Paragraph::getDepth() const
|
||||
{
|
||||
return params().depth();
|
||||
@ -805,60 +777,6 @@ int Paragraph::beginningOfBody() const
|
||||
}
|
||||
|
||||
|
||||
Paragraph * Paragraph::depthHook(depth_type depth)
|
||||
{
|
||||
Paragraph * newpar = this;
|
||||
|
||||
do {
|
||||
newpar = newpar->previous();
|
||||
} while (newpar && newpar->getDepth() > depth);
|
||||
|
||||
if (!newpar) {
|
||||
if (previous() || getDepth())
|
||||
lyxerr << "ERROR (Paragraph::DepthHook): "
|
||||
"no hook." << endl;
|
||||
newpar = this;
|
||||
}
|
||||
|
||||
return newpar;
|
||||
}
|
||||
|
||||
|
||||
Paragraph const * Paragraph::depthHook(depth_type depth) const
|
||||
{
|
||||
Paragraph const * newpar = this;
|
||||
|
||||
do {
|
||||
newpar = newpar->previous();
|
||||
} while (newpar && newpar->getDepth() > depth);
|
||||
|
||||
if (!newpar) {
|
||||
if (previous() || getDepth())
|
||||
lyxerr << "ERROR (Paragraph::DepthHook): "
|
||||
"no hook." << endl;
|
||||
newpar = this;
|
||||
}
|
||||
|
||||
return newpar;
|
||||
}
|
||||
|
||||
|
||||
Paragraph * Paragraph::outerHook()
|
||||
{
|
||||
if (!getDepth())
|
||||
return 0;
|
||||
return depthHook(depth_type(getDepth() - 1));
|
||||
}
|
||||
|
||||
|
||||
Paragraph const * Paragraph::outerHook() const
|
||||
{
|
||||
if (!getDepth())
|
||||
return 0;
|
||||
return depthHook(depth_type(getDepth() - 1));
|
||||
}
|
||||
|
||||
|
||||
// returns -1 if inset not found
|
||||
int Paragraph::getPositionOfInset(Inset const * inset) const
|
||||
{
|
||||
@ -1487,15 +1405,6 @@ void Paragraph::layout(LyXLayout_ptr const & new_layout)
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::isFirstInSequence() const
|
||||
{
|
||||
Paragraph const * dhook = depthHook(getDepth());
|
||||
return (dhook == this
|
||||
|| dhook->layout() != layout()
|
||||
|| dhook->getDepth() != getDepth());
|
||||
}
|
||||
|
||||
|
||||
Inset * Paragraph::inInset() const
|
||||
{
|
||||
return pimpl_->inset_owner;
|
||||
|
@ -112,12 +112,6 @@ public:
|
||||
///
|
||||
void makeSameLayout(Paragraph const * par);
|
||||
|
||||
/// Is it the first par with same depth and layout?
|
||||
bool isFirstInSequence() const;
|
||||
|
||||
/** Check if the current paragraph is the last paragraph in a
|
||||
proof environment */
|
||||
int getEndLabel() const;
|
||||
///
|
||||
Inset * inInset() const;
|
||||
///
|
||||
@ -200,15 +194,6 @@ public:
|
||||
/// mark whole par as erased
|
||||
void markErased();
|
||||
|
||||
/// for the environments
|
||||
Paragraph * depthHook(depth_type depth);
|
||||
/// for the environments
|
||||
Paragraph const * depthHook(depth_type depth) const;
|
||||
///
|
||||
Paragraph * outerHook();
|
||||
///
|
||||
Paragraph const * outerHook() const;
|
||||
|
||||
/// Paragraphs can contain "manual labels", for example, Description environment.
|
||||
/// The text for this user-editable label is stored in the paragraph alongside
|
||||
/// the text of the rest of the paragraph (the body). This function returns
|
||||
|
@ -196,7 +196,6 @@ void mergeParagraph(BufferParams const & bparams,
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth)
|
||||
{
|
||||
Paragraph * newpar = par;
|
||||
@ -207,10 +206,11 @@ Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth)
|
||||
|
||||
if (!newpar) {
|
||||
if (par->previous() || par->getDepth())
|
||||
lyxerr << "Error (depthHook): "
|
||||
<< "no hook." << endl;
|
||||
lyxerr << "ERROR (Paragraph::DepthHook): "
|
||||
"no hook." << endl;
|
||||
newpar = par;
|
||||
}
|
||||
|
||||
return newpar;
|
||||
}
|
||||
|
||||
@ -227,39 +227,38 @@ bool isFirstInSequence(Paragraph * par)
|
||||
{
|
||||
Paragraph const * dhook = depthHook(par, par->getDepth());
|
||||
return (dhook == par
|
||||
|| dhook->getLayout() != par->getLayout()
|
||||
|| dhook->layout() != par->layout()
|
||||
|| dhook->getDepth() != par->getDepth());
|
||||
}
|
||||
|
||||
|
||||
int getEndLabel(Paragraph * para, BufferParams const & bparams)
|
||||
int getEndLabel(Paragraph * p)
|
||||
{
|
||||
Paragraph * par = para;
|
||||
Paragraph * par = p;
|
||||
Paragraph::depth_type par_depth = p->getDepth();
|
||||
while (par) {
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
layout_type layout = par->getLayout();
|
||||
int const endlabeltype =
|
||||
textclasslist.Style(bparams.textclass,
|
||||
layout).endlabeltype;
|
||||
LyXLayout_ptr const & layout = par->layout();
|
||||
int const endlabeltype = layout->endlabeltype;
|
||||
|
||||
if (endlabeltype != END_LABEL_NO_LABEL) {
|
||||
if (!para->next())
|
||||
if (!p->next())
|
||||
return endlabeltype;
|
||||
|
||||
Paragraph::depth_type const next_depth =
|
||||
para->next()->getDepth();
|
||||
Paragraph::depth_type const next_depth = p->next()->getDepth();
|
||||
if (par_depth > next_depth ||
|
||||
(par_depth == next_depth
|
||||
&& layout != para->next()->getLayout()))
|
||||
&& layout != p->next()->layout()))
|
||||
return endlabeltype;
|
||||
break;
|
||||
}
|
||||
if (par_depth == 0)
|
||||
break;
|
||||
par = outerHook(par);
|
||||
if (par)
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
return END_LABEL_NO_LABEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
@ -1024,3 +1023,29 @@ int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex)
|
||||
|
||||
return unknown;
|
||||
}
|
||||
|
||||
|
||||
LyXFont const realizeFont(LyXFont const & font,
|
||||
Buffer const * buf,
|
||||
ParagraphList & /*plist*/,
|
||||
ParagraphList::iterator pit)
|
||||
{
|
||||
LyXTextClass const & tclass = buf->params.getLyXTextClass();
|
||||
LyXFont tmpfont(font);
|
||||
Paragraph::depth_type par_depth = pit->getDepth();
|
||||
|
||||
Paragraph * par = &*pit;
|
||||
|
||||
// Resolve against environment font information
|
||||
while (par && par_depth && !tmpfont.resolved()) {
|
||||
par = outerHook(par);
|
||||
if (par) {
|
||||
tmpfont.realize(par->layout()->font);
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
}
|
||||
|
||||
tmpfont.realize(tclass.defaultfont());
|
||||
|
||||
return tmpfont;
|
||||
}
|
||||
|
@ -13,11 +13,11 @@
|
||||
#define PARAGRAPH_FUNCS_H
|
||||
|
||||
#include "ParagraphList.h"
|
||||
#include "paragraph.h"
|
||||
#include "support/types.h"
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class Paragraph;
|
||||
class TexRow;
|
||||
class LyXLex;
|
||||
|
||||
@ -42,8 +42,6 @@ void mergeParagraph(BufferParams const & bparams,
|
||||
ParagraphList & paragraphs,
|
||||
ParagraphList::iterator par);
|
||||
|
||||
|
||||
#if 0
|
||||
/// for the environments
|
||||
Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth);
|
||||
|
||||
@ -54,8 +52,7 @@ bool isFirstInSequence(Paragraph * par);
|
||||
|
||||
/** Check if the current paragraph is the last paragraph in a
|
||||
proof environment */
|
||||
int getEndLabel(Paragraph * para, BufferParams const & bparams);
|
||||
#endif
|
||||
int getEndLabel(Paragraph * para);
|
||||
|
||||
|
||||
void latexParagraphs(Buffer const * buf,
|
||||
@ -69,4 +66,9 @@ void latexParagraphs(Buffer const * buf,
|
||||
/// read a paragraph from a .lyx file. Returns number of unrecognised tokens
|
||||
int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex);
|
||||
|
||||
LyXFont const realizeFont(LyXFont const & font,
|
||||
Buffer const * buf,
|
||||
ParagraphList & /*plist*/,
|
||||
ParagraphList::iterator pit);
|
||||
|
||||
#endif // PARAGRAPH_FUNCS_H
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "encoding.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "support/LAssert.h"
|
||||
|
||||
@ -859,12 +860,12 @@ LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
|
||||
LyXFont tmpfont(font);
|
||||
|
||||
// check for environment font information
|
||||
char par_depth = owner_->getDepth();
|
||||
Paragraph const * par = owner_;
|
||||
depth_type par_depth = owner_->getDepth();
|
||||
Paragraph * par = owner_;
|
||||
LyXTextClass const & tclass = bparams.getLyXTextClass();
|
||||
|
||||
while (par && par->getDepth() && !tmpfont.resolved()) {
|
||||
par = par->outerHook();
|
||||
par = outerHook(par);
|
||||
if (par) {
|
||||
tmpfont.realize(par->layout()->font);
|
||||
par_depth = par->getDepth();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include "insets/insettext.h"
|
||||
@ -673,7 +674,7 @@ void RowPainter::paintFirst()
|
||||
if (layout->labeltype >= LABEL_STATIC
|
||||
&& (layout->labeltype != LABEL_STATIC
|
||||
|| layout->latextype != LATEX_ENVIRONMENT
|
||||
|| pit_->isFirstInSequence())) {
|
||||
|| isFirstInSequence(&*pit_))) {
|
||||
|
||||
LyXFont font = getLabelFont();
|
||||
if (!pit_->getLabelstring().empty()) {
|
||||
@ -721,7 +722,7 @@ void RowPainter::paintFirst()
|
||||
|
||||
// the labels at the top of an environment.
|
||||
// More or less for bibliography
|
||||
} else if (pit_->isFirstInSequence() &&
|
||||
} else if (isFirstInSequence(&*pit_) &&
|
||||
(layout->labeltype == LABEL_TOP_ENVIRONMENT ||
|
||||
layout->labeltype == LABEL_BIBLIO ||
|
||||
layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
|
||||
@ -796,7 +797,7 @@ void RowPainter::paintLast()
|
||||
}
|
||||
|
||||
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
|
||||
int const endlabel = pit_->getEndLabel();
|
||||
int const endlabel = getEndLabel(&*pit_);
|
||||
|
||||
// draw an endlabel
|
||||
switch (endlabel) {
|
||||
|
18
src/text.C
18
src/text.C
@ -538,8 +538,8 @@ int LyXText::leftMargin(Row const & row) const
|
||||
if (row.par()->layout() == tclass.defaultLayout()) {
|
||||
// find the previous same level paragraph
|
||||
if (row.par() != ownerParagraphs().begin()) {
|
||||
Paragraph * newpar = row.par()
|
||||
->depthHook(row.par()->getDepth());
|
||||
Paragraph * newpar =
|
||||
depthHook(&*row.par(), row.par()->getDepth());
|
||||
if (newpar &&
|
||||
newpar->layout()->nextnoindent)
|
||||
parindent.erase();
|
||||
@ -548,7 +548,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
} else {
|
||||
// find the next level paragraph
|
||||
|
||||
Paragraph * newpar = row.par()->outerHook();
|
||||
Paragraph * newpar = outerHook(&*row.par());
|
||||
|
||||
// make a corresponding row. Needed to call leftMargin()
|
||||
|
||||
@ -614,7 +614,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
// theorems (JMarc)
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& ! row.par()->isFirstInSequence())) {
|
||||
&& !isFirstInSequence(&*row.par()))) {
|
||||
x += font_metrics::signedWidth(layout->leftmargin,
|
||||
labelfont);
|
||||
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
|
||||
@ -679,7 +679,7 @@ int LyXText::leftMargin(Row const & row) const
|
||||
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& ! row.par()->isFirstInSequence()))
|
||||
&& !isFirstInSequence(&*row.par())))
|
||||
&& align == LYX_ALIGN_BLOCK
|
||||
&& !row.par()->params().noindent()
|
||||
// in tabulars and ert paragraphs are never indented!
|
||||
@ -1153,7 +1153,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
|
||||
|| layout->labeltype == LABEL_BIBLIO
|
||||
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
|
||||
&& pit->isFirstInSequence()
|
||||
&& isFirstInSequence(&*pit)
|
||||
&& !pit->getLabelstring().empty())
|
||||
{
|
||||
float spacing_val = 1.0;
|
||||
@ -1180,7 +1180,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
if (!pit->params().pagebreakTop()) {
|
||||
Paragraph * prev = pit->previous();
|
||||
if (prev)
|
||||
prev = pit->depthHook(pit->getDepth());
|
||||
prev = depthHook(&*pit, pit->getDepth());
|
||||
if (prev && prev->layout() == layout &&
|
||||
prev->getDepth() == pit->getDepth() &&
|
||||
prev->getLabelWidthString() == pit->getLabelWidthString())
|
||||
@ -1201,7 +1201,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
layoutasc = (tmptop * defaultRowHeight());
|
||||
}
|
||||
|
||||
prev = pit->outerHook();
|
||||
prev = outerHook(&*pit);
|
||||
if (prev) {
|
||||
maxasc += int(prev->layout()->parsep * defaultRowHeight());
|
||||
} else if (pit != ownerParagraphs().begin()) {
|
||||
@ -1250,7 +1250,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
|
||||
|
||||
if (comparepit->getDepth() > nextpit->getDepth()) {
|
||||
usual = (comparepit->layout()->bottomsep * defaultRowHeight());
|
||||
comparepit = comparepit->depthHook(nextpit->getDepth());
|
||||
comparepit = depthHook(&*comparepit, nextpit->getDepth());
|
||||
if (comparepit->layout()!= nextpit->layout()
|
||||
|| nextpit->getLabelWidthString() !=
|
||||
comparepit->getLabelWidthString())
|
||||
|
35
src/text2.C
35
src/text2.C
@ -30,6 +30,7 @@
|
||||
#include "ParagraphParameters.h"
|
||||
#include "counters.h"
|
||||
#include "lyxrow_funcs.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "insets/insetbibitem.h"
|
||||
#include "insets/insetfloat.h"
|
||||
@ -99,36 +100,6 @@ void LyXText::init(BufferView * bview, bool reinit)
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
LyXFont const realizeFont(LyXFont const & font,
|
||||
Buffer const * buf,
|
||||
ParagraphList & /*plist*/,
|
||||
ParagraphList::iterator pit)
|
||||
{
|
||||
LyXTextClass const & tclass = buf->params.getLyXTextClass();
|
||||
LyXFont tmpfont(font);
|
||||
Paragraph::depth_type par_depth = pit->getDepth();
|
||||
|
||||
Paragraph * par = &*pit;
|
||||
|
||||
// Resolve against environment font information
|
||||
while (par && par_depth && !tmpfont.resolved()) {
|
||||
par = par->outerHook();
|
||||
if (par) {
|
||||
tmpfont.realize(par->layout()->font);
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
}
|
||||
|
||||
tmpfont.realize(tclass.defaultfont());
|
||||
|
||||
return tmpfont;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Gets the fully instantiated font at a given position in a paragraph
|
||||
// Basically the same routine as Paragraph::getFont() in paragraph.C.
|
||||
// The difference is that this one is used for displaying, and thus we
|
||||
@ -251,7 +222,7 @@ void LyXText::setCharFont(Buffer const * buf, ParagraphList::iterator pit,
|
||||
#warning FIXME I think I hate this outerHood stuff.
|
||||
Paragraph * tp = &*pit;
|
||||
while (!layoutfont.resolved() && tp && tp->getDepth()) {
|
||||
tp = tp->outerHook();
|
||||
tp = outerHook(tp);
|
||||
if (tp)
|
||||
layoutfont.realize(tp->layout()->font);
|
||||
}
|
||||
@ -1091,7 +1062,7 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
|
||||
if (pit != ownerParagraphs().begin()
|
||||
&& boost::prior(pit)->getDepth() > pit->getDepth()
|
||||
&& layout->labeltype != LABEL_BIBLIO) {
|
||||
pit->enumdepth = pit->depthHook(pit->getDepth())->enumdepth;
|
||||
pit->enumdepth = depthHook(&*pit, pit->getDepth())->enumdepth;
|
||||
}
|
||||
|
||||
if (!pit->params().labelString().empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user