-#ifndef NO_PEXTRA_REALLY
- // BEGIN pextra_minipage compability
- // This should be removed in 1.3.x (Lgb)
-
- // This compability code is not perfect. In a couple
- // of rand cases it fails. When the minipage par is
- // the first par in the document, and when there are
- // none or only one regular paragraphs after the
- // minipage. Currently I am not investing any effort
- // in fixing those cases.
- static LyXParagraph * minipar = 0;
- //lyxerr << "Call depth: " << call_depth << endl;
- if (call_depth == 1) {
-
- if (minipar
- && par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) {
- lyxerr << "minipages in a row" << endl;
- if (par->params.pextraStartMinipage()) {
- lyxerr << "start new minipage" << endl;
- // minipages in a row
- par->previous()->next(0);
- par->previous(minipar->previous());
- minipar->previous()->next(par);
- minipar->previous(0);
-
- // Before we insert the list of
- // minipages into the inset we have
- // to clean up a bit.
- // This is not quite correct yet since
- // we do want to use some of these
- // parameters to set options in the
- // minipage inset.
- InsetMinipage::Position imp = static_cast<InsetMinipage::Position>(minipar->params.pextraAlignment());
- string pextraWidth = minipar->params.pextraWidth();
- string pextraWidthp = minipar->params.pextraWidthp();
- bool pextraHfill = minipar->params.pextraHfill();
-#if 1
- bool startNew = minipar->params.pextraStartMinipage();
-#endif
-
- LyXParagraph * tmp = minipar;
- while (tmp) {
- tmp->params.pextraType(0);
- tmp->params.pextraWidth(string());
- tmp->params.pextraWidthp(string());
- tmp->params.pextraAlignment(0);
- tmp->params.pextraHfill(false);
- tmp->params.pextraStartMinipage(false);
- tmp = tmp->next();
- }
-
- InsetMinipage * mini = new InsetMinipage;
- mini->pos(imp);
- mini->width(pextraWidth);
- mini->widthp(pextraWidthp);
- mini->inset->par = minipar;
-
-#if 1
- if (!startNew || !pextraHfill) {
- // To minimize problems for
- // the users we will insert
- // the first minipage in
- // a sequence of minipages
- // in its own paragraph.
- LyXParagraph * p = new LyXParagraph;
- p->layout = 0;
- // Insert this after par->prev, but
- // before par.
- p->previous(par->previous());
- p->next(par);
- par->previous()->next(p);
- par->previous(p);
- }
-
-#endif
- // Insert the minipage last in the
- // previous paragraph.
- LyXParagraph * prev = par->previous();
- if (pextraHfill) {
- prev->InsertChar(prev->size(),
- LyXParagraph::META_HFILL);
- }
- prev->InsertInset(prev->size(), mini);
-
- minipar = par;
- } else {
- lyxerr << "new minipage par" << endl;
- //nothing to do just continue reading
- }
-
- } else if (minipar) {
- lyxerr << "last minipage par read" << endl;
- // The last paragraph read was not part of a
- // minipage but the par linked list is...
- // So we need to remove the last par from the
- // rest, insert the rest of the paragraphs into
- // a InsetMinipage, insert this minipage into
- // prevpar, append the current par to prevpar
- // and continue...
-
- LyXParagraph * lp = minipar;
- int pcount = 0;
- while (lp) {
- ++pcount;
- lp = lp->next();
- }
- lyxerr << "Minipar count: " << pcount << endl;
- lyxerr << "Par: " << (void*)par << endl;
- lyxerr << "Par->prev: " << (void*)par->previous() << endl;
-
- if (par->previous())
- par->previous()->next(0);
- par->previous(minipar->previous());
- minipar->previous()->next(par);
- minipar->previous(0);
-
- // Before we insert the list of
- // minipages into the inset we have
- // to clean up a bit.
- // This is not quite correct yet since we
- // do want to use some of these parameters
- // to set options in the minipage inset.
- InsetMinipage::Position imp = static_cast<InsetMinipage::Position>(minipar->params.pextraAlignment());
- string pextraWidth = minipar->params.pextraWidth();
- string pextraWidthp = minipar->params.pextraWidthp();
- bool pextraHfill = minipar->params.pextraHfill();
-#if 1
- bool startNew = minipar->params.pextraStartMinipage();
-#endif
- LyXParagraph * tmp = minipar;
- while (tmp) {
- tmp->params.pextraType(0);
- tmp->params.pextraWidth(string());
- tmp->params.pextraWidthp(string());
- tmp->params.pextraAlignment(0);
- tmp->params.pextraHfill(false);
- tmp->params.pextraStartMinipage(false);
- tmp = tmp->next();
- }
-
- InsetMinipage * mini = new InsetMinipage;
- mini->pos(imp);
- mini->width(pextraWidth);
- mini->widthp(pextraWidthp);
- mini->inset->par = minipar;
-
-#if 1
- if (!startNew || !pextraHfill) {
- // To minimize problems for the users
- // we will insert the first minipage
- // in a sequence of minipages in its
- // own paragraph.
- LyXParagraph * p = new LyXParagraph;
- p->layout = 0;
- // Insert this after par->prev, but
- // before par.
- p->previous(par->previous());
- p->next(par);
- par->previous()->next(p);
- par->previous(p);
- }
-#endif
-
- LyXParagraph * prev = par->previous();
- if (pextraHfill) {
- prev->InsertChar(prev->size(),
- LyXParagraph::META_HFILL);
- }
- prev->InsertInset(prev->size(), mini);
-
- minipar = 0;
- } else if (par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) {
-
- // par is the first paragraph in a minipage
- lyxerr << "begin minipage" << endl;
- minipar = par;
-
- }
- }
-
- // End of pextra_minipage compability
-#endif
- if (!return_par)
- return_par = par;