]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
reduce number of calls to LyXText::getFont
[lyx.git] / src / text.C
index 3bc1a9ff12a6097aa7d45f639bed852e16493b5d..cd8b3c2f5d9ad2382936c246985f1711e173a0f4 100644 (file)
@@ -591,7 +591,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const
            && align == LYX_ALIGN_BLOCK
            && !par.params().noindent()
            // in charstyles, tabulars and ert paragraphs are never indented!
-           && (par.ownerCode() != InsetBase::TEXT_CODE
+           && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText())
                    && par.ownerCode() != InsetBase::ERT_CODE
                    && par.ownerCode() != InsetBase::CHARSTYLE_CODE)
            && (par.layout() != tclass.defaultLayout()
@@ -916,7 +916,7 @@ void LyXText::setHeightOfRow(pit_type const pit, Row & row)
 
                // This is special code for the chapter, since the label of this
                // layout is printed in an extra row
-               if (layout->counter == "chapter" 
+               if (layout->counter == "chapter"
                    && !par.params().labelString().empty()) {
                        labeladdon = int(font_metrics::maxHeight(labelfont)
                                     * layout->spacing.getValue()
@@ -1649,11 +1649,29 @@ Row const & LyXText::firstRow() const
 }
 
 
-void LyXText::redoParagraph(pit_type const pit)
+bool LyXText::redoParagraph(pit_type const pit)
 {
        // remove rows of paragraph, keep track of height changes
        Paragraph & par = pars_[pit];
 
+       // Add bibitem insets if necessary
+       if (par.layout()->labeltype == LABEL_BIBLIO) {
+               bool hasbibitem(false);
+               if (!par.insetlist.empty()
+                       // Insist on it being in pos 0
+                       && par.getChar(0) == Paragraph::META_INSET) {
+                       InsetBase * inset = par.insetlist.begin()->inset;
+                       if (inset->lyxCode() == InsetBase::BIBITEM_CODE)
+                               hasbibitem = true;
+               }
+               if (!hasbibitem) {
+                       InsetBibitem * inset(new
+                               InsetBibitem(InsetCommandParams("bibitem")));
+                       par.insertInset(0, static_cast<InsetBase *>(inset));
+                       bv()->cursor().posRight();
+               }
+       }
+
        // redo insets
        InsetList::iterator ii = par.insetlist.begin();
        InsetList::iterator iend = par.insetlist.end();
@@ -1683,8 +1701,13 @@ void LyXText::redoParagraph(pit_type const pit)
 
        dim.asc += par.rows()[0].ascent();
        dim.des -= par.rows()[0].ascent();
+
+       bool const same = dim == par.dim();
+
        par.dim() = dim;
        //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
+
+       return !same;
 }