]> git.lyx.org Git - lyx.git/blob - src/coordcache.C
a7f8a511e2700956936a0da560cfea31c8c9fa03
[lyx.git] / src / coordcache.C
1 /* \file coordcache.C
2  * This file is part of LyX, the document processor.
3  * Licence details can be found in the file COPYING.
4  *
5  * \author André Pönitz
6  *
7  * Full author contact details are available in file CREDITS.
8  */
9
10 #include <config.h>
11
12 #include "coordcache.h"
13 #include "debug.h"
14
15 #include "lyxtext.h"
16
17 #include "insets/insetbase.h"
18
19 #include <boost/assert.hpp>
20
21
22 namespace lyx {
23
24 // just a helper to be able to set a breakpoint
25 void lyxbreaker(void const * data, const char * hint, int size)
26 {
27         lyxerr << "break on pointer: " << data << " hint: " << hint
28                 << " size: " << size << std::endl;
29         BOOST_ASSERT(false);
30 }
31
32
33 void CoordCache::clear()
34 {
35         arrays_.clear();
36         insets_.clear();
37         pars_.clear();
38         slices0_.clear();
39         slices1_.clear();
40 }
41
42
43 Point CoordCache::get(LyXText const * text, lyx::pit_type pit)
44 {
45         ParPosCache::iterator const it = pars_.find(text);
46         BOOST_ASSERT(it != pars_.end());
47         InnerParPosCache::iterator const posit = it->second.find(pit);
48         BOOST_ASSERT(posit != it->second.end());
49         return posit->second;
50 }
51
52 void
53 CoordCache::dump() const {
54         lyxerr << "ParPosCache contains:" << std::endl;
55         for (ParPosCache::const_iterator i = getParPos().begin(); i != getParPos().end(); ++i) {
56                 LyXText const * lt = (*i).first;
57                 InnerParPosCache const & cache = (*i).second;
58                 lyxerr << "LyXText:" << lt << std::endl;
59                 for (InnerParPosCache::const_iterator j = cache.begin(); j != cache.end(); ++j) {
60                         pit_type pit = (*j).first;
61                         Paragraph const & par = lt->getPar(pit);
62                         Point p = (*j).second;
63                         lyxerr << "Paragraph " << pit << ": \"";
64                         for (int k = 0; k < std::min(10, par.size()); ++k) {
65                                 lyxerr << lyx::to_utf8(docstring(1,par.getChar(k)));
66                         }
67                         lyxerr << "\" has point " << p.x_ << "," << p.y_ << std::endl;
68                 }
69         }
70 }
71
72 } // namespace lyx