2007-04-26 04:41:58 +00:00
|
|
|
|
/* \file CoordCache.cpp
|
2005-04-26 10:30:24 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2004-08-14 14:04:37 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "CoordCache.h"
|
2004-08-14 14:04:37 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
#include "insets/Inset.h"
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
2004-08-14 14:04:37 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2006-10-15 22:32:56 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
Point::Point(int x, int y)
|
|
|
|
|
: x_(x), y_(y)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(x > -1000000);
|
|
|
|
|
BOOST_ASSERT(x < 1000000);
|
|
|
|
|
BOOST_ASSERT(y > -1000000);
|
|
|
|
|
BOOST_ASSERT(y < 1000000);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-14 14:04:37 +00:00
|
|
|
|
// just a helper to be able to set a breakpoint
|
|
|
|
|
void lyxbreaker(void const * data, const char * hint, int size)
|
|
|
|
|
{
|
2004-10-05 10:11:42 +00:00
|
|
|
|
lyxerr << "break on pointer: " << data << " hint: " << hint
|
2004-08-14 14:04:37 +00:00
|
|
|
|
<< " size: " << size << std::endl;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-10-05 10:11:42 +00:00
|
|
|
|
void CoordCache::clear()
|
2004-08-14 14:04:37 +00:00
|
|
|
|
{
|
|
|
|
|
arrays_.clear();
|
|
|
|
|
insets_.clear();
|
2004-11-30 01:59:49 +00:00
|
|
|
|
pars_.clear();
|
2005-07-18 12:13:32 +00:00
|
|
|
|
slices0_.clear();
|
|
|
|
|
slices1_.clear();
|
2004-08-14 14:04:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-16 17:54:25 +00:00
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Point CoordCache::get(Text const * text, pit_type pit) const
|
2004-11-30 01:59:49 +00:00
|
|
|
|
{
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
ParPosCache::const_iterator const it = pars_.find(text);
|
2004-11-30 01:59:49 +00:00
|
|
|
|
BOOST_ASSERT(it != pars_.end());
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
InnerParPosCache::const_iterator const posit = it->second.find(pit);
|
2004-11-30 01:59:49 +00:00
|
|
|
|
BOOST_ASSERT(posit != it->second.end());
|
|
|
|
|
return posit->second;
|
|
|
|
|
}
|
2006-10-15 22:32:56 +00:00
|
|
|
|
|
2007-04-29 12:32:14 +00:00
|
|
|
|
|
|
|
|
|
void CoordCache::dump() const
|
|
|
|
|
{
|
2006-10-20 20:57:21 +00:00
|
|
|
|
lyxerr << "ParPosCache contains:" << std::endl;
|
2007-04-29 13:39:47 +00:00
|
|
|
|
for (ParPosCache::const_iterator it = getParPos().begin(); it != getParPos().end(); ++it) {
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Text const * lt = it->first;
|
2007-04-29 13:39:47 +00:00
|
|
|
|
InnerParPosCache const & cache = it->second;
|
2007-04-29 23:33:02 +00:00
|
|
|
|
lyxerr << "Text:" << lt << std::endl;
|
2007-04-29 13:39:47 +00:00
|
|
|
|
for (InnerParPosCache::const_iterator jt = cache.begin(); jt != cache.end(); ++jt) {
|
|
|
|
|
pit_type pit = jt->first;
|
2006-10-20 20:57:21 +00:00
|
|
|
|
Paragraph const & par = lt->getPar(pit);
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Point p = jt->second;
|
2006-10-20 20:57:21 +00:00
|
|
|
|
lyxerr << "Paragraph " << pit << ": \"";
|
2007-04-29 13:39:47 +00:00
|
|
|
|
int const n = std::min(static_cast<lyx::pos_type>(10), par.size());
|
|
|
|
|
for (int k = 0; k < n; ++k)
|
|
|
|
|
lyxerr << to_utf8(docstring(1, par.getChar(k)));
|
2006-10-20 20:57:21 +00:00
|
|
|
|
lyxerr << "\" has point " << p.x_ << "," << p.y_ << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-21 10:56:36 +00:00
|
|
|
|
|
|
|
|
|
lyxerr << "InsetCache contains:" << std::endl;
|
2007-04-29 13:39:47 +00:00
|
|
|
|
for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) {
|
|
|
|
|
Inset const * inset = it->first;
|
|
|
|
|
Point const p = it->second;
|
2007-04-30 14:39:09 +00:00
|
|
|
|
lyxerr << "Inset " << inset << "(" << to_utf8(inset->name())
|
2007-04-29 13:39:47 +00:00
|
|
|
|
<< ") has point " << p.x_ << "," << p.y_ << std::endl;
|
2006-10-21 10:56:36 +00:00
|
|
|
|
}
|
2006-10-20 20:57:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-15 22:32:56 +00:00
|
|
|
|
} // namespace lyx
|