Add In nsetOld * argument to updateInset to rebreak the correct par.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7615 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2003-08-27 13:51:18 +00:00
parent a12509db90
commit 7338f3b980
26 changed files with 62 additions and 54 deletions

View File

@ -543,9 +543,9 @@ int BufferView::unlockInset(UpdatableInset * inset)
} }
void BufferView::updateInset() void BufferView::updateInset(InsetOld const * inset)
{ {
pimpl_->updateInset(); pimpl_->updateInset(inset);
} }

View File

@ -79,8 +79,11 @@ public:
bool fitCursor(); bool fitCursor();
/// perform pending painting updates /// perform pending painting updates
void update(); void update();
/// update for a particular inset /** update for a particular inset. Gets a pointer and not a
void updateInset(); * reference because we really need the pointer information
* to find it in the buffer.
*/
void updateInset(InsetOld const *);
/// reset the scrollbar to reflect current view position /// reset the scrollbar to reflect current view position
void updateScrollbar(); void updateScrollbar();
/// FIXME /// FIXME

View File

@ -40,6 +40,7 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "lastfiles.h" #include "lastfiles.h"
#include "paragraph.h" #include "paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "TextCache.h" #include "TextCache.h"
#include "undo_funcs.h" #include "undo_funcs.h"
@ -1182,7 +1183,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
case LFUN_INSET_INSERT: { case LFUN_INSET_INSERT: {
InsetOld * inset = createInset(ev); InsetOld * inset = createInset(ev);
if (inset && insertInset(inset)) { if (inset && insertInset(inset)) {
updateInset(); updateInset(inset);
string const name = ev.getArg(0); string const name = ev.getArg(0);
if (name == "bibitem") { if (name == "bibitem") {
@ -1371,14 +1372,16 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
} }
void BufferView::Pimpl::updateInset() void BufferView::Pimpl::updateInset(InsetOld const * inset)
{ {
if (!available()) if (!available())
return; return;
bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
// this should not be needed, but it is... // this should not be needed, but it is...
bv_->text->redoParagraph(bv_->text->cursor.par()); // bv_->text->redoParagraph(bv_->text->cursor.par());
//bv_->text->fullRebreak(); // bv_->text->fullRebreak();
update(); update();
updateScrollbar(); updateScrollbar();

View File

@ -101,7 +101,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
/// ///
bool insertInset(InsetOld * inset, string const & lout = string()); bool insertInset(InsetOld * inset, string const & lout = string());
/// ///
void updateInset(); void updateInset(InsetOld const * inset);
/// a function should be executed from the workarea /// a function should be executed from the workarea
bool workAreaDispatch(FuncRequest const & ev); bool workAreaDispatch(FuncRequest const & ev);
/// a function should be executed /// a function should be executed

View File

@ -1,4 +1,8 @@
2003-08-27 Alfredo Braunstein <abraunst@libero.it>
* BufferView.[Ch]:
* BufferView_pimpl.[Ch] (updateInset): add an InsetOld * argument
2003-08-26 André Pönitz <poenitz@gmx.net> 2003-08-26 André Pönitz <poenitz@gmx.net>
* paragraph_func.[Ch] (outerPar): new function * paragraph_func.[Ch] (outerPar): new function

View File

@ -35,6 +35,7 @@
#include "Lsstream.h" #include "Lsstream.h"
#include "insets/updatableinset.h" #include "insets/updatableinset.h"
#include "insets/insettext.h"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <algorithm> #include <algorithm>
@ -232,8 +233,7 @@ bool changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type, bool test_o
bool const changed = text->changeDepth(type, false); bool const changed = text->changeDepth(type, false);
if (text->inset_owner) if (text->inset_owner)
bv->updateInset(); bv->updateInset(text->inset_owner);
bv->update();
return changed; return changed;
} }

View File

@ -124,7 +124,7 @@ void PreviewedInset::imageReady(PreviewImage const & pimage) const
pimage_ = &pimage; pimage_ = &pimage;
if (view()) if (view())
view()->updateInset(); view()->updateInset(inset());
} }
} // namespace graphics } // namespace graphics

View File

@ -66,7 +66,7 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
if (p.getCmdName().empty()) if (p.getCmdName().empty())
return DISPATCHED; return DISPATCHED;
setParams(p); setParams(p);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
cmd.view()->fitCursor(); cmd.view()->fitCursor();
return DISPATCHED; return DISPATCHED;
} }

View File

@ -125,7 +125,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd)
InsetBranchMailer::string2params(cmd.argument, params); InsetBranchMailer::string2params(cmd.argument, params);
params_.branch = params.branch; params_.branch = params.branch;
setButtonLabel(); setButtonLabel();
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }
case LFUN_INSET_EDIT: case LFUN_INSET_EDIT:

View File

@ -210,7 +210,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
inset.insetUnlock(bv); inset.insetUnlock(bv);
if (scroll()) if (scroll())
scroll(bv, 0.0F); scroll(bv, 0.0F);
bv->updateInset(); bv->updateInset(this);
} }
@ -229,7 +229,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
if (collapsed_ && cmd.button() != mouse_button::button3) { if (collapsed_ && cmd.button() != mouse_button::button3) {
collapsed_ = false; collapsed_ = false;
bv->updateInset(); bv->updateInset(this);
bv->buffer()->markDirty(); bv->buffer()->markDirty();
return; return;
} }
@ -241,7 +241,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
collapsed_ = true; collapsed_ = true;
bv->unlockInset(this); bv->unlockInset(this);
} }
bv->updateInset(); bv->updateInset(this);
bv->buffer()->markDirty(); bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease\n"; lyxerr << "InsetCollapsable::lfunMouseRelease\n";
} else if (!collapsed_ && cmd.y > button_dim.y2) { } else if (!collapsed_ && cmd.y > button_dim.y2) {
@ -296,7 +296,7 @@ InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
lyxerr << "branch collapsed_" << endl; lyxerr << "branch collapsed_" << endl;
collapsed_ = false; collapsed_ = false;
if (bv->lockInset(this)) { if (bv->lockInset(this)) {
bv->updateInset(); bv->updateInset(this);
bv->buffer()->markDirty(); bv->buffer()->markDirty();
inset.localDispatch(cmd); inset.localDispatch(cmd);
first_after_edit = true; first_after_edit = true;
@ -324,7 +324,7 @@ InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
first_after_edit = true; first_after_edit = true;
if (!bv->lockInset(this)) if (!bv->lockInset(this))
return DISPATCHED; return DISPATCHED;
bv->updateInset(); bv->updateInset(this);
bv->buffer()->markDirty(); bv->buffer()->markDirty();
inset.localDispatch(cmd); inset.localDispatch(cmd);
} else { } else {
@ -488,7 +488,7 @@ void InsetCollapsable::open(BufferView * bv)
return; return;
collapsed_ = false; collapsed_ = false;
bv->updateInset(); bv->updateInset(this);
} }
@ -498,7 +498,7 @@ void InsetCollapsable::close(BufferView * bv) const
return; return;
collapsed_ = true; collapsed_ = true;
bv->updateInset(); bv->updateInset(this);
} }

View File

@ -102,7 +102,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
return UNDISPATCHED; return UNDISPATCHED;
setParams(p); setParams(p);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -455,7 +455,7 @@ InsetOld::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
* taken by the text). * taken by the text).
*/ */
inset.getLyXText(cmd.view())->fullRebreak(); inset.getLyXText(cmd.view())->fullRebreak();
bv->updateInset(); bv->updateInset(this);
result = DISPATCHED; result = DISPATCHED;
} }
break; break;
@ -603,7 +603,7 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
break; break;
} }
if (bv) { if (bv) {
bv->updateInset(); bv->updateInset(this);
bv->buffer()->markDirty(); bv->buffer()->markDirty();
} }
} }

View File

@ -127,7 +127,7 @@ void InsetExternal::statusChanged()
{ {
BufferView * bv = renderer_->view(); BufferView * bv = renderer_->view();
if (bv) if (bv)
bv->updateInset(); bv->updateInset(this);
} }
@ -152,7 +152,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
InsetExternal::Params p; InsetExternal::Params p;
InsetExternalMailer::string2params(cmd.argument, *buffer, p); InsetExternalMailer::string2params(cmd.argument, *buffer, p);
setParams(p, buffer); setParams(p, buffer);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -172,7 +172,7 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd)
params_.wide = params.wide; params_.wide = params.wide;
wide(params_.wide, cmd.view()->buffer()->params); wide(params_.wide, cmd.view()->buffer()->params);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -170,10 +170,8 @@ InsetGraphics::~InsetGraphics()
void InsetGraphics::statusChanged() void InsetGraphics::statusChanged()
{ {
BufferView * bv = graphic_->view(); BufferView * bv = graphic_->view();
if (bv) { if (bv)
bv->text->redoParagraph(outerPar(*bv->buffer(), this)); bv->updateInset(this);
bv->updateInset();
}
} }
@ -186,7 +184,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
InsetGraphicsMailer::string2params(cmd.argument, buffer, p); InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
if (!p.filename.empty()) { if (!p.filename.empty()) {
setParams(p); setParams(p);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
} }
return DISPATCHED; return DISPATCHED;
} }

View File

@ -138,7 +138,7 @@ dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd)
if (!p.cparams.getCmdName().empty()) { if (!p.cparams.getCmdName().empty()) {
set(p); set(p);
params_.masterFilename_ = cmd.view()->buffer()->fileName(); params_.masterFilename_ = cmd.view()->buffer()->fileName();
cmd.view()->updateInset(); cmd.view()->updateInset(this);
} }
return DISPATCHED; return DISPATCHED;
} }
@ -600,7 +600,7 @@ void InsetInclude::PreviewImpl::restartLoading()
lyxerr << "restartLoading()" << std::endl; lyxerr << "restartLoading()" << std::endl;
removePreview(); removePreview();
if (view()) if (view())
view()->updateInset(); view()->updateInset(&parent());
generatePreview(); generatePreview();
} }

View File

@ -68,7 +68,7 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
} }
setParams(p); setParams(p);
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -111,7 +111,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd)
/* FIXME: I refuse to believe we have to live /* FIXME: I refuse to believe we have to live
* with ugliness like this ... */ * with ugliness like this ... */
inset.getLyXText(cmd.view())->fullRebreak(); inset.getLyXText(cmd.view())->fullRebreak();
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -141,7 +141,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd)
InsetNoteMailer::string2params(cmd.argument, params); InsetNoteMailer::string2params(cmd.argument, params);
params_.type = params.type; params_.type = params.type;
setButtonLabel(); setButtonLabel();
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -422,7 +422,7 @@ void InsetTabular::insetUnlock(BufferView * bv)
void InsetTabular::updateLocal(BufferView * bv) const void InsetTabular::updateLocal(BufferView * bv) const
{ {
bv->updateInset(); bv->updateInset(this);
if (locked) if (locked)
resetPos(bv); resetPos(bv);
} }

View File

@ -317,7 +317,7 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
text_.selection.cursor = text_.cursor; text_.selection.cursor = text_.cursor;
bv->fitCursor(); bv->fitCursor();
bv->updateInset(); bv->updateInset(this);
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
bv->owner()->updateMenubar(); bv->owner()->updateMenubar();
bv->owner()->updateToolbar(); bv->owner()->updateToolbar();

View File

@ -91,7 +91,7 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd)
params_.placement = params.placement; params_.placement = params.placement;
params_.width = params.width; params_.width = params.width;
cmd.view()->updateInset(); cmd.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -125,7 +125,7 @@ InsetOld::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
int const xx = strToInt(ev.argument); int const xx = strToInt(ev.argument);
scroll(ev.view(), xx); scroll(ev.view(), xx);
} }
ev.view()->updateInset(); ev.view()->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }

View File

@ -153,12 +153,12 @@ void InsetFormulaBase::insetUnlock(BufferView * bv)
if (mathcursor) { if (mathcursor) {
if (mathcursor->inMacroMode()) { if (mathcursor->inMacroMode()) {
mathcursor->macroModeClose(); mathcursor->macroModeClose();
bv->updateInset(); bv->updateInset(this);
} }
releaseMathCursor(bv); releaseMathCursor(bv);
} }
generatePreview(); generatePreview();
bv->updateInset(); bv->updateInset(this);
} }
@ -204,7 +204,7 @@ void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
void InsetFormulaBase::toggleInsetSelection(BufferView * bv) void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
{ {
if (mathcursor) if (mathcursor)
bv->updateInset(); bv->updateInset(this);
} }
@ -214,7 +214,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
return UNDISPATCHED; return UNDISPATCHED;
BufferView * bv = cmd.view(); BufferView * bv = cmd.view();
bv->updateInset(); bv->updateInset(this);
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl; //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button3) { if (cmd.button() == mouse_button::button3) {
@ -233,7 +233,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
mathcursor->selClear(); mathcursor->selClear();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->insert(ar); mathcursor->insert(ar);
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }
@ -280,7 +280,7 @@ dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
return DISPATCHED; return DISPATCHED;
} }
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }
@ -308,7 +308,7 @@ dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
BufferView * bv = cmd.view(); BufferView * bv = cmd.view();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
} }
@ -342,7 +342,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
} }
// if that is removed, we won't get the magenta box when entering an // if that is removed, we won't get the magenta box when entering an
// inset for the first time // inset for the first time
bv->updateInset(); bv->updateInset(this);
return DISPATCHED; return DISPATCHED;
case LFUN_MOUSE_PRESS: case LFUN_MOUSE_PRESS:
@ -720,7 +720,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
} }
if (result == DISPATCHED) if (result == DISPATCHED)
bv->updateInset(); bv->updateInset(this);
mathcursor->normalize(); mathcursor->normalize();
mathcursor->touch(); mathcursor->touch();
@ -850,7 +850,7 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
mathcursor->setSelection(it, ar.size()); mathcursor->setSelection(it, ar.size());
current = it; current = it;
it.jump(ar.size()); it.jump(ar.size());
bv->updateInset(); bv->updateInset(this);
return true; return true;
} }
} }

View File

@ -282,7 +282,7 @@ void LyXText::toggleInset()
else else
inset->open(bv()); inset->open(bv());
bv()->updateInset(); bv()->updateInset(inset);
} }
@ -848,7 +848,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
setSelection(); setSelection();
setCursor(tmpcursor.par(), tmpcursor.pos()); setCursor(tmpcursor.par(), tmpcursor.pos());
if (inset_owner) if (inset_owner)
bv()->updateInset(); bv()->updateInset(inset_owner);
} }

View File

@ -355,7 +355,7 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
if (!bv->insertInset(new_inset)) if (!bv->insertInset(new_inset))
delete new_inset; delete new_inset;
else else
bv->updateInset(); bv->updateInset(new_inset);
} }