1 /* \file CoordCache.cpp
2 * This file is part of LyX, the document processor.
3 * Licence details can be found in the file COPYING.
7 * Full author contact details are available in file CREDITS.
12 #include "CoordCache.h"
17 #include "insets/Inset.h"
19 #include <boost/assert.hpp>
24 Point::Point(int x, int y)
27 BOOST_ASSERT(x > -1000000);
28 BOOST_ASSERT(x < 1000000);
29 BOOST_ASSERT(y > -1000000);
30 BOOST_ASSERT(y < 1000000);
33 // just a helper to be able to set a breakpoint
34 void lyxbreaker(void const * data, const char * hint, int size)
36 lyxerr << "break on pointer: " << data << " hint: " << hint
37 << " size: " << size << std::endl;
42 void CoordCache::clear()
52 Point CoordCache::get(Text const * text, pit_type pit) const
54 ParPosCache::const_iterator const it = pars_.find(text);
55 BOOST_ASSERT(it != pars_.end());
56 InnerParPosCache::const_iterator const posit = it->second.find(pit);
57 BOOST_ASSERT(posit != it->second.end());
62 void CoordCache::dump() const
64 lyxerr << "ParPosCache contains:" << std::endl;
65 for (ParPosCache::const_iterator it = getParPos().begin(); it != getParPos().end(); ++it) {
66 Text const * lt = it->first;
67 InnerParPosCache const & cache = it->second;
68 lyxerr << "Text:" << lt << std::endl;
69 for (InnerParPosCache::const_iterator jt = cache.begin(); jt != cache.end(); ++jt) {
70 pit_type pit = jt->first;
71 Paragraph const & par = lt->getPar(pit);
73 lyxerr << "Paragraph " << pit << ": \"";
74 int const n = std::min(static_cast<lyx::pos_type>(10), par.size());
75 for (int k = 0; k < n; ++k)
76 lyxerr << to_utf8(docstring(1, par.getChar(k)));
77 lyxerr << "\" has point " << p.x_ << "," << p.y_ << std::endl;
81 lyxerr << "InsetCache contains:" << std::endl;
82 for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) {
83 Inset const * inset = it->first;
84 Point const p = it->second;
85 lyxerr << "Inset " << inset << "(" << to_utf8(inset->name())
86 << ") has point " << p.x_ << "," << p.y_ << std::endl;