- BOOST_ASSERT(!paragraphs().begin()->rows.empty());
- par_type const pend = paragraphs().size() - 1;
- pit = 0;
- while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
- ++pit;
-
- RowList::iterator rit = pars_[pit].rows.end();
- RowList::iterator const rbegin = pars_[pit].rows.begin();
- do {
- --rit;
- } while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
+ BOOST_ASSERT(theCoords.getParPos().find(this) != theCoords.getParPos().end());
+ CoordCache::InnerParPosCache const & cc = theCoords.getParPos().find(this)->second;
+ lyxerr << "LyXText::getPitNearY: y: " << y << " cache size: "
+ << cc.size() << endl;
+
+ // look for highest numbered paragraph with y coordinate less than given y
+ pit_type pit = 0;
+ int yy = -1;
+ CoordCache::InnerParPosCache::const_iterator it = cc.begin();
+ CoordCache::InnerParPosCache::const_iterator et = cc.end();
+ for (; it != et; ++it) {
+ lyxerr << " examining: pit: " << it->first << " y: "
+ << it->second.y_ << endl;
+ if (it->first >= pit && int(it->second.y_) - int(pars_[it->first].ascent()) <= y) {
+ pit = it->first;
+ yy = it->second.y_;
+ }
+ }