]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.cpp
BufferParams.cpp: change the package loading to:
[lyx.git] / src / bufferview_funcs.cpp
index e8c3eff286ef527150525a3012ca6edecb07cb11..77b1a8e341d9082c6cdde86d1a63c15ee8033136 100644 (file)
@@ -157,8 +157,8 @@ Point coordOffset(BufferView const & bv, DocIterator const & dit,
        int y = 0;
        int lastw = 0;
 
-       // Addup ontribution of nested insets, from inside to outside,
-       // keeping the outer paragraph for a special handling below
+       // Addup contribution of nested insets, from inside to outside,
+       // keeping the outer paragraph for a special handling below
        for (size_t i = dit.depth() - 1; i >= 1; --i) {
                CursorSlice const & sl = dit[i];
                int xx = 0;
@@ -179,9 +179,22 @@ Point coordOffset(BufferView const & bv, DocIterator const & dit,
                        if (rtl)
                                x -= lastw;
                }
-               
+
                // remember width for the case that sl.inset() is positioned in an RTL inset
-               lastw = sl.inset().width();
+               if (i && dit[i - 1].text()) {
+                       // If this Inset is inside a Text Inset, retrieve the Dimension
+                       // from the containing text instead of using Inset::dimension() which
+                       // might not be implemented.
+                       // FIXME (Abdel 23/09/2007): this is a bit messy because of the
+                       // elimination of Inset::dim_ cache. This coordOffset() method needs
+                       // to be rewritten in light of the new design.
+                       Dimension const & dim = bv.parMetrics(dit[i - 1].text(),
+                               dit[i - 1].pit()).insetDimension(&sl.inset());
+                       lastw = dim.wid;
+               } else {
+                       Dimension const dim = sl.inset().dimension(bv);
+                       lastw = dim.wid;
+               }
                
                //lyxerr << "Cursor::getPos, i: "
                // << i << " x: " << xx << " y: " << y << endl;
@@ -247,18 +260,10 @@ CurStatus status(BufferView const * bv, DocIterator const & dit)
 {
        // FIXME: it's be better to have something like TextMetrics::status().
        TextMetrics const & tm = bv->textMetrics(dit.bottom().text());
-       pit_type const pit = dit.bottom().pit();
-       if (!tm.has(pit)) {
-               if (dit.bottom().pit() < bv->anchor_ref())
-                       return CUR_ABOVE;
-               else
-                       return CUR_BELOW;
-       }
-
-       ParagraphMetrics const & pm = tm.parMetrics(pit);
-       if (pm.position() < 0)
+       int par_pos = tm.parPosition(dit.bottom().pit());
+       if (par_pos < 0)
                return CUR_ABOVE;
-       else if (pm.position() > bv->workHeight())
+       else if (par_pos > bv->workHeight())
                return CUR_BELOW;
                
        return CUR_INSIDE;
@@ -277,7 +282,7 @@ bool findNextInset(DocIterator & dit,
                if (inset
                    && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
                    && (contents.empty() ||
-                       static_cast<InsetCommand const *>(inset)->getContents() == contents)) {
+                   static_cast<InsetCommand const *>(inset)->getContents() == contents)) {
                        dit = tmpdit;
                        return true;
                }