mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
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:
parent
462eca7d1a
commit
35b6b4c8d0
@ -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)
|
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
||||||
{
|
{
|
||||||
// Check if the label 'from' appears more than once
|
// 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)
|
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return ChangeInsets(InsetOld::REF_CODE, from, to);
|
return pimpl_->ChangeInsets(InsetOld::REF_CODE, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,24 +15,24 @@
|
|||||||
#ifndef BUFFER_VIEW_H
|
#ifndef BUFFER_VIEW_H
|
||||||
#define BUFFER_VIEW_H
|
#define BUFFER_VIEW_H
|
||||||
|
|
||||||
#include "support/std_string.h"
|
|
||||||
|
|
||||||
#include "insets/inset.h"
|
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
class Change;
|
#include "support/std_string.h"
|
||||||
class LyXView;
|
|
||||||
class LyXText;
|
|
||||||
class TeXErrors;
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class LyXScreen;
|
class Change;
|
||||||
class Language;
|
|
||||||
class Painter;
|
|
||||||
class UpdatableInset;
|
|
||||||
class WordLangTuple;
|
|
||||||
class Encoding;
|
class Encoding;
|
||||||
class ErrorList;
|
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
|
* A buffer view encapsulates a view onto a particular
|
||||||
@ -205,15 +205,6 @@ private:
|
|||||||
/// Set the current locking inset
|
/// Set the current locking inset
|
||||||
void theLockingInset(UpdatableInset * 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;
|
struct Pimpl;
|
||||||
friend struct BufferView::Pimpl;
|
friend struct BufferView::Pimpl;
|
||||||
|
|
||||||
|
@ -1384,3 +1384,44 @@ void BufferView::Pimpl::updateInset(InsetOld const * inset)
|
|||||||
update();
|
update();
|
||||||
updateScrollbar();
|
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;
|
||||||
|
}
|
||||||
|
@ -20,9 +20,13 @@
|
|||||||
|
|
||||||
#include "errorlist.h"
|
#include "errorlist.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "frontends/Timeout.h"
|
|
||||||
|
#include "insets/inset.h"
|
||||||
|
|
||||||
#include "frontends/key_state.h"
|
#include "frontends/key_state.h"
|
||||||
#include "frontends/LyXKeySym.h"
|
#include "frontends/LyXKeySym.h"
|
||||||
|
#include "frontends/Timeout.h"
|
||||||
|
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
@ -140,6 +144,14 @@ private:
|
|||||||
/// notify readonly status
|
/// notify readonly status
|
||||||
void showReadonly(bool);
|
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;
|
friend class BufferView;
|
||||||
|
|
||||||
|
@ -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>
|
2003-09-06 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* buffer_funcs.C:
|
* buffer_funcs.C:
|
||||||
|
@ -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>
|
2003-09-05 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* *.C: strip out redundant #includes. (26 in total.)
|
* *.C: strip out redundant #includes. (26 in total.)
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
|
|
||||||
|
#include "insets/inset.h"
|
||||||
|
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
@ -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>
|
2003-09-05 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* *.C: strip out redundant #includes. (193 in total.)
|
* *.C: strip out redundant #includes. (193 in total.)
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include "insets/renderers.h"
|
#include "insets/renderers.h"
|
||||||
|
|
||||||
|
#include "insets/inset.h"
|
||||||
|
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "metricsinfo.h"
|
#include "metricsinfo.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user