]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphMetrics.cpp
Further cleanup of InsetFlex, InsetCollapsable and InsetLayout:
[lyx.git] / src / ParagraphMetrics.cpp
index 701e6742334731e7d575861d9e6972200c4f5419..9d6404dbe6047f829d2b66562120f023d6bbb981 100644 (file)
@@ -28,6 +28,7 @@
 #include "gettext.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
+#include "Layout.h"
 #include "Font.h"
 #include "LyXRC.h"
 #include "Row.h"
@@ -118,6 +119,24 @@ void ParagraphMetrics::setPosition(int position)
 }
 
 
+Dimension const & ParagraphMetrics::insetDimension(Inset const * inset) const
+{
+       InsetDims::const_iterator it = inset_dims_.find(inset);
+       if (it != inset_dims_.end())
+               return it->second;
+
+       static Dimension dummy;
+       return dummy;
+}
+
+
+void ParagraphMetrics::setInsetDimension(Inset const * inset,
+               Dimension const & dim)
+{
+       inset_dims_[inset] = dim;
+}
+
+
 Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
 {
        BOOST_ASSERT(!rows().empty());
@@ -196,11 +215,11 @@ int ParagraphMetrics::rightMargin(Buffer const & buffer) const
 
 int ParagraphMetrics::singleWidth(pos_type pos, Font const & font) const
 {
-       char_type c = par_->getChar(pos);
-
        // The most special cases are handled first.
-       if (c == Paragraph::META_INSET)
-               return par_->getInset(pos)->width();
+       if (par_->isInset(pos))
+               return insetDimension(par_->getInset(pos)).wid;
+
+       char_type c = par_->getChar(pos);
 
        if (!isPrintable(c))
                return theFontMetrics(font).width(c);