Move BufferView::ChangeInsets to the Pimpl. As a result, can remove

the #include "insets/inset.h" from BufferView.h.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7696 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-09-06 19:16:30 +00:00
parent 462eca7d1a
commit 35b6b4c8d0
9 changed files with 85 additions and 65 deletions

View File

@ -517,47 +517,6 @@ void BufferView::updateInset(InsetOld const * inset)
}
bool BufferView::ChangeInsets(InsetOld::Code code,
string const & from, string const & to)
{
bool need_update = false;
LyXCursor cursor = text->cursor;
LyXCursor tmpcursor = cursor;
cursor.par(tmpcursor.par());
cursor.pos(tmpcursor.pos());
ParIterator end = buffer()->par_iterator_end();
for (ParIterator it = buffer()->par_iterator_begin();
it != end; ++it) {
bool changed_inset = false;
for (InsetList::iterator it2 = it->insetlist.begin();
it2 != it->insetlist.end(); ++it2) {
if (it2->inset->lyxCode() == code) {
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
if (inset->getContents() == from) {
inset->setContents(to);
changed_inset = true;
}
}
}
if (changed_inset) {
need_update = true;
// FIXME
// The test it.size()==1 was needed to prevent crashes.
// How to set the cursor corretly when it.size()>1 ??
if (it.size() == 1) {
text->setCursorIntern(it.pit(), 0);
text->redoParagraph(text->cursor.par());
}
}
}
text->setCursorIntern(cursor.par(), cursor.pos());
return need_update;
}
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
{
// Check if the label 'from' appears more than once
@ -567,7 +526,7 @@ bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
if (lyx::count(labels.begin(), labels.end(), from) > 1)
return false;
return ChangeInsets(InsetOld::REF_CODE, from, to);
return pimpl_->ChangeInsets(InsetOld::REF_CODE, from, to);
}

View File

@ -15,24 +15,24 @@
#ifndef BUFFER_VIEW_H
#define BUFFER_VIEW_H
#include "support/std_string.h"
#include "insets/inset.h"
#include <boost/utility.hpp>
class Change;
class LyXView;
class LyXText;
class TeXErrors;
#include "support/std_string.h"
class Buffer;
class LyXScreen;
class Language;
class Painter;
class UpdatableInset;
class WordLangTuple;
class Change;
class Encoding;
class ErrorList;
class FuncRequest;
class InsetOld;
class Language;
class LyXText;
class LyXScreen;
class LyXView;
class Painter;
class TeXErrors;
class UpdatableInset;
class WordLangTuple;
/**
* A buffer view encapsulates a view onto a particular
@ -205,15 +205,6 @@ private:
/// Set the current locking inset
void theLockingInset(UpdatableInset * inset);
/**
* Change all insets with the given code's contents to a new
* string. May only be used with InsetCommand-derived insets
* Returns true if a screen update is needed.
*/
bool ChangeInsets(InsetOld::Code code, string const & from,
string const & to);
struct Pimpl;
friend struct BufferView::Pimpl;

View File

@ -1384,3 +1384,44 @@ void BufferView::Pimpl::updateInset(InsetOld const * inset)
update();
updateScrollbar();
}
bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
string const & from, string const & to)
{
bool need_update = false;
LyXCursor cursor = bv_->text->cursor;
LyXCursor tmpcursor = cursor;
cursor.par(tmpcursor.par());
cursor.pos(tmpcursor.pos());
ParIterator end = bv_->buffer()->par_iterator_end();
for (ParIterator it = bv_->buffer()->par_iterator_begin();
it != end; ++it) {
bool changed_inset = false;
for (InsetList::iterator it2 = it->insetlist.begin();
it2 != it->insetlist.end(); ++it2) {
if (it2->inset->lyxCode() == code) {
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
if (inset->getContents() == from) {
inset->setContents(to);
changed_inset = true;
}
}
}
if (changed_inset) {
need_update = true;
// FIXME
// The test it.size()==1 was needed to prevent crashes.
// How to set the cursor corretly when it.size()>1 ??
if (it.size() == 1) {
bv_->text->setCursorIntern(it.pit(), 0);
bv_->text->redoParagraph(bv_->text->cursor.par());
}
}
}
bv_->text->setCursorIntern(cursor.par(), cursor.pos());
return need_update;
}

View File

@ -20,9 +20,13 @@
#include "errorlist.h"
#include "BufferView.h"
#include "frontends/Timeout.h"
#include "insets/inset.h"
#include "frontends/key_state.h"
#include "frontends/LyXKeySym.h"
#include "frontends/Timeout.h"
#include "support/types.h"
#include <boost/scoped_ptr.hpp>
@ -140,6 +144,14 @@ private:
/// notify readonly status
void showReadonly(bool);
/**
* Change all insets with the given code's contents to a new
* string. May only be used with InsetCommand-derived insets
* Returns true if a screen update is needed.
*/
bool ChangeInsets(InsetOld::Code code, string const & from,
string const & to);
///
friend class BufferView;

View File

@ -1,3 +1,8 @@
2003-09-06 Angus Leeming <leeming@lyx.org>
* BufferView.[Ch] (ChangeInsets): moved to BufferView_pimpl.[Ch].
As a result, can remove the #include "insets/inset.h" from BufferView.h
2003-09-06 Angus Leeming <leeming@lyx.org>
* buffer_funcs.C:

View File

@ -1,3 +1,7 @@
2003-09-06 Angus Leeming <leeming@lyx.org>
* PreviewedInset.C: add #include "insets/inset.h"
2003-09-05 Angus Leeming <leeming@lyx.org>
* *.C: strip out redundant #includes. (26 in total.)

View File

@ -17,6 +17,8 @@
#include "BufferView.h"
#include "insets/inset.h"
#include "support/lstrings.h"
#include <boost/bind.hpp>

View File

@ -1,3 +1,7 @@
2003-09-06 Angus Leeming <leeming@lyx.org>
* renderers.C: add #include "insets/inset.h"
2003-09-05 Angus Leeming <leeming@lyx.org>
* *.C: strip out redundant #includes. (193 in total.)

View File

@ -12,6 +12,8 @@
#include "insets/renderers.h"
#include "insets/inset.h"
#include "BufferView.h"
#include "gettext.h"
#include "metricsinfo.h"