]> git.lyx.org Git - features.git/commitdiff
Change the interface to a paragraph's layout. We still store a LayoutPtr, but now...
authorRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 21:31:27 +0000 (21:31 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 6 Mar 2008 21:31:27 +0000 (21:31 +0000)
The need for a LayoutPtr arises from the fact that (a) we do not want to give our clients a Layout &, since we do not want them to be able to change our Layout; but (b) we also need to be able to change which layout is ours. So we cannot store a Layout const &. Or so it seems to the compiler.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23522 a592a061-630c-0410-9148-cb99ea01b6c8

29 files changed:
src/BaseClassList.h
src/Buffer.cpp
src/Cursor.cpp
src/CutAndPaste.cpp
src/Layout.cpp
src/Layout.h
src/Paragraph.cpp
src/Paragraph.h
src/ParagraphMetrics.cpp
src/ParagraphParameters.cpp
src/Text.cpp
src/Text2.cpp
src/Text3.cpp
src/TextClass.h
src/TextMetrics.cpp
src/TocBackend.cpp
src/buffer_funcs.cpp
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiToolbar.cpp
src/insets/InsetFoot.cpp
src/insets/InsetText.cpp
src/mathed/InsetMathMBox.cpp
src/mathed/InsetMathMBox.h
src/output_docbook.cpp
src/output_latex.cpp
src/output_plaintext.cpp
src/paragraph_funcs.cpp
src/rowpainter.cpp
src/sgml.cpp

index 73ea0d950ae9d25217b2b54b32d91d81e6430058..4f058f6de1418b1ae35bc95dbd2729e0dcf18d24 100644 (file)
@@ -37,6 +37,7 @@ public:
        ///
        operator base_type() const { return data_; }
        ///
+       bool empty() const { return data_.empty(); }
 private:
        base_type data_;
 };
index 0742c5fad232123ecc50fe2852ad6de8833a5029..78aaf190701e76ea13583563aa4187964d6189a9 100644 (file)
@@ -592,7 +592,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
                if (*cit == '\n') {
                        if (autobreakrows && (!par.empty() || par.allowEmpty())) {
                                breakParagraph(params(), pars, pit, pos,
-                                              par.layout()->isEnvironment());
+                                              par.layout().isEnvironment());
                                ++pit;
                                pos = 0;
                                space_inserted = true;
@@ -1834,7 +1834,7 @@ void Buffer::updateEnvironmentMacros(DocIterator & it,
                // increased depth?
                if ((par.params().depth() > depth
                     || par.params().leftIndent() != leftIndent)
-                   && par.layout()->isEnvironment()) {
+                   && par.layout().isEnvironment()) {
                        updateBlockMacros(it, scope);
                        continue;
                }
@@ -1924,7 +1924,7 @@ void Buffer::updateBlockMacros(DocIterator & it, DocIterator & scope) const
        // set scope for macros in this paragraph:
        // * either the "old" outer scope
        // * or the scope ending after the environment
-       if (par.layout()->isEnvironment()) {
+       if (par.layout().isEnvironment()) {
                // find end of environment block,
                DocIterator envEnd = it;
                pit_type n = it.lastpit() + 1;
index d60323c64812d2f7351d0e94a22382384e2b5966..656fc7417cf2d62b852869c85bb84a96c7915bf9 100644 (file)
@@ -1956,7 +1956,7 @@ void Cursor::recordUndoSelection()
 
 void Cursor::checkBufferStructure()
 {
-       if (paragraph().layout()->toclevel == Layout::NOT_IN_TOC)
+       if (paragraph().layout().toclevel == Layout::NOT_IN_TOC)
                return;
        Buffer const * master = buffer().masterBuffer();
        master->tocBackend().updateItem(ParConstIterator(*this));
index 9ec65f901c84a1882453a96ead45f3be98b2b80b..bd0b3baaa7cdddfa974b49b52897f687ba0dd97d 100644 (file)
@@ -449,7 +449,7 @@ void switchBetweenClasses(DocumentClass const * const oldone,
        // layouts
        ParIterator end = par_iterator_end(in);
        for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
-               docstring const name = it->layout()->name();
+               docstring const name = it->layout().name();
                bool hasLayout = newtc.hasLayout(name);
 
                if (in.useEmptyLayout())
@@ -463,7 +463,7 @@ void switchBetweenClasses(DocumentClass const * const oldone,
                        docstring const s = bformat(
                                                 _("Layout had to be changed from\n%1$s to %2$s\n"
                                                "because of class conversion from\n%3$s to %4$s"),
-                        name, it->layout()->name(),
+                        name, it->layout().name(),
                         from_utf8(oldtc.name()), from_utf8(newtc.name()));
                        // To warn the user that something had to be done.
                        errorlist.push_back(ErrorItem(_("Changed Layout"), s,
index c874f88efc12393bd817d324b1f17598c88b288a..e368f23bbda0e821d3928b0f58538e5290a9e577 100644 (file)
@@ -830,6 +830,16 @@ docstring const & Layout::depends_on() const
 }
 
 
+bool Layout::operator==(Layout const & rhs) const
+{
+       // This is enough for the applications we actually make,
+       // at least at the moment. But we could check more.
+       return name() == rhs.name()
+               && latexname() == rhs.latexname()
+               && latextype == rhs.latextype;
+}
+
+
 Layout * Layout::forCaption()
 {
        Layout * lay = new Layout();
index 32abb5c520db108ccced9625616823eb33e2eb36..7da73aa5537d7a9146e5f2547c356fa9c5359e21 100644 (file)
@@ -100,6 +100,27 @@ public:
        docstring const & labelstring_appendix() const {
                return labelstring_appendix_;
        }
+       ///
+       bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
+       ///
+       bool isCommand() const { return latextype == LATEX_COMMAND; }
+       ///
+       bool isEnvironment() const {
+               return latextype == LATEX_ENVIRONMENT
+                       || latextype == LATEX_BIB_ENVIRONMENT
+                       || latextype == LATEX_ITEM_ENVIRONMENT
+                       || latextype == LATEX_LIST_ENVIRONMENT;
+       }
+
+       ///
+       bool operator==(Layout const &) const;
+       ///
+       bool operator!=(Layout const & rhs) const 
+               { return !(*this == rhs); }
+
+       ////////////////////////////////////////////////////////////////
+       // members
+       ////////////////////////////////////////////////////////////////
        /** Default font for this layout/environment.
            The main font for this kind of environment. If an attribute has
            INHERITED_*, it means that the value is specified by
@@ -197,17 +218,6 @@ public:
        bool needprotect;
        /// true when empty paragraphs should be kept.
        bool keepempty;
-       ///
-       bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
-       ///
-       bool isCommand() const { return latextype == LATEX_COMMAND; }
-       ///
-       bool isEnvironment() const {
-               return latextype == LATEX_ENVIRONMENT
-                       || latextype == LATEX_BIB_ENVIRONMENT
-                       || latextype == LATEX_ITEM_ENVIRONMENT
-                       || latextype == LATEX_LIST_ENVIRONMENT;
-       }
        /// Type of LaTeX object
        LatexType latextype;
        /// Does this object belong in the title part of the document?
index 4e5dfb148d8a7ce7a6baccf97afb832bc8db94f3..1d9330ce66346f595e6ab71bbb27154c3bcffbb2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "Paragraph.h"
 
+#include "BaseClassList.h"
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Changes.h"
@@ -78,7 +79,7 @@ class Paragraph::Private
 {
 public:
        ///
-       Private(Paragraph * owner);
+       Private(Paragraph * owner, Layout const & layout);
        /// "Copy constructor"
        Private(Private const &, Paragraph * owner);
 
@@ -189,8 +190,12 @@ public:
        ///
        InsetList insetlist_;
 
+       // This little bit of indirection is needed so that we can protect
+       // the layout as const but still be able to change layout_.
        ///
-       LayoutPtr layout_;
+       Layout const & layout() const { return *layout_; }
+       ///
+       void setLayout(Layout const & layout) { layout_ = &layout; }
 
        /// end of label
        pos_type begin_of_body_;
@@ -202,6 +207,9 @@ public:
        typedef std::set<docstring> Words;
        ///
        Words words_;
+private:
+       ///
+       Layout const * layout_;
 };
 
 
@@ -228,8 +236,8 @@ size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
 } // namespace anon
 
 
-Paragraph::Private::Private(Paragraph * owner)
-       : owner_(owner), inset_owner_(0), begin_of_body_(0)
+Paragraph::Private::Private(Paragraph * owner, Layout const & layout)
+       : owner_(owner), inset_owner_(0), begin_of_body_(0), layout_(&layout)
 {
        id_ = paragraph_id++;
        text_.reserve(100);
@@ -239,8 +247,8 @@ Paragraph::Private::Private(Paragraph * owner)
 Paragraph::Private::Private(Private const & p, Paragraph * owner)
        : owner_(owner), inset_owner_(p.inset_owner_), fontlist_(p.fontlist_), 
          params_(p.params_), changes_(p.changes_), insetlist_(p.insetlist_),
-         layout_(p.layout_), begin_of_body_(p.begin_of_body_), text_(p.text_),
-         words_(p.words_)
+         begin_of_body_(p.begin_of_body_), text_(p.text_), words_(p.words_),
+         layout_(p.layout_)
 {
        id_ = paragraph_id++;
 }
@@ -1034,8 +1042,12 @@ void Paragraph::Private::validate(LaTeXFeatures & features,
 //
 /////////////////////////////////////////////////////////////////////
 
-Paragraph::Paragraph()
-       : d(new Paragraph::Private(this))
+namespace {
+       Layout const emptyParagraphLayout;
+}
+
+Paragraph::Paragraph() 
+       : d(new Paragraph::Private(this, emptyParagraphLayout))
 {
        itemdepth = 0;
        d->params_.clear();
@@ -1091,7 +1103,7 @@ void Paragraph::write(ostream & os, BufferParams const & bparams,
        }
 
        // First write the layout
-       os << "\n\\begin_layout " << to_utf8(d->layout_->name()) << '\n';
+       os << "\n\\begin_layout " << to_utf8(d->layout().name()) << '\n';
 
        d->params_.write(os);
 
@@ -1171,7 +1183,7 @@ void Paragraph::write(ostream & os, BufferParams const & bparams,
 
 void Paragraph::validate(LaTeXFeatures & features) const
 {
-       d->validate(features, *d->layout_);
+       d->validate(features, d->layout());
 }
 
 
@@ -1335,9 +1347,9 @@ Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
 
        pos_type const body_pos = beginOfBody();
        if (pos < body_pos)
-               font.fontInfo().realize(d->layout_->labelfont);
+               font.fontInfo().realize(d->layout().labelfont);
        else
-               font.fontInfo().realize(d->layout_->font);
+               font.fontInfo().realize(d->layout().font);
 
        font.fontInfo().realize(outerfont.fontInfo());
        font.fontInfo().realize(bparams.getFont().fontInfo());
@@ -1349,7 +1361,7 @@ Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
 Font const Paragraph::getLabelFont
        (BufferParams const & bparams, Font const & outerfont) const
 {
-       FontInfo tmpfont = d->layout_->labelfont;
+       FontInfo tmpfont = d->layout().labelfont;
        tmpfont.realize(outerfont.fontInfo());
        tmpfont.realize(bparams.getFont().fontInfo());
        return Font(tmpfont, getParLanguage(bparams));
@@ -1359,7 +1371,7 @@ Font const Paragraph::getLabelFont
 Font const Paragraph::getLayoutFont
        (BufferParams const & bparams, Font const & outerfont) const
 {
-       FontInfo tmpfont = d->layout_->font;
+       FontInfo tmpfont = d->layout().font;
        tmpfont.realize(outerfont.fontInfo());
        tmpfont.realize(bparams.getFont().fontInfo());
        return Font(tmpfont, getParLanguage(bparams));
@@ -1429,7 +1441,7 @@ void Paragraph::setFont(pos_type pos, Font const & font)
 
 void Paragraph::makeSameLayout(Paragraph const & par)
 {
-       d->layout_ = par.d->layout_;
+       d->setLayout(par.d->layout());
        d->params_ = par.d->params_;
 }
 
@@ -1455,7 +1467,8 @@ bool Paragraph::stripLeadingSpaces(bool trackChanges)
 
 bool Paragraph::hasSameLayout(Paragraph const & par) const
 {
-       return par.d->layout_ == d->layout_ && d->params_.sameLayout(par.d->params_);
+       return par.d->layout() == d->layout()
+               && d->params_.sameLayout(par.d->params_);
 }
 
 
@@ -1467,7 +1480,7 @@ depth_type Paragraph::getDepth() const
 
 depth_type Paragraph::getMaxDepthAfter() const
 {
-       if (d->layout_->isEnvironment())
+       if (d->layout().isEnvironment())
                return d->params_.depth() + 1;
        else
                return d->params_.depth();
@@ -1477,7 +1490,7 @@ depth_type Paragraph::getMaxDepthAfter() const
 char Paragraph::getAlign() const
 {
        if (d->params_.align() == LYX_ALIGN_LAYOUT)
-               return d->layout_->align;
+               return d->layout().align;
        else
                return d->params_.align();
 }
@@ -1492,7 +1505,7 @@ docstring const & Paragraph::labelString() const
 // the next two functions are for the manual labels
 docstring const Paragraph::getLabelWidthString() const
 {
-       if (d->layout_->margintype == MARGIN_MANUAL)
+       if (d->layout().margintype == MARGIN_MANUAL)
                return d->params_.labelWidthString();
        else
                return _("Senseless with this layout!");
@@ -1519,21 +1532,21 @@ docstring const Paragraph::translateIfPossible(docstring const & s,
 }
 
 
-docstring Paragraph::expandLabel(LayoutPtr const & layout,
+docstring Paragraph::expandLabel(Layout const & layout,
                BufferParams const & bparams, bool process_appendix) const
 {
        DocumentClass const & tclass = bparams.documentClass();
 
        docstring fmt;
        if (process_appendix && d->params_.appendix())
-               fmt = translateIfPossible(layout->labelstring_appendix(),
+               fmt = translateIfPossible(layout.labelstring_appendix(),
                        bparams);
        else
-               fmt = translateIfPossible(layout->labelstring(), bparams);
+               fmt = translateIfPossible(layout.labelstring(), bparams);
 
-       if (fmt.empty() && layout->labeltype == LABEL_COUNTER 
-           && !layout->counter.empty())
-               fmt = "\\the" + layout->counter;
+       if (fmt.empty() && layout.labeltype == LABEL_COUNTER 
+           && !layout.counter.empty())
+               fmt = "\\the" + layout.counter;
 
        // handle 'inherited level parts' in 'fmt',
        // i.e. the stuff between '@' in   '@Section@.\arabic{subsection}'
@@ -1544,7 +1557,7 @@ docstring Paragraph::expandLabel(LayoutPtr const & layout,
                        docstring parent(fmt, i + 1, j - i - 1);
                        docstring label = from_ascii("??");
                        if (tclass.hasLayout(parent))
-                               docstring label = expandLabel(&(tclass[parent]), bparams,
+                               docstring label = expandLabel(tclass[parent], bparams,
                                                      process_appendix);
                        fmt = docstring(fmt, 0, i) + label 
                                + docstring(fmt, j + 1, docstring::npos);
@@ -1557,10 +1570,10 @@ docstring Paragraph::expandLabel(LayoutPtr const & layout,
 
 void Paragraph::applyLayout(Layout const & new_layout)
 {
-       d->layout_ = &new_layout;
+       d->setLayout(new_layout);
        LyXAlignment const oldAlign = d->params_.align();
        
-       if (!(oldAlign & d->layout_->alignpossible)) {
+       if (!(oldAlign & d->layout().alignpossible)) {
                frontend::Alert::warning(_("Alignment not permitted"), 
                        _("The new layout does not permit the alignment previously used.\nSetting to default."));
                d->params_.align(LYX_ALIGN_LAYOUT);
@@ -1576,7 +1589,7 @@ pos_type Paragraph::beginOfBody() const
 
 void Paragraph::setBeginOfBody()
 {
-       if (d->layout_->labeltype != LABEL_MANUAL) {
+       if (d->layout().labeltype != LABEL_MANUAL) {
                d->begin_of_body_ = 0;
                return;
        }
@@ -1817,14 +1830,14 @@ bool Paragraph::latex(BufferParams const & bparams,
 
        bool return_value = false;
 
-       LayoutPtr style;
+       Layout style;
 
        bool asdefault = forceEmptyLayout();
 
        if (asdefault)
-               style = &(bparams.documentClass().emptyLayout());
+               style = bparams.documentClass().emptyLayout();
         else
-               style = d->layout_;
+               style = d->layout();
 
        // Current base font for all inherited font changes, without any
        // change caused by an individual character, except for the language:
@@ -1859,7 +1872,7 @@ bool Paragraph::latex(BufferParams const & bparams,
 
        // if the paragraph is empty, the loop will not be entered at all
        if (empty()) {
-               if (style->isCommand()) {
+               if (style.isCommand()) {
                        os << '{';
                        ++column;
                }
@@ -1888,7 +1901,7 @@ bool Paragraph::latex(BufferParams const & bparams,
                                os << "}] ";
                                column +=3;
                        }
-                       if (style->isCommand()) {
+                       if (style.isCommand()) {
                                os << '{';
                                ++column;
                        }
@@ -1988,13 +2001,13 @@ bool Paragraph::latex(BufferParams const & bparams,
                if (c == ' ') {
                        // FIXME: integrate this case in latexSpecialChar
                        // Do not print the separation of the optional argument
-                       // if style->pass_thru is false. This works because
+                       // if style.pass_thru is false. This works because
                        // latexSpecialChar ignores spaces if
-                       // style->pass_thru is false.
+                       // style.pass_thru is false.
                        if (i != body_pos - 1) {
                                if (d->simpleTeXBlanks(
                                                runparams, os, texrow,
-                                               i, column, font, *style)) {
+                                               i, column, font, style)) {
                                        // A surrogate pair was output. We
                                        // must not call latexSpecialChar
                                        // in this iteration, since it would output
@@ -2006,9 +2019,9 @@ bool Paragraph::latex(BufferParams const & bparams,
                }
 
                OutputParams rp = runparams;
-               rp.free_spacing = style->free_spacing;
+               rp.free_spacing = style.free_spacing;
                rp.local_font = &font;
-               rp.intitle = style->intitle;
+               rp.intitle = style.intitle;
 
                // Two major modes:  LaTeX or plain
                // Handle here those cases common to both modes
@@ -2017,11 +2030,11 @@ bool Paragraph::latex(BufferParams const & bparams,
                        d->latexInset(bparams, os,
                                        texrow, rp, running_font,
                                        basefont, outerfont, open_font,
-                                       runningChange, *style, i, column);
+                                       runningChange, style, i, column);
                else {
                        try {
                                d->latexSpecialChar(os, rp, running_font, runningChange,
-                                       *style, i, column);
+                                       style, i, column);
                        } catch (EncodingException & e) {
                                if (runparams.dryrun) {
                                        os << "<" << _("LyX Warning: ")
@@ -2165,11 +2178,11 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 {
        bool emph_flag = false;
 
-       LayoutPtr const & style = d->layout_;
+       Layout const & style = d->layout();
        FontInfo font_old =
-               style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
+               style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
 
-       if (style->pass_thru && !d->onlyText(buf, outerfont, initial))
+       if (style.pass_thru && !d->onlyText(buf, outerfont, initial))
                os << "]]>";
 
        // parsing main loop
@@ -2192,7 +2205,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
                } else {
                        char_type c = d->text_[i];
 
-                       if (style->pass_thru)
+                       if (style.pass_thru)
                                os.put(c);
                        else
                                os << sgml::escapeChar(c);
@@ -2204,9 +2217,9 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
                os << "</emphasis>";
        }
 
-       if (style->free_spacing)
+       if (style.free_spacing)
                os << '\n';
-       if (style->pass_thru && !d->onlyText(buf, outerfont, initial))
+       if (style.pass_thru && !d->onlyText(buf, outerfont, initial))
                os << "<![CDATA[";
 }
 
@@ -2331,15 +2344,15 @@ int Paragraph::id() const
 }
 
 
-LayoutPtr const & Paragraph::layout() const
+Layout const & Paragraph::layout() const
 {
-       return d->layout_;
+       return d->layout();
 }
 
 
-void Paragraph::setLayout(LayoutPtr const & layout)
+void Paragraph::setLayout(Layout const & layout)
 {
-       d->layout_ = layout;
+       d->setLayout(layout);
 }
 
 
@@ -2378,7 +2391,7 @@ ParagraphParameters const & Paragraph::params() const
 
 bool Paragraph::isFreeSpacing() const
 {
-       if (d->layout_->free_spacing)
+       if (d->layout().free_spacing)
                return true;
        return d->inset_owner_ && d->inset_owner_->isFreeSpacing();
 }
@@ -2386,7 +2399,7 @@ bool Paragraph::isFreeSpacing() const
 
 bool Paragraph::allowEmpty() const
 {
-       if (d->layout_->keepempty)
+       if (d->layout().keepempty)
                return true;
        return d->inset_owner_ && d->inset_owner_->allowEmpty();
 }
@@ -2439,7 +2452,7 @@ int Paragraph::checkBiblio(Buffer const & buffer)
        // up this bibitem issue for 1.6. See also bug 2743.
 
        // Add bibitem insets if necessary
-       if (d->layout_->labeltype != LABEL_BIBLIO)
+       if (d->layout().labeltype != LABEL_BIBLIO)
                return 0;
 
        bool hasbibitem = !d->insetlist_.empty()
index 20e255797b7efa48848f60a2e5aaf1c33f13793e..e7fdf143a577a1167bc6d09f1f590a37fdfcc3f0 100644 (file)
@@ -17,7 +17,7 @@
 #define PARAGRAPH_H
 
 #include "FontEnums.h"
-#include "LayoutPtr.h"
+#include "Layout.h"
 
 #include "insets/InsetCode.h"
 
@@ -153,11 +153,9 @@ public:
        bool empty() const;
 
        ///
-       LayoutPtr const & layout() const;
+       Layout const & layout() const;
        ///
-       void setLayout(LayoutPtr const & layout);
-       ///
-       void setLayout(Layout const & layout) { setLayout(&layout); }
+       void setLayout(Layout const & layout);
        ///
        void setEmptyOrDefaultLayout(DocumentClass const & tc);
 
@@ -212,7 +210,7 @@ public:
        docstring const translateIfPossible(docstring const & label,
                BufferParams const & bparams) const;
        /// Expand the counters for the labelstring of \c layout
-       docstring expandLabel(LayoutPtr const &, BufferParams const &,
+       docstring expandLabel(Layout const &, BufferParams const &,
                bool process_appendix = true) const;
        /// Actual paragraph alignment used
        char getAlign() const;
index 12f387d18f37e3680a15b69552387a41cee41e99..fc71943377ce0f76c7d9140e50ecec7bfaa22a12 100644 (file)
@@ -203,7 +203,7 @@ int ParagraphMetrics::rightMargin(BufferView const & bv) const
        int const r_margin =
                bv.rightMargin()
                + fm.signedWidth(tclass.rightmargin())
-               + fm.signedWidth(par_->layout()->rightmargin)
+               + fm.signedWidth(par_->layout().rightmargin)
                * 4 / (par_->getDepth() + 4);
 
        return r_margin;
@@ -260,7 +260,7 @@ bool ParagraphMetrics::hfillExpansion(Row const & row, pos_type pos) const
        }
 
        // do not expand in some labels
-       if (par_->layout()->margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
+       if (par_->layout().margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
                return false;
 
        // if there is anything between the first char of the row and
index d0d4b261278f61fa21450865f68a4b600eacaf79..00b990c7c9414a3ebce731c03e044dad233afd21 100644 (file)
@@ -312,13 +312,13 @@ void params2string(Paragraph const & par, string & data)
        ostringstream os;
        params.write(os);
 
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        // Is alignment possible
-       os << "\\alignpossible " << layout->alignpossible << '\n';
+       os << "\\alignpossible " << layout.alignpossible << '\n';
 
        /// set default alignment
-       os << "\\aligndefault " << layout->align << '\n';
+       os << "\\aligndefault " << layout.align << '\n';
 
        /// paragraph is always in inset. This is redundant.
        os << "\\ininset " << 1 << '\n';
index 221399839059b855c407e868e9b5229025ec5ec2..bf80ba3dad0068f01c21d7997aaa6d4dbe1d3335 100644 (file)
@@ -128,9 +128,9 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                par.setLayout(bp.documentClass()[layoutname]);
 
                // Test whether the layout is obsolete.
-               LayoutPtr const & layout = par.layout();
-               if (!layout->obsoleted_by().empty())
-                       par.setLayout(bp.documentClass()[layout->obsoleted_by()]);
+               Layout const & layout = par.layout();
+               if (!layout.obsoleted_by().empty())
+                       par.setLayout(bp.documentClass()[layout.obsoleted_by()]);
 
                par.params().read(lex);
 
@@ -336,7 +336,7 @@ bool Text::empty() const
 {
        return pars_.empty() || (pars_.size() == 1 && pars_[0].empty()
                // FIXME: Should we consider the labeled type as empty too? 
-               && pars_[0].layout()->labeltype == LABEL_NO_LABEL);
+               && pars_[0].layout().labeltype == LABEL_NO_LABEL);
 }
 
 
@@ -356,12 +356,12 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
        pit_type cpit = cur.pit();
 
        DocumentClass const & tclass = cur.buffer().params().documentClass();
-       LayoutPtr const & layout = cpar.layout();
+       Layout const & layout = cpar.layout();
 
        // this is only allowed, if the current paragraph is not empty
        // or caption and if it has not the keepempty flag active
        if (cur.lastpos() == 0 && !cpar.allowEmpty() &&
-           layout->labeltype != LABEL_SENSITIVE)
+           layout.labeltype != LABEL_SENSITIVE)
                return;
 
        // a layout change may affect also the following paragraph
@@ -374,12 +374,12 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
 
        // What should the layout for the new paragraph be?
        bool keep_layout = inverse_logic ? 
-               !layout->isEnvironment() 
-               : layout->isEnvironment();
+               !layout.isEnvironment() 
+               : layout.isEnvironment();
 
        // We need to remember this before we break the paragraph, because
        // that invalidates the layout variable
-       bool sensitive = layout->labeltype == LABEL_SENSITIVE;
+       bool sensitive = layout.labeltype == LABEL_SENSITIVE;
 
        // we need to set this before we insert the paragraph.
        bool const isempty = cpar.allowEmpty() && cpar.empty();
@@ -437,7 +437,7 @@ void Text::insertChar(Cursor & cur, char_type c)
        // try to remove this
        pit_type const pit = cur.pit();
 
-       bool const freeSpacing = par.layout()->free_spacing ||
+       bool const freeSpacing = par.layout().free_spacing ||
                par.isFreeSpacing();
 
        if (lyxrc.auto_number) {
@@ -887,7 +887,7 @@ void Text::changeCase(Cursor & cur, TextCase action)
 
 bool Text::handleBibitems(Cursor & cur)
 {
-       if (cur.paragraph().layout()->labeltype != LABEL_BIBLIO)
+       if (cur.paragraph().layout().labeltype != LABEL_BIBLIO)
                return false;
 
        if (cur.pos() != 0)
@@ -1004,8 +1004,8 @@ bool Text::backspacePos0(Cursor & cur)
        // Correction: Pasting is always allowed with standard-layout
        // or the empty layout.
        else if (par.layout() == prevpar.layout()
-                || tclass.isDefaultLayout(*par.layout())
-                || tclass.isEmptyLayout(*par.layout())) {
+                || tclass.isDefaultLayout(par.layout())
+                || tclass.isEmptyLayout(par.layout())) {
                cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
                mergeParagraph(bufparams, plist, prevcur.pit());
                needsUpdate = true;
@@ -1305,7 +1305,7 @@ docstring Text::getPossibleLabel(Cursor & cur) const
 {
        pit_type pit = cur.pit();
 
-       LayoutPtr layout = pars_[pit].layout();
+       Layout const * layout = &(pars_[pit].layout());
 
        docstring text;
        docstring par_text = pars_[pit].asString(false);
@@ -1332,7 +1332,7 @@ docstring Text::getPossibleLabel(Cursor & cur) const
 
        // For section, subsection, etc...
        if (layout->latextype == LATEX_PARAGRAPH && pit != 0) {
-               LayoutPtr const & layout2 = pars_[pit - 1].layout();
+               Layout const * layout2 = &(pars_[pit - 1].layout());
                if (layout2->latextype != LATEX_PARAGRAPH) {
                        --pit;
                        layout = layout2;
index 26b62f72f677e83caa3783886b83e9bfcc7e4421..3ba4f84d558cde1e9bd2459d975260ca88e6ce9c 100644 (file)
@@ -75,17 +75,17 @@ bool Text::isMainText(Buffer const & buffer) const
 
 FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 {
-       LayoutPtr const & layout = pars_[pit].layout();
+       Layout const & layout = pars_[pit].layout();
 
        if (!pars_[pit].getDepth())  {
-               FontInfo lf = layout->resfont;
+               FontInfo lf = layout.resfont;
                // In case the default family has been customized
-               if (layout->font.family() == INHERIT_FAMILY)
+               if (layout.font.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
                return lf;
        }
 
-       FontInfo font = layout->font;
+       FontInfo font = layout.font;
        // Realize with the fonts of lesser depth.
        //font.realize(outerFont(pit, paragraphs()));
        font.realize(buffer.params().getFont().fontInfo());
@@ -96,17 +96,17 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 
 FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const
 {
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        if (!par.getDepth()) {
-               FontInfo lf = layout->reslabelfont;
+               FontInfo lf = layout.reslabelfont;
                // In case the default family has been customized
-               if (layout->labelfont.family() == INHERIT_FAMILY)
+               if (layout.labelfont.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
                return lf;
        }
 
-       FontInfo font = layout->labelfont;
+       FontInfo font = layout.labelfont;
        // Realize with the fonts of lesser depth.
        font.realize(buffer.params().getFont().fontInfo());
 
@@ -118,15 +118,15 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
                pos_type pos, Font const & fnt, Font const & display_font)
 {
        Font font = fnt;
-       LayoutPtr const & layout = pars_[pit].layout();
+       Layout const & layout = pars_[pit].layout();
 
        // Get concrete layout font to reduce against
        FontInfo layoutfont;
 
        if (pos < pars_[pit].beginOfBody())
-               layoutfont = layout->labelfont;
+               layoutfont = layout.labelfont;
        else
-               layoutfont = layout->font;
+               layoutfont = layout.font;
 
        // Realize against environment font information
        if (pars_[pit].getDepth()) {
@@ -136,7 +136,7 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
                       pars_[tp].getDepth()) {
                        tp = outerHook(tp, paragraphs());
                        if (tp != pit_type(paragraphs().size()))
-                               layoutfont.realize(pars_[tp].layout()->font);
+                               layoutfont.realize(pars_[tp].layout().font);
                }
        }
 
@@ -244,7 +244,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
 static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
                        Paragraph const & par, int max_depth)
 {
-       if (par.layout()->labeltype == LABEL_BIBLIO)
+       if (par.layout().labeltype == LABEL_BIBLIO)
                return false;
        int const depth = par.params().depth();
        if (type == Text::INC_DEPTH && depth < max_depth)
@@ -452,7 +452,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                Paragraph & par = pars_[pit];
                ParagraphParameters params = par.params();
                params.read(argument, merge);
-               par.params().apply(params, *par.layout());
+               par.params().apply(params, par.layout());
        }
 }
 
@@ -470,8 +470,7 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
        for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
             pit <= end; ++pit) {
                Paragraph & par = pars_[pit];
-               Layout const & layout = *(par.layout());
-               par.params().apply(p, layout);
+               par.params().apply(p, par.layout());
        }       
 }
 
index b77d0005a056ab58309beefd6fa124977f6b7829..ca96a4e648baa514b97b157fa5391517e2d71c05 100644 (file)
@@ -268,7 +268,7 @@ static void outline(OutlineOp mode, Cursor & cur)
 
        DocumentClass const & tc = buf.params().documentClass();
 
-       int const thistoclevel = start->layout()->toclevel;
+       int const thistoclevel = start->layout().toclevel;
        int toclevel;
 
        // Move out (down) from this section header
@@ -276,7 +276,7 @@ static void outline(OutlineOp mode, Cursor & cur)
                ++finish;
        // Seek the one (on same level) below
        for (; finish != end; ++finish) {
-               toclevel = finish->layout()->toclevel;
+               toclevel = finish->layout().toclevel;
                if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel) {
                        break;
                }
@@ -291,7 +291,7 @@ static void outline(OutlineOp mode, Cursor & cur)
                        // Search previous same-level header above
                        do {
                                --dest;
-                               toclevel = dest->layout()->toclevel;
+                               toclevel = dest->layout().toclevel;
                        } while(dest != bgn
                                && (toclevel == Layout::NOT_IN_TOC
                                    || toclevel > thistoclevel));
@@ -324,14 +324,14 @@ static void outline(OutlineOp mode, Cursor & cur)
                        pit_type const len = distance(start, finish);
                        buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
                        for (; start != finish; ++start) {
-                               toclevel = start->layout()->toclevel;
+                               toclevel = start->layout().toclevel;
                                if (toclevel == Layout::NOT_IN_TOC)
                                        continue;
                                DocumentClass::const_iterator lit = tc.begin();
                                DocumentClass::const_iterator len = tc.end();
                                for (; lit != len; ++lit) {
                                        if (lit->toclevel == toclevel + 1 &&
-                                           start->layout()->labeltype == lit->labeltype) {
+                                           start->layout().labeltype == lit->labeltype) {
                                                start->setLayout(*lit);
                                                break;
                                        }
@@ -343,14 +343,14 @@ static void outline(OutlineOp mode, Cursor & cur)
                        pit_type const len = distance(start, finish);
                        buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
                        for (; start != finish; ++start) {
-                               toclevel = start->layout()->toclevel;
+                               toclevel = start->layout().toclevel;
                                if (toclevel == Layout::NOT_IN_TOC)
                                        continue;
                                DocumentClass::const_iterator lit = tc.begin();
                                DocumentClass::const_iterator len = tc.end();
                                for (; lit != len; ++lit) {
                                        if (lit->toclevel == toclevel - 1 &&
-                                               start->layout()->labeltype == lit->labeltype) {
+                                               start->layout().labeltype == lit->labeltype) {
                                                        start->setLayout(*lit);
                                                        break;
                                        }
@@ -825,7 +825,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        /*
                        Paragraph & par = pars_[cur.pit()];
                        if (inset->lyxCode() == LABEL_CODE
-                               && par.layout()->labeltype == LABEL_COUNTER) {
+                               && par.layout().labeltype == LABEL_COUNTER) {
                                // Go to the end of the paragraph
                                // Warning: Because of Change-Tracking, the last
                                // position is 'size()' and not 'size()-1':
@@ -852,7 +852,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_SPACE_INSERT:
-               if (cur.paragraph().layout()->free_spacing)
+               if (cur.paragraph().layout().free_spacing)
                        insertChar(cur, ' ');
                else {
                        doInsertInset(cur, this, cmd, false, false);
@@ -978,7 +978,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_SERVER_GET_LAYOUT:
-               cur.message(cur.paragraph().layout()->name());
+               cur.message(cur.paragraph().layout().name());
                break;
 
        case LFUN_LAYOUT: {
@@ -986,7 +986,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                LYXERR(Debug::INFO, "LFUN_LAYOUT: (arg) " << to_utf8(layout));
 
                Paragraph const & para = cur.paragraph();
-               docstring const old_layout = para.layout()->name();
+               docstring const old_layout = para.layout().name();
                DocumentClass const & tclass = bv->buffer().params().documentClass();
 
                if (layout.empty())
@@ -1028,7 +1028,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        pit_type spit = cur.selBegin().pit();
                        pit_type epit = cur.selEnd().pit() + 1;
                        while (spit != epit) {
-                               if (pars_[spit].layout()->name() != old_layout) {
+                               if (pars_[spit].layout().name() != old_layout) {
                                        change_layout = true;
                                        break;
                                }
@@ -1073,8 +1073,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                Paragraph & par = cur.paragraph();
                pos_type pos = cur.pos();
                BufferParams const & bufparams = bv->buffer().params();
-               LayoutPtr const & style = par.layout();
-               if (!style->pass_thru
+               Layout const & style = par.layout();
+               if (!style.pass_thru
                    && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
                        // this avoids a double undo
                        // FIXME: should not be needed, ideally
@@ -1832,7 +1832,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                return true;
 
        case LFUN_BIBITEM_INSERT:
-               enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO
+               enable = (cur.paragraph().layout().labeltype == LABEL_BIBLIO
                          && cur.pos() == 0);
                break;
 
@@ -1944,7 +1944,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_OPTIONAL_INSERT:
                code = OPTARG_CODE;
                enable = cur.paragraph().insetList().count(OPTARG_CODE)
-                       < cur.paragraph().layout()->optionalargs;
+                       < cur.paragraph().layout().optionalargs;
                break;
        case LFUN_ENVIRONMENT_INSERT:
                code = BOX_CODE;
@@ -2092,7 +2092,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_OUTLINE_DOWN:
        case LFUN_OUTLINE_IN:
        case LFUN_OUTLINE_OUT:
-               enable = (cur.paragraph().layout()->toclevel != Layout::NOT_IN_TOC);
+               enable = (cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC);
                break;
 
        case LFUN_WORD_DELETE_FORWARD:
index 20181131543c52f6db23d28b4ace90a60dd0fa59..a465f123efed3b6f812a96adde041962ae99e54b 100644 (file)
@@ -14,7 +14,6 @@
 #include "FontInfo.h"
 #include "Layout.h"
 #include "LayoutEnums.h"
-#include "LayoutPtr.h"
 
 #include "insets/InsetLayout.h"
 
index fe92b38cc905f49672532905e5029ee71d813593..385c023a86dba0d7c9fc23e7899051b6d20612c8 100644 (file)
@@ -247,7 +247,7 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
 
        ParagraphList const & pars = text_->paragraphs();
        Paragraph const & par = pars[pit];
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
        Buffer const & buffer = bv_->buffer();
        // FIXME: broken?
        BufferParams const & params = buffer.params();
@@ -258,10 +258,10 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
                Font f = par.getFontSettings(params, pos);
                if (!text_->isMainText(buffer))
                        applyOuterFont(f);
-               bool lab = layout->labeltype == LABEL_MANUAL && pos < body_pos;
+               bool lab = layout.labeltype == LABEL_MANUAL && pos < body_pos;
 
-               FontInfo const & lf = lab ? layout->labelfont : layout->font;
-               FontInfo rlf = lab ? layout->reslabelfont : layout->resfont;
+               FontInfo const & lf = lab ? layout.labelfont : layout.font;
+               FontInfo rlf = lab ? layout.reslabelfont : layout.resfont;
                
                // In case the default family has been customized
                if (lf.family() == INHERIT_FAMILY)
@@ -272,7 +272,7 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
 
        // The uncommon case need not be optimized as much
        FontInfo const & layoutfont = pos < body_pos ? 
-               layout->labelfont : layout->font;
+               layout.labelfont : layout.font;
 
        Font font = par.getFontSettings(params, pos);
        font.fontInfo().realize(layoutfont);
@@ -508,10 +508,10 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
                row.x = leftMargin(max_width_, pit, row.pos());
 
        // is there a manual margin with a manual label
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
-       if (layout->margintype == MARGIN_MANUAL
-           && layout->labeltype == LABEL_MANUAL) {
+       if (layout.margintype == MARGIN_MANUAL
+           && layout.labeltype == LABEL_MANUAL) {
                /// We might have real hfills in the label part
                int nlh = numberOfLabelHfills(par, row);
 
@@ -540,7 +540,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
                // set x how you need it
                int align;
                if (par.params().align() == LYX_ALIGN_LAYOUT)
-                       align = layout->align;
+                       align = layout.align;
                else
                        align = par.params().align();
 
@@ -602,7 +602,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
                    && (body_pos > end || !par.isLineSeparator(body_pos - 1)))
                {
                        row.x += theFontMetrics(text_->labelFont(buffer, par)).
-                               width(layout->labelsep);
+                               width(layout.labelsep);
                        if (body_pos <= end)
                                row.x += row.label_hfill;
                }
@@ -680,7 +680,7 @@ static pos_type addressBreakPoint(pos_type i, Paragraph const & par)
 int TextMetrics::labelEnd(pit_type const pit) const
 {
        // labelEnd is only needed if the layout fills a flushleft label.
-       if (text_->getPar(pit).layout()->margintype != MARGIN_MANUAL)
+       if (text_->getPar(pit).layout().margintype != MARGIN_MANUAL)
                return 0;
        // return the beginning of the body
        return leftMargin(max_width_, pit);
@@ -697,9 +697,9 @@ pit_type TextMetrics::rowBreakPoint(int width, pit_type const pit,
        if (pos == end || width < 0)
                return end;
 
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
-       if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX)
+       if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX)
                return addressBreakPoint(pos, par);
 
        pos_type const body_pos = par.beginOfBody();
@@ -742,7 +742,7 @@ pit_type TextMetrics::rowBreakPoint(int width, pit_type const pit,
                if (body_pos && i == body_pos) {
                        FontMetrics const & fm = theFontMetrics(
                                text_->labelFont(buffer, par));
-                       int add = fm.width(layout->labelsep);
+                       int add = fm.width(layout.labelsep);
                        if (par.isLineSeparator(i - 1))
                                add -= singleWidth(pit, i - 1);
 
@@ -839,7 +839,7 @@ int TextMetrics::rowWidth(int right_margin, pit_type const pit,
                        if (body_pos > 0 && i == body_pos) {
                                FontMetrics const & fm = theFontMetrics(
                                        text_->labelFont(buffer, par));
-                               w += fm.width(par.layout()->labelsep);
+                               w += fm.width(par.layout().labelsep);
                                if (par.isLineSeparator(i - 1))
                                        w -= singleWidth(pit, i - 1);
                                w = max(w, label_end);
@@ -858,7 +858,7 @@ int TextMetrics::rowWidth(int right_margin, pit_type const pit,
        if (body_pos > 0 && body_pos >= end) {
                FontMetrics const & fm = theFontMetrics(
                        text_->labelFont(buffer, par));
-               w += fm.width(par.layout()->labelsep);
+               w += fm.width(par.layout().labelsep);
                if (end > 0 && par.isLineSeparator(end - 1))
                        w -= singleWidth(pit, end - 1);
                w = max(w, label_end);
@@ -880,7 +880,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
        // ok, let us initialize the maxasc and maxdesc value.
        // Only the fontsize count. The other properties
        // are taken from the layoutfont. Nicer on the screen :)
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        // as max get the first character of this row then it can
        // increase but not decrease the height. Just some point to
@@ -899,7 +899,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
        FontMetrics const & fontmetrics = theFontMetrics(font);
 
        // these are minimum values
-       double const spacing_val = layout->spacing.getValue()
+       double const spacing_val = layout.spacing.getValue()
                * text_->spacing(buffer, par);
        //lyxerr << "spacing_val = " << spacing_val << endl;
        int maxasc  = int(fontmetrics.maxAscent()  * spacing_val);
@@ -948,8 +948,8 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
                        && par.ownerCode() != ERT_CODE
                        && par.ownerCode() != LISTINGS_CODE
                        && pit > 0
-                       && ((layout->isParagraph() && par.getDepth() == 0)
-                           || (pars[pit - 1].layout()->isParagraph()
+                       && ((layout.isParagraph() && par.getDepth() == 0)
+                           || (pars[pit - 1].layout().isParagraph()
                                && pars[pit - 1].getDepth() == 0)))
                {
                                maxasc += bufparams.getDefSkip().inPixels(*bv_);
@@ -960,25 +960,25 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
 
                // 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(labelfont_metrics.maxHeight()
-                                    * layout->spacing.getValue()
+                                    * layout.spacing.getValue()
                                     * text_->spacing(buffer, par));
                }
 
                // special code for the top label
-               if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
-                    || layout->labeltype == LABEL_BIBLIO
-                    || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
+               if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
+                    || layout.labeltype == LABEL_BIBLIO
+                    || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
                    && isFirstInSequence(pit, pars)
                    && !par.labelString().empty())
                {
                        labeladdon = int(
                                  labelfont_metrics.maxHeight()
-                                       * layout->spacing.getValue()
+                                       * layout.spacing.getValue()
                                        * text_->spacing(buffer, par)
-                               + (layout->topsep + layout->labelbottomsep) * dh);
+                               + (layout.topsep + layout.labelbottomsep) * dh);
                }
 
                // Add the layout spaces, for example before and after
@@ -992,20 +992,20 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
                    && prevpar.getDepth() == par.getDepth()
                    && prevpar.getLabelWidthString()
                                        == par.getLabelWidthString()) {
-                       layoutasc = layout->itemsep * dh;
+                       layoutasc = layout.itemsep * dh;
                } else if (pit != 0 || first != 0) {
-                       if (layout->topsep > 0)
-                               layoutasc = layout->topsep * dh;
+                       if (layout.topsep > 0)
+                               layoutasc = layout.topsep * dh;
                }
 
                prev = outerHook(pit, pars);
                if (prev != pit_type(pars.size())) {
-                       maxasc += int(pars[prev].layout()->parsep * dh);
+                       maxasc += int(pars[prev].layout().parsep * dh);
                } else if (pit != 0) {
                        Paragraph const & prevpar = pars[pit - 1];
                        if (prevpar.getDepth() != 0 ||
                                        prevpar.layout() == layout) {
-                               maxasc += int(layout->parsep * dh);
+                               maxasc += int(layout.parsep * dh);
                        }
                }
        }
@@ -1022,18 +1022,18 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
                        double unusual = 0;
 
                        if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
-                               usual = pars[cpit].layout()->bottomsep * dh;
+                               usual = pars[cpit].layout().bottomsep * dh;
                                cpit = depthHook(cpit, pars, pars[nextpit].getDepth());
                                if (pars[cpit].layout() != pars[nextpit].layout()
                                        || pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
                                {
-                                       unusual = pars[cpit].layout()->bottomsep * dh;
+                                       unusual = pars[cpit].layout().bottomsep * dh;
                                }
                                layoutdesc = max(unusual, usual);
                        } else if (pars[cpit].getDepth() == pars[nextpit].getDepth()) {
                                if (pars[cpit].layout() != pars[nextpit].layout()
                                        || pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
-                                       layoutdesc = int(pars[cpit].layout()->bottomsep * dh);
+                                       layoutdesc = int(pars[cpit].layout().bottomsep * dh);
                        }
                }
        }
@@ -1079,7 +1079,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
        pos_type vc = row.pos();
        pos_type end = row.endpos();
        pos_type c = 0;
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        bool left_side = false;
 
@@ -1104,7 +1104,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
                if (body_pos > 0 && c == body_pos - 1) {
                        FontMetrics const & fm = theFontMetrics(
                                text_->labelFont(buffer, par));
-                       tmpx += row.label_hfill + fm.width(layout->labelsep);
+                       tmpx += row.label_hfill + fm.width(layout.labelsep);
                        if (par.isLineSeparator(body_pos - 1))
                                tmpx -= singleWidth(pit, body_pos - 1);
                }
@@ -1538,7 +1538,7 @@ int TextMetrics::cursorX(CursorSlice const & sl,
                if (body_pos > 0 && pos == body_pos - 1) {
                        FontMetrics const & labelfm = theFontMetrics(
                                text_->labelFont(buffer, par));
-                       x += row.label_hfill + labelfm.width(par.layout()->labelsep);
+                       x += row.label_hfill + labelfm.width(par.layout().labelsep);
                        if (par.isLineSeparator(body_pos - 1))
                                x -= singleWidth(pit, body_pos - 1);
                }
@@ -1700,9 +1700,9 @@ int TextMetrics::leftMargin(int max_width,
        Buffer const & buffer = bv_->buffer();
        //lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
        DocumentClass const & tclass = buffer.params().documentClass();
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
-       docstring parindent = layout->parindent;
+       docstring parindent = layout.parindent;
 
        int l_margin = 0;
 
@@ -1716,15 +1716,15 @@ int TextMetrics::leftMargin(int max_width,
                // find the next level paragraph
                pit_type newpar = outerHook(pit, pars);
                if (newpar != pit_type(pars.size())) {
-                       if (pars[newpar].layout()->isEnvironment()) {
+                       if (pars[newpar].layout().isEnvironment()) {
                                l_margin = leftMargin(max_width, newpar);
                        }
-                       if (tclass.isDefaultLayout(*par.layout()) 
-                           || tclass.isEmptyLayout(*par.layout())) {
+                       if (tclass.isDefaultLayout(par.layout()) 
+                           || tclass.isEmptyLayout(par.layout())) {
                                if (pars[newpar].params().noindent())
                                        parindent.erase();
                                else
-                                       parindent = pars[newpar].layout()->parindent;
+                                       parindent = pars[newpar].layout().parindent;
                        }
                }
        }
@@ -1732,34 +1732,34 @@ int TextMetrics::leftMargin(int max_width,
        // This happens after sections in standard classes. The 1.3.x
        // code compared depths too, but it does not seem necessary
        // (JMarc)
-       if (tclass.isDefaultLayout(*par.layout())
-           && pit > 0 && pars[pit - 1].layout()->nextnoindent)
+       if (tclass.isDefaultLayout(par.layout())
+           && pit > 0 && pars[pit - 1].layout().nextnoindent)
                parindent.erase();
 
        FontInfo const labelfont = text_->labelFont(buffer, par);
        FontMetrics const & labelfont_metrics = theFontMetrics(labelfont);
 
-       switch (layout->margintype) {
+       switch (layout.margintype) {
        case MARGIN_DYNAMIC:
-               if (!layout->leftmargin.empty()) {
+               if (!layout.leftmargin.empty()) {
                        l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
-                               layout->leftmargin);
+                               layout.leftmargin);
                }
                if (!par.labelString().empty()) {
-                       l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+                       l_margin += labelfont_metrics.signedWidth(layout.labelindent);
                        l_margin += labelfont_metrics.width(par.labelString());
-                       l_margin += labelfont_metrics.width(layout->labelsep);
+                       l_margin += labelfont_metrics.width(layout.labelsep);
                }
                break;
 
        case MARGIN_MANUAL: {
-               l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+               l_margin += labelfont_metrics.signedWidth(layout.labelindent);
                // The width of an empty par, even with manual label, should be 0
                if (!par.empty() && pos >= par.beginOfBody()) {
                        if (!par.getLabelWidthString().empty()) {
                                docstring labstr = par.getLabelWidthString();
                                l_margin += labelfont_metrics.width(labstr);
-                               l_margin += labelfont_metrics.width(layout->labelsep);
+                               l_margin += labelfont_metrics.width(layout.labelsep);
                        }
                }
                break;
@@ -1767,30 +1767,30 @@ int TextMetrics::leftMargin(int max_width,
 
        case MARGIN_STATIC: {
                l_margin += theFontMetrics(buffer.params().getFont()).
-                       signedWidth(layout->leftmargin) * 4     / (par.getDepth() + 4);
+                       signedWidth(layout.leftmargin) * 4      / (par.getDepth() + 4);
                break;
        }
 
        case MARGIN_FIRST_DYNAMIC:
-               if (layout->labeltype == LABEL_MANUAL) {
+               if (layout.labeltype == LABEL_MANUAL) {
                        if (pos >= par.beginOfBody()) {
-                               l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
+                               l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
                        } else {
-                               l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+                               l_margin += labelfont_metrics.signedWidth(layout.labelindent);
                        }
                } else if (pos != 0
                           // Special case to fix problems with
                           // theorems (JMarc)
-                          || (layout->labeltype == LABEL_STATIC
-                              && layout->latextype == LATEX_ENVIRONMENT
+                          || (layout.labeltype == LABEL_STATIC
+                              && layout.latextype == LATEX_ENVIRONMENT
                               && !isFirstInSequence(pit, pars))) {
-                       l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
-               } else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
-                          && layout->labeltype != LABEL_BIBLIO
-                          && layout->labeltype !=
+                       l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
+               } else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
+                          && layout.labeltype != LABEL_BIBLIO
+                          && layout.labeltype !=
                           LABEL_CENTERED_TOP_ENVIRONMENT) {
-                       l_margin += labelfont_metrics.signedWidth(layout->labelindent);
-                       l_margin += labelfont_metrics.width(layout->labelsep);
+                       l_margin += labelfont_metrics.signedWidth(layout.labelindent);
+                       l_margin += labelfont_metrics.width(layout.labelsep);
                        l_margin += labelfont_metrics.width(par.labelString());
                }
                break;
@@ -1806,7 +1806,7 @@ int TextMetrics::leftMargin(int max_width,
                for ( ; rit != end; ++rit)
                        if (rit->fill() < minfill)
                                minfill = rit->fill();
-               l_margin += theFontMetrics(params.getFont()).signedWidth(layout->leftmargin);
+               l_margin += theFontMetrics(params.getFont()).signedWidth(layout.leftmargin);
                l_margin += minfill;
 #endif
                // also wrong, but much shorter.
@@ -1821,17 +1821,17 @@ int TextMetrics::leftMargin(int max_width,
        LyXAlignment align;
 
        if (par.params().align() == LYX_ALIGN_LAYOUT)
-               align = layout->align;
+               align = layout.align;
        else
                align = par.params().align();
 
        // set the correct parindent
        if (pos == 0
-           && (layout->labeltype == LABEL_NO_LABEL
-              || layout->labeltype == LABEL_TOP_ENVIRONMENT
-              || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
-              || (layout->labeltype == LABEL_STATIC
-                  && layout->latextype == LATEX_ENVIRONMENT
+           && (layout.labeltype == LABEL_NO_LABEL
+              || layout.labeltype == LABEL_TOP_ENVIRONMENT
+              || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
+              || (layout.labeltype == LABEL_STATIC
+                  && layout.latextype == LATEX_ENVIRONMENT
                   && !isFirstInSequence(pit, pars)))
            && align == LYX_ALIGN_BLOCK
            && !par.params().noindent()
@@ -1841,8 +1841,8 @@ int TextMetrics::leftMargin(int max_width,
            && !(!par.empty()
                    && par.isInset(pos)
                    && par.getInset(pos)->display())
-                       && ((tclass.isDefaultLayout(*par.layout()) 
-                || tclass.isEmptyLayout(*par.layout()))
+                       && ((tclass.isDefaultLayout(par.layout()) 
+                || tclass.isEmptyLayout(par.layout()))
                || buffer.params().paragraph_separation == BufferParams::PARSEP_INDENT)
            )
        {
index 9e558aab3050a338c89e72f433b5b1cad1400c92..1964147977395f25256dee7d668aa3c30eb1ee5a 100644 (file)
@@ -132,7 +132,7 @@ void TocBackend::updateItem(ParConstIterator const & par_it)
                }
        }
 
-       int const toclevel = toc_item->par_it_->layout()->toclevel;
+       int const toclevel = toc_item->par_it_->layout().toclevel;
        if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
                && tocstring.empty())
                        tocstring = toc_item->par_it_->asString(true);
@@ -181,7 +181,7 @@ void TocBackend::update()
                }
 
                /// now the toc entry for the paragraph
-               int const toclevel = pit->layout()->toclevel;
+               int const toclevel = pit->layout().toclevel;
                if (toclevel != Layout::NOT_IN_TOC
                    && toclevel >= min_toclevel) {
                        // insert this into the table of contents
index 2f12d6db9121a1fd6f063e80c443f8aad7b3a165..41b59a5b1cb30ebd58a52bd95256ffff628cd322 100644 (file)
@@ -25,7 +25,6 @@
 #include "Language.h"
 #include "LaTeX.h"
 #include "Layout.h"
-#include "LayoutPtr.h"
 #include "LyX.h"
 #include "TextClass.h"
 #include "Paragraph.h"
@@ -233,7 +232,7 @@ depth_type getDepth(DocIterator const & it)
 depth_type getItemDepth(ParIterator const & it)
 {
        Paragraph const & par = *it;
-       LabelType const labeltype = par.layout()->labeltype;
+       LabelType const labeltype = par.layout().labeltype;
 
        if (labeltype != LABEL_ENUMERATE && labeltype != LABEL_ITEMIZE)
                return 0;
@@ -257,7 +256,7 @@ depth_type getItemDepth(ParIterator const & it)
                // that is not more deeply nested.
                Paragraph & prev_par = *prev_it;
                depth_type const prev_depth = getDepth(prev_it);
-               if (labeltype == prev_par.layout()->labeltype) {
+               if (labeltype == prev_par.layout().labeltype) {
                        if (prev_depth < min_depth)
                                return prev_par.itemdepth + 1;
                        if (prev_depth == min_depth)
@@ -275,14 +274,14 @@ depth_type getItemDepth(ParIterator const & it)
 bool needEnumCounterReset(ParIterator const & it)
 {
        Paragraph const & par = *it;
-       BOOST_ASSERT(par.layout()->labeltype == LABEL_ENUMERATE);
+       BOOST_ASSERT(par.layout().labeltype == LABEL_ENUMERATE);
        depth_type const cur_depth = par.getDepth();
        ParIterator prev_it = it;
        while (prev_it.pit()) {
                --prev_it.top().pit();
                Paragraph const & prev_par = *prev_it;
                if (prev_par.getDepth() <= cur_depth)
-                       return  prev_par.layout()->labeltype != LABEL_ENUMERATE;
+                       return  prev_par.layout().labeltype != LABEL_ENUMERATE;
        }
        // start of nested inset: reset
        return true;
@@ -294,7 +293,7 @@ void setLabel(Buffer const & buf, ParIterator & it)
 {
        DocumentClass const & textclass = buf.params().documentClass();
        Paragraph & par = it.paragraph();
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
        Counters & counters = textclass.counters();
 
        if (par.params().startOfAppendix()) {
@@ -308,19 +307,19 @@ void setLabel(Buffer const & buf, ParIterator & it)
        // Compute the item depth of the paragraph
        par.itemdepth = getItemDepth(it);
 
-       if (layout->margintype == MARGIN_MANUAL) {
+       if (layout.margintype == MARGIN_MANUAL) {
                if (par.params().labelWidthString().empty())
-                       par.params().labelWidthString(par.translateIfPossible(layout->labelstring(), buf.params()));
+                       par.params().labelWidthString(par.translateIfPossible(layout.labelstring(), buf.params()));
        } else {
                par.params().labelWidthString(docstring());
        }
 
-       switch(layout->labeltype) {
+       switch(layout.labeltype) {
        case LABEL_COUNTER:
-               if (layout->toclevel <= buf.params().secnumdepth
-                   && (layout->latextype != LATEX_ENVIRONMENT
+               if (layout.toclevel <= buf.params().secnumdepth
+                   && (layout.latextype != LATEX_ENVIRONMENT
                        || isFirstInSequence(it.pit(), it.plist()))) {
-                       counters.step(layout->counter);
+                       counters.step(layout.counter);
                        par.params().labelString(
                                par.expandLabel(layout, buf.params()));
                } else
@@ -434,7 +433,7 @@ void setLabel(Buffer const & buf, ParIterator & it)
        case LABEL_STATIC:      
        case LABEL_BIBLIO:
                par.params().labelString(
-                       par.translateIfPossible(layout->labelstring(), 
+                       par.translateIfPossible(layout.labelstring(), 
                                                buf.params()));
                break;
        }
index 49465a7ef06ec5cd53bf8536cc5fa179425a6fcd..357d36bc736a339af8f460ba2d91e4a225cf49e8 100644 (file)
@@ -327,13 +327,13 @@ bool GuiParagraph::canIndent() const
 
 LyXAlignment GuiParagraph::alignPossible() const
 {
-       return bufferview()->cursor().innerParagraph().layout()->alignpossible;
+       return bufferview()->cursor().innerParagraph().layout().alignpossible;
 }
 
 
 LyXAlignment GuiParagraph::alignDefault() const
 {
-       return bufferview()->cursor().innerParagraph().layout()->align;
+       return bufferview()->cursor().innerParagraph().layout().align;
 }
 
 
index 7135b9b6b3e9511d8c258afd6c42518594fc9a59..e2a060a696a57b9a4841d1a22a8040afae40bcfa 100644 (file)
@@ -620,7 +620,7 @@ void GuiLayoutBox::updateContents(bool reset)
        Inset const * inset = 
        owner_.view()->cursor().innerParagraph().inInset();
        if (!reset && text_class_ == text_class && inset_ == inset) {
-               set(owner_.view()->cursor().innerParagraph().layout()->name());
+               set(owner_.view()->cursor().innerParagraph().layout().name());
                return;
        }
 
@@ -644,7 +644,7 @@ void GuiLayoutBox::updateContents(bool reset)
                addItemSort(name, lyxrc.sort_layouts);
        }
 
-       set(owner_.view()->cursor().innerParagraph().layout()->name());
+       set(owner_.view()->cursor().innerParagraph().layout().name());
 
        // needed to recalculate size hint
        hide();
index 0dc7aa66998066c69efda6fb531d65d24d1edca2..c40dc08d43fa196ec58c9325917344a4898f2c98 100644 (file)
@@ -52,7 +52,7 @@ void InsetFoot::updateLabels(ParIterator const & it)
        Counters & cnts = tclass.counters();
        docstring const foot = from_ascii("footnote");
        Paragraph const & outer =  it.paragraph();
-       if (!outer.layout()->intitle && cnts.hasCounter(foot)) {
+       if (!outer.layout().intitle && cnts.hasCounter(foot)) {
                cnts.step(foot);
                // FIXME: the counter should format itself.
                setLabel(support::bformat(from_ascii("%1$s %2$s"), 
index 2ae41303a2496b6a3056773893c5e8ff2ba0385b..95cc549d555480e29c8c20b2a8beb4037b24447e 100644 (file)
@@ -142,7 +142,7 @@ void InsetText::clear()
        ParagraphList & pars = paragraphs();
 
        // This is a gross hack...
-       LayoutPtr old_layout = pars.begin()->layout();
+       Layout old_layout = pars.begin()->layout();
 
        pars.clear();
        pars.push_back(Paragraph());
index 52d5452cdc3b717534eaa6289a4f4960265bc11a..8facb40d68d65ee852e3eb31e69063d67d44e1a3 100644 (file)
@@ -39,7 +39,7 @@ InsetMathMBox::InsetMathMBox()
 }
 
 
-InsetMathMBox::InsetMathMBox(LayoutPtr const & layout)
+InsetMathMBox::InsetMathMBox(Layout const & layout)
 {
        text_.paragraphs().clear();
        text_.paragraphs().push_back(Paragraph());
index 6d9091d9a0a003e4ed3edd105935419022483d07..6d3529bd33378bcb46ee4dd125b18a5a17f1cda0 100644 (file)
@@ -31,7 +31,7 @@ class InsetMathMBox : public InsetMath {
 public:
        ///
        explicit InsetMathMBox();
-       explicit InsetMathMBox(LayoutPtr const & layout);
+       explicit InsetMathMBox(Layout const & layout);
 
        /// this stores metrics information in cache_
        void metrics(MetricsInfo & mi, Dimension & dim) const;
index 87e63506a8d1ffe824f9f2452214bed8f9dc0a3f..2b8d6a0384b467213b12014f4bdc9fc53662e189 100644 (file)
@@ -43,7 +43,7 @@ ParagraphList::const_iterator searchParagraph(
        ParagraphList::const_iterator p,
   ParagraphList::const_iterator const & pend)
 {
-       for (++p; p != pend && p->layout()->latextype == LATEX_PARAGRAPH; ++p)
+       for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p)
                ;
 
        return p;
@@ -54,12 +54,12 @@ ParagraphList::const_iterator searchCommand(
                ParagraphList::const_iterator p,
                ParagraphList::const_iterator const & pend)
 {
-       LayoutPtr const & bstyle = p->layout();
+       Layout const & bstyle = p->layout();
 
        for (++p; p != pend; ++p) {
-               LayoutPtr const & style = p->layout();
-               if (style->latextype == LATEX_COMMAND
-                               && style->commanddepth <= bstyle->commanddepth)
+               Layout const & style = p->layout();
+               if (style.latextype == LATEX_COMMAND
+                               && style.commanddepth <= bstyle.commanddepth)
                        return p;
        }
        return pend;
@@ -70,14 +70,14 @@ ParagraphList::const_iterator searchEnvironment(
                ParagraphList::const_iterator p,
                ParagraphList::const_iterator const & pend)
 {
-       LayoutPtr const & bstyle = p->layout();
+       Layout const & bstyle = p->layout();
        size_t const depth = p->params().depth();
        for (++p; p != pend; ++p) {
-               LayoutPtr const & style = p->layout();
-               if (style->latextype == LATEX_COMMAND)
+               Layout const & style = p->layout();
+               if (style.latextype == LATEX_COMMAND)
                        return p;
 
-               if (style->latextype == LATEX_PARAGRAPH) {
+               if (style.latextype == LATEX_PARAGRAPH) {
                        if (p->params().depth() > depth)
                                continue;
                        return p;
@@ -86,7 +86,7 @@ ParagraphList::const_iterator searchEnvironment(
                if (p->params().depth() < depth)
                        return p;
 
-               if (style->latexname() != bstyle->latexname()
+               if (style.latexname() != bstyle.latexname()
                                && p->params().depth() == depth)
                        return p;
        }
@@ -104,7 +104,7 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf,
        for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
                if (par != pbegin)
                        os << '\n';
-               if (buf.params().documentClass().isDefaultLayout(*par->layout()) 
+               if (buf.params().documentClass().isDefaultLayout(par->layout()) 
                    && par->emptyTag()) {
                        par->simpleDocBookOnePar(buf, os, runparams, 
                                        outerFont(distance(paragraphs.begin(), par), paragraphs));
@@ -128,50 +128,50 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        ParagraphList::const_iterator par = pbegin;
 
        Layout const & defaultstyle = buf.params().documentClass().defaultLayout();
-       LayoutPtr const & bstyle = par->layout();
+       Layout const & bstyle = par->layout();
        string item_tag;
 
        // Opening outter tag
        sgml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
-       if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
+       if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
                os << "<![CDATA[";
 
        while (par != pend) {
-               LayoutPtr const & style = par->layout();
+               Layout const & style = par->layout();
                ParagraphList::const_iterator send;
                string id = par->getID(buf, runparams);
                string wrapper = "";
                pos_type sep = 0;
 
                // Opening inner tag
-               switch (bstyle->latextype) {
+               switch (bstyle.latextype) {
                case LATEX_ENVIRONMENT:
-                       if (!bstyle->innertag().empty()) {
-                               sgml::openTag(os, bstyle->innertag(), id);
+                       if (!bstyle.innertag().empty()) {
+                               sgml::openTag(os, bstyle.innertag(), id);
                        }
                        break;
 
                case LATEX_ITEM_ENVIRONMENT:
-                       if (!bstyle->labeltag().empty()) {
-                               sgml::openTag(os, bstyle->innertag(), id);
-                               sgml::openTag(os, bstyle->labeltag());
+                       if (!bstyle.labeltag().empty()) {
+                               sgml::openTag(os, bstyle.innertag(), id);
+                               sgml::openTag(os, bstyle.labeltag());
                                sep = par->firstWord(os, runparams) + 1;
-                               sgml::closeTag(os, bstyle->labeltag());
+                               sgml::closeTag(os, bstyle.labeltag());
                        }
                        wrapper = defaultstyle.latexname();
                        // If a sub list (embedded list) appears next with a
                        // different depth, then there is no need to open
                        // another tag at the current depth.
                        if(par->params().depth() == pbegin->params().depth()) {
-                               sgml::openTag(os, bstyle->itemtag());
+                               sgml::openTag(os, bstyle.itemtag());
                        }
                        break;
                default:
                        break;
                }
 
-               switch (style->latextype) {
+               switch (style.latextype) {
                case LATEX_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT: {
                        if (par->params().depth() == pbegin->params().depth()) {
@@ -195,10 +195,10 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                }
 
                // Closing inner tag
-               switch (bstyle->latextype) {
+               switch (bstyle.latextype) {
                case LATEX_ENVIRONMENT:
-                       if (!bstyle->innertag().empty()) {
-                               sgml::closeTag(os, bstyle->innertag());
+                       if (!bstyle.innertag().empty()) {
+                               sgml::closeTag(os, bstyle.innertag());
                                os << '\n';
                        }
                        break;
@@ -212,17 +212,17 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                        // when par == pend but at the same time that the
                        // current tag is closed.
                        if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) {
-                               sgml::closeTag(os, bstyle->itemtag());
+                               sgml::closeTag(os, bstyle.itemtag());
                        }
-                       if (!bstyle->labeltag().empty())
-                               sgml::closeTag(os, bstyle->innertag());
+                       if (!bstyle.labeltag().empty())
+                               sgml::closeTag(os, bstyle.innertag());
                        break;
                default:
                        break;
                }
        }
 
-       if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
+       if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
                os << "]]>";
 
        // Closing outter tag
@@ -240,32 +240,32 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
                                          ParagraphList::const_iterator const & pend)
 {
        ParagraphList::const_iterator par = pbegin;
-       LayoutPtr const & bstyle = par->layout();
+       Layout const & bstyle = par->layout();
 
        //Open outter tag
        sgml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
 
        // Label around sectioning number:
-       if (!bstyle->labeltag().empty()) {
-               sgml::openTag(os, bstyle->labeltag());
+       if (!bstyle.labeltag().empty()) {
+               sgml::openTag(os, bstyle.labeltag());
                // We don't care about appendix in DOCBOOK.
                os << par->expandLabel(bstyle, buf.params(), false);
-               sgml::closeTag(os, bstyle->labeltag());
+               sgml::closeTag(os, bstyle.labeltag());
        }
 
        // Opend inner tag and  close inner tags
-       sgml::openTag(os, bstyle->innertag());
+       sgml::openTag(os, bstyle.innertag());
        par->simpleDocBookOnePar(buf, os, runparams,  outerFont(distance(paragraphs.begin(), par), paragraphs));
-       sgml::closeTag(os, bstyle->innertag());
+       sgml::closeTag(os, bstyle.innertag());
        os << '\n';
 
        ++par;
        while (par != pend) {
-               LayoutPtr const & style = par->layout();
+               Layout const & style = par->layout();
                ParagraphList::const_iterator send;
 
-               switch (style->latextype) {
+               switch (style.latextype) {
                case LATEX_COMMAND: {
                        send = searchCommand(par, pend);
                        par = makeCommand(buf, os, runparams, paragraphs, par,send);
@@ -314,11 +314,11 @@ void docbookParagraphs(ParagraphList const & paragraphs,
        }
 
        while (par != pend) {
-               LayoutPtr const & style = par->layout();
+               Layout const & style = par->layout();
                ParagraphList::const_iterator lastpar = par;
                ParagraphList::const_iterator send;
 
-               switch (style->latextype) {
+               switch (style.latextype) {
                case LATEX_COMMAND: {
                        send = searchCommand(par, pend);
                        par = makeCommand(buf, os, runparams, paragraphs, par,send);
index c1d3000077a4d2fc6d5b609b0d6ee1e08a4c378e..36e74e83cd5ab42ee6e64f26a5de94e6e70ab259 100644 (file)
@@ -83,7 +83,7 @@ TeXDeeper(Buffer const & buf,
 
        while (par != paragraphs.end() &&
                     par->params().depth() == pit->params().depth()) {
-               if (par->layout()->isEnvironment()) {
+               if (par->layout().isEnvironment()) {
                        par = TeXEnvironment(buf, text, par,
                                             os, texrow, runparams);
                } else {
@@ -108,8 +108,8 @@ TeXEnvironment(Buffer const & buf,
 
        BufferParams const & bparams = buf.params();
 
-       LayoutPtr const & style = pit->forceEmptyLayout() ?
-               &bparams.documentClass().emptyLayout() : pit->layout();
+       Layout const & style = pit->forceEmptyLayout() ?
+               bparams.documentClass().emptyLayout() : pit->layout();
 
        ParagraphList const & paragraphs = text.paragraphs();
 
@@ -155,25 +155,25 @@ TeXEnvironment(Buffer const & buf,
                leftindent_open = true;
        }
 
-       if (style->isEnvironment()) {
-               os << "\\begin{" << from_ascii(style->latexname()) << '}';
-               if (style->optionalargs > 0) {
+       if (style.isEnvironment()) {
+               os << "\\begin{" << from_ascii(style.latexname()) << '}';
+               if (style.optionalargs > 0) {
                        int ret = latexOptArgInsets(*pit, os, runparams,
-                                                   style->optionalargs);
+                                                   style.optionalargs);
                        while (ret > 0) {
                                texrow.newline();
                                --ret;
                        }
                }
-               if (style->latextype == LATEX_LIST_ENVIRONMENT) {
+               if (style.latextype == LATEX_LIST_ENVIRONMENT) {
                        os << '{'
                           << pit->params().labelWidthString()
                           << "}\n";
-               } else if (style->labeltype == LABEL_BIBLIO) {
+               } else if (style.labeltype == LABEL_BIBLIO) {
                        // ale970405
                        os << '{' << bibitemWidest(buf) << "}\n";
                } else
-                       os << from_ascii(style->latexparam()) << '\n';
+                       os << from_ascii(style.latexparam()) << '\n';
                texrow.newline();
        }
 
@@ -199,7 +199,7 @@ TeXEnvironment(Buffer const & buf,
                        os << '\n';
                        texrow.newline();
                } else if (par->params().depth() > pit->params().depth()) {
-                       if (par->layout()->isParagraph()) {
+                       if (par->layout().isParagraph()) {
                          // Thinko!
                          // How to handle this? (Lgb)
                          //&& !suffixIs(os, "\n\n")
@@ -234,8 +234,8 @@ TeXEnvironment(Buffer const & buf,
                open_encoding_ = none;
        }
 
-       if (style->isEnvironment()) {
-               os << "\\end{" << from_ascii(style->latexname()) << "}\n";
+       if (style.isEnvironment()) {
+               os << "\\end{" << from_ascii(style.latexname()) << "}\n";
                texrow.newline();
        }
 
@@ -308,11 +308,11 @@ TeXOnePar(Buffer const & buf,
        // was forceDefaultParagraphs()?
        // In an inset with unlimited length (all in one row),
        // force layout to default
-       LayoutPtr const style = pit->forceEmptyLayout() ?
-               &bparams.documentClass().emptyLayout() : pit->layout();
+       Layout const style = pit->forceEmptyLayout() ?
+               bparams.documentClass().emptyLayout() : pit->layout();
 
        OutputParams runparams = runparams_in;
-       runparams.moving_arg |= style->needprotect;
+       runparams.moving_arg |= style.needprotect;
 
        bool const maintext = text.isMainText(buf);
        // we are at the beginning of an inset and CJK is already open.
@@ -339,7 +339,7 @@ TeXOnePar(Buffer const & buf,
 
        if (par_language->babel() != prev_language->babel()
            // check if we already put language command in TeXEnvironment()
-           && !(style->isEnvironment()
+           && !(style.isEnvironment()
                 && (pit == paragraphs.begin() ||
                     (boost::prior(pit)->layout() != pit->layout() &&
                      boost::prior(pit)->getDepth() <= pit->getDepth())
@@ -493,27 +493,27 @@ TeXOnePar(Buffer const & buf,
                        texrow.newline();
                }
 
-               if (style->isCommand()) {
+               if (style.isCommand()) {
                        os << '\n';
                        texrow.newline();
                }
        }
 
-       switch (style->latextype) {
+       switch (style.latextype) {
        case LATEX_COMMAND:
-               os << '\\' << from_ascii(style->latexname());
+               os << '\\' << from_ascii(style.latexname());
 
                // Separate handling of optional argument inset.
-               if (style->optionalargs > 0) {
+               if (style.optionalargs > 0) {
                        int ret = latexOptArgInsets(*pit, os, runparams,
-                                                   style->optionalargs);
+                                                   style.optionalargs);
                        while (ret > 0) {
                                texrow.newline();
                                --ret;
                        }
                }
                else
-                       os << from_ascii(style->latexparam());
+                       os << from_ascii(style.latexparam());
                break;
        case LATEX_ITEM_ENVIRONMENT:
        case LATEX_LIST_ENVIRONMENT:
@@ -548,9 +548,9 @@ TeXOnePar(Buffer const & buf,
                 ? pit->getLayoutFont(bparams, outerfont)
                 : pit->getFont(bparams, pit->size() - 1, outerfont);
 
-       bool is_command = style->isCommand();
+       bool is_command = style.isCommand();
 
-       if (style->resfont.size() != font.fontInfo().size()
+       if (style.resfont.size() != font.fontInfo().size()
            && boost::next(pit) != paragraphs.end()
            && !is_command) {
                if (!need_par)
@@ -562,7 +562,7 @@ TeXOnePar(Buffer const & buf,
                os << '}';
 
        bool pending_newline = false;
-       switch (style->latextype) {
+       switch (style.latextype) {
        case LATEX_ITEM_ENVIRONMENT:
        case LATEX_LIST_ENVIRONMENT:
                if (boost::next(pit) != paragraphs.end()
@@ -574,8 +574,7 @@ TeXOnePar(Buffer const & buf,
                // skip it otherwise fall through
                ParagraphList::const_iterator next = boost::next(pit);
 
-               if (next != paragraphs.end()
-                   && (next->layout() != pit->layout()
+               if (next != paragraphs.end() && (next->layout() != pit->layout()
                        || next->params().depth() != pit->params().depth()))
                        break;
        }
@@ -659,16 +658,16 @@ TeXOnePar(Buffer const & buf,
        // also if the next paragraph is a multilingual environment (because of nesting)
        if (boost::next(pit) != paragraphs.end() && open_encoding_ == CJK &&
            (boost::next(pit)->getParLanguage(bparams)->encoding()->package() != Encoding::CJK ||
-            boost::next(pit)->layout()->isEnvironment() && boost::next(pit)->isMultiLingual(bparams))
+            boost::next(pit)->layout().isEnvironment() && boost::next(pit)->isMultiLingual(bparams))
             // in environments, CJK has to be closed later (nesting!)
-            && !style->isEnvironment()) {
+            && !style.isEnvironment()) {
                os << "\\end{CJK}\n";
                open_encoding_ = none;
        }
 
        // If this is the last paragraph, close the CJK environment
        // if necessary. If it's an environment, we'll have to \end that first.
-       if (boost::next(pit) == paragraphs.end() && !style->isEnvironment()) {
+       if (boost::next(pit) == paragraphs.end() && !style.isEnvironment()) {
                switch (open_encoding_) {
                        case CJK: {
                                // end of main text
@@ -789,11 +788,11 @@ void latexParagraphs(Buffer const & buf,
                // any environment other than the default layout of the
                // text class to be valid!
                if (par->allowParagraphCustomization()) {
-                       LayoutPtr const & layout = par->forceEmptyLayout() ?
-                                       &tclass.emptyLayout() :
+                       Layout const & layout = par->forceEmptyLayout() ?
+                                       tclass.emptyLayout() :
                                        par->layout();
 
-                       if (layout->intitle) {
+                       if (layout.intitle) {
                                if (already_title) {
                                        lyxerr << "Error in latexParagraphs: You"
                                                " should not mix title layouts"
@@ -821,10 +820,10 @@ void latexParagraphs(Buffer const & buf,
                                was_title = false;
                        }
 
-                       if (layout->is_environment) {
+                       if (layout.is_environment) {
                                par = TeXOnePar(buf, text, par, os, texrow,
                                                runparams, everypar);
-                       } else if (layout->isEnvironment() ||
+                       } else if (layout.isEnvironment() ||
                                   !par->params().leftIndent().zero()) {
                                par = TeXEnvironment(buf, text, par, os,
                                                     texrow, runparams);
index f28a046ab5b42ff804630e2887d37a7fa9fcb3ef..09d7a3847cbeedf87230b3c00b8b6d6a6491bb65 100644 (file)
@@ -77,7 +77,7 @@ void writePlaintextParagraph(Buffer const & buf,
        depth_type depth = par.params().depth();
 
        // First write the layout
-       string const tmp = to_utf8(par.layout()->name());
+       string const tmp = to_utf8(par.layout().name());
        if (compare_ascii_no_case(tmp, "itemize") == 0) {
                ltype = 1;
                ltype_depth = depth + 1;
index e8241050b07b470a0bc76ddd4f21f543801f5d06..625d258d7d7271e3ac5c82d4107f00d1864a5006 100644 (file)
@@ -264,8 +264,8 @@ int getEndLabel(pit_type p, ParagraphList const & pars)
        pit_type pit = p;
        depth_type par_depth = pars[p].getDepth();
        while (pit != pit_type(pars.size())) {
-               LayoutPtr const & layout = pars[pit].layout();
-               int const endlabeltype = layout->endlabeltype;
+               Layout const & layout = pars[pit].layout();
+               int const endlabeltype = layout.endlabeltype;
 
                if (endlabeltype != END_LABEL_NO_LABEL) {
                        if (p + 1 == pit_type(pars.size()))
@@ -299,7 +299,7 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars)
               && !tmpfont.resolved()) {
                par_offset = outerHook(par_offset, pars);
                if (par_offset != pit_type(pars.size())) {
-                       tmpfont.realize(pars[par_offset].layout()->font);
+                       tmpfont.realize(pars[par_offset].layout().font);
                        par_depth = pars[par_offset].getDepth();
                }
        }
index 7fb154abaa711f281f050a5ccc24081db745d943..335b2941c6192dfb7b55297b5a8c2ca9cec3e28e 100644 (file)
@@ -474,16 +474,16 @@ void RowPainter::paintFirst()
 
        Buffer const & buffer = pi_.base.bv->buffer();
 
-       LayoutPtr const & layout = par_.layout();
+       Layout const & layout = par_.layout();
 
        if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
                if (pit_ != 0) {
-                       if (layout->latextype == LATEX_PARAGRAPH
+                       if (layout.latextype == LATEX_PARAGRAPH
                                && !par_.getDepth()) {
                                y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
                        } else {
-                               LayoutPtr const & playout = pars_[pit_ - 1].layout();
-                               if (playout->latextype == LATEX_PARAGRAPH
+                               Layout const & playout = pars_[pit_ - 1].layout();
+                               if (playout.latextype == LATEX_PARAGRAPH
                                        && !pars_[pit_ - 1].getDepth()) {
                                        // is it right to use defskip here, too? (AS)
                                        y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
@@ -497,9 +497,9 @@ void RowPainter::paintFirst()
        //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
 
        // should we print a label?
-       if (layout->labeltype >= LABEL_STATIC
-           && (layout->labeltype != LABEL_STATIC
-                     || layout->latextype != LATEX_ENVIRONMENT
+       if (layout.labeltype >= LABEL_STATIC
+           && (layout.labeltype != LABEL_STATIC
+                     || layout.latextype != LATEX_ENVIRONMENT
                      || is_seq)) {
 
                FontInfo const font = labelFont();
@@ -512,7 +512,7 @@ void RowPainter::paintFirst()
                        // this is special code for the chapter layout. This is
                        // printed in an extra row and has a pagebreak at
                        // the top.
-                       if (layout->counter == "chapter") {
+                       if (layout.counter == "chapter") {
                                double spacing_val = 1.0;
                                if (!parparams.spacing().isDefault()) {
                                        spacing_val = parparams.spacing().getValue();
@@ -520,10 +520,10 @@ void RowPainter::paintFirst()
                                        spacing_val = buffer.params().spacing().getValue();
                                }
 
-                               int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
+                               int const labeladdon = int(fm.maxHeight() * layout.spacing.getValue() * spacing_val);
 
-                               int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
-                                       + int(layout->parsep) * defaultRowHeight();
+                               int const maxdesc = int(fm.maxDescent() * layout.spacing.getValue() * spacing_val)
+                                       + int(layout.parsep) * defaultRowHeight();
 
                                if (is_rtl) {
                                        x = width_ - leftMargin() -
@@ -534,9 +534,9 @@ void RowPainter::paintFirst()
                        } else {
                                if (is_rtl) {
                                        x = width_ - leftMargin()
-                                               + fm.width(layout->labelsep);
+                                               + fm.width(layout.labelsep);
                                } else {
-                                       x = x_ - fm.width(layout->labelsep)
+                                       x = x_ - fm.width(layout.labelsep)
                                                - fm.width(str);
                                }
 
@@ -547,9 +547,9 @@ void RowPainter::paintFirst()
        // the labels at the top of an environment.
        // More or less for bibliography
        } else if (is_seq &&
-               (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
-               layout->labeltype == LABEL_BIBLIO ||
-               layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
+               (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
+               layout.labeltype == LABEL_BIBLIO ||
+               layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
                FontInfo const font = labelFont();
                docstring const str = par_.labelString();
                if (!str.empty()) {
@@ -562,14 +562,14 @@ void RowPainter::paintFirst()
                        FontMetrics const & fm = theFontMetrics(font);
 
                        int const labeladdon = int(fm.maxHeight()
-                               * layout->spacing.getValue() * spacing_val);
+                               * layout.spacing.getValue() * spacing_val);
 
                        int maxdesc =
-                               int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
-                               + (layout->labelbottomsep * defaultRowHeight()));
+                               int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
+                               + (layout.labelbottomsep * defaultRowHeight()));
 
                        double x = x_;
-                       if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
+                       if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
                                if (is_rtl)
                                        x = leftMargin();
                                x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
@@ -629,7 +629,7 @@ void RowPainter::paintLast()
        case END_LABEL_STATIC: {
                FontInfo const font = labelFont();
                FontMetrics const & fm = theFontMetrics(font);
-               docstring const & str = par_.layout()->endlabelstring();
+               docstring const & str = par_.layout().endlabelstring();
                double const x = is_rtl ?
                        x_ - fm.width(str)
                        : - text_metrics_.rightMargin(pm_) - row_.width();
@@ -674,7 +674,7 @@ void RowPainter::paintText()
                body_pos = 0;
        }
 
-       LayoutPtr const & layout = par_.layout();
+       Layout const & layout = par_.layout();
 
        bool running_strikeout = false;
        bool is_struckout = false;
@@ -762,7 +762,7 @@ void RowPainter::paintText()
 
                if (body_pos > 0 && pos == body_pos - 1) {
                        int const lwidth = theFontMetrics(labelFont())
-                               .width(layout->labelsep);
+                               .width(layout.labelsep);
 
                        x_ += row_.label_hfill + lwidth - width_pos;
                }
index 1611f32495ceb0125651af950ef39b4a810a0f5e..068a831f8bf9ca99ab0449647de345bdf432ea8b 100644 (file)
@@ -201,9 +201,9 @@ void sgml::closeTag(odocstream & os, string const & name)
 void sgml::openTag(Buffer const & buf, odocstream & os,
        OutputParams const & runparams, Paragraph const & par)
 {
-       LayoutPtr const & style = par.layout();
-       string const & name = style->latexname();
-       string param = style->latexparam();
+       Layout const & style = par.layout();
+       string const & name = style.latexname();
+       string param = style.latexparam();
        Counters & counters = buf.params().documentClass().counters();
 
        string id = par.getID(buf, runparams);
@@ -220,8 +220,8 @@ void sgml::openTag(Buffer const & buf, odocstream & os,
        } else {
                if (param.find('#') != string::npos) {
                        // FIXME UNICODE
-                       if (!style->counter.empty())
-                               counters.step(style->counter);
+                       if (!style.counter.empty())
+                               counters.step(style.counter);
                        else
                                counters.step(from_ascii(name));
                        int i = counters.value(from_ascii(name));
@@ -236,8 +236,8 @@ void sgml::openTag(Buffer const & buf, odocstream & os,
 
 void sgml::closeTag(odocstream & os, Paragraph const & par)
 {
-       LayoutPtr const & style = par.layout();
-       closeTag(os, style->latexname());
+       Layout const & style = par.layout();
+       closeTag(os, style.latexname());
 }