+
+#ifndef NO_COMPABILITY
+#ifndef NO_PEXTRA_REALLY
+ // I wonder if we could use this blanket fix for all the
+ // checkminipage cases...
+ if (par && par->size()) {
+ // It is possible that this will check to often,
+ // but that should not be an correctness issue.
+ // Only a speed issue.
+ checkminipage = true;
+ }
+
+ // now check if we have a minipage paragraph as at this
+ // point we already read all the necessary data!
+ // this cannot be done in layout because there we did
+ // not read yet the paragraph PEXTRA-params (Jug)
+ //
+ // 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.
+
+ //lyxerr << "Call depth: " << call_depth << endl;
+ if (checkminipage && (call_depth == 1)) {
+ checkminipage = false;
+ if (minipar && (minipar != par) &&
+ (par->params().pextraType()==Paragraph::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(0);
+
+ Paragraph * 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();
+ }
+ // create a new paragraph to insert the
+ // minipages in the following case
+ if (par->params().pextraStartMinipage() &&
+ !par->params().pextraHfill())
+ {
+ Paragraph * p = new Paragraph;
+ p->layout = 0;
+ p->previous(parBeforeMinipage);
+ parBeforeMinipage->next(p);
+ p->next(0);
+ p->params().depth(parBeforeMinipage->params().depth());
+ parBeforeMinipage = p;
+ }
+ InsetMinipage * mini = new InsetMinipage;
+ mini->pos(static_cast<InsetMinipage::Position>(par->params().pextraAlignment()));
+ mini->width(par->params().pextraWidth());
+ if (!par->params().pextraWidthp().empty()) {
+ lyxerr << "WP:" << mini->width() << endl;
+ mini->width(tostr(par->params().pextraWidthp())+"%");
+ }
+ mini->inset.paragraph(par);
+ // Insert the minipage last in the
+ // previous paragraph.
+ if (par->params().pextraHfill()) {
+ parBeforeMinipage->insertChar
+ (parBeforeMinipage->size(), Paragraph::META_HFILL);
+ }
+ parBeforeMinipage->insertInset
+ (parBeforeMinipage->size(), mini);
+
+ minipar = par;
+ } else {
+ lyxerr << "new minipage par" << endl;
+ //nothing to do just continue reading
+ }
+
+ } else if (minipar && (minipar != par)) {
+ 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
+ if (par->previous())
+ par->previous()->next(0);
+ par->previous(parBeforeMinipage);
+ parBeforeMinipage->next(par);
+ Paragraph * 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();
+ }
+ depth = parBeforeMinipage->params().depth();
+ minipar = parBeforeMinipage = 0;
+ } else if (!minipar &&
+ (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE))
+ {
+ // par is the first paragraph in a minipage
+ lyxerr << "begin minipage" << endl;
+ // To minimize problems for
+ // the users we will insert
+ // the first minipage in
+ // a sequence of minipages
+ // in its own paragraph.
+ Paragraph * p = new Paragraph;
+ p->layout = 0;
+ p->previous(par->previous());
+ p->next(0);
+ p->params().depth(depth);
+ par->params().depth(0);
+ depth = 0;
+ if (par->previous())
+ par->previous()->next(p);
+ par->previous(0);
+ parBeforeMinipage = p;
+ minipar = par;
+ if (!first_par || (first_par == par))
+ first_par = p;
+
+ InsetMinipage * mini = new InsetMinipage;
+ mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
+ mini->width(minipar->params().pextraWidth());
+ if (!par->params().pextraWidthp().empty()) {
+ lyxerr << "WP:" << mini->width() << endl;
+ mini->width(tostr(par->params().pextraWidthp())+"%");
+ }
+ mini->inset.paragraph(minipar);
+
+ // Insert the minipage last in the
+ // previous paragraph.
+ if (minipar->params().pextraHfill()) {
+ parBeforeMinipage->insertChar
+ (parBeforeMinipage->size(),Paragraph::META_HFILL);
+ }
+ parBeforeMinipage->insertInset
+ (parBeforeMinipage->size(), mini);
+ }
+ }
+ // End of pextra_minipage compability
+ --call_depth;
+#endif
+#endif