From: Alfredo Braunstein Date: Wed, 27 Aug 2003 13:51:18 +0000 (+0000) Subject: Add In nsetOld * argument to updateInset to rebreak the correct par. X-Git-Tag: 1.6.10~16220 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7338f3b980d4dc5793ff80be814b7a74e1c72274;p=features.git 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 --- diff --git a/src/BufferView.C b/src/BufferView.C index d925d62bf0..41b8c53efb 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -543,9 +543,9 @@ int BufferView::unlockInset(UpdatableInset * inset) } -void BufferView::updateInset() +void BufferView::updateInset(InsetOld const * inset) { - pimpl_->updateInset(); + pimpl_->updateInset(inset); } diff --git a/src/BufferView.h b/src/BufferView.h index 482492943b..076361c14e 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -79,8 +79,11 @@ public: bool fitCursor(); /// perform pending painting updates void update(); - /// update for a particular inset - void updateInset(); + /** update for a particular inset. Gets a pointer and not a + * 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 void updateScrollbar(); /// FIXME diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index da2e8b0361..a62e5004f9 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -40,6 +40,7 @@ #include "lyxrc.h" #include "lastfiles.h" #include "paragraph.h" +#include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "TextCache.h" #include "undo_funcs.h" @@ -1182,7 +1183,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) case LFUN_INSET_INSERT: { InsetOld * inset = createInset(ev); if (inset && insertInset(inset)) { - updateInset(); + updateInset(inset); string const name = ev.getArg(0); 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()) return; + bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset)); + // this should not be needed, but it is... - bv_->text->redoParagraph(bv_->text->cursor.par()); - //bv_->text->fullRebreak(); + // bv_->text->redoParagraph(bv_->text->cursor.par()); + // bv_->text->fullRebreak(); update(); updateScrollbar(); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index c4ce343a72..df03767e9c 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -101,7 +101,7 @@ struct BufferView::Pimpl : public boost::signals::trackable { /// bool insertInset(InsetOld * inset, string const & lout = string()); /// - void updateInset(); + void updateInset(InsetOld const * inset); /// a function should be executed from the workarea bool workAreaDispatch(FuncRequest const & ev); /// a function should be executed diff --git a/src/ChangeLog b/src/ChangeLog index 4dff19effb..1b3f994fa8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,8 @@ +2003-08-27 Alfredo Braunstein + * BufferView.[Ch]: + * BufferView_pimpl.[Ch] (updateInset): add an InsetOld * argument + 2003-08-26 André Pönitz * paragraph_func.[Ch] (outerPar): new function diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 5496707e2d..4d0b6e8760 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -35,6 +35,7 @@ #include "Lsstream.h" #include "insets/updatableinset.h" +#include "insets/insettext.h" #include #include @@ -232,8 +233,7 @@ bool changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type, bool test_o bool const changed = text->changeDepth(type, false); if (text->inset_owner) - bv->updateInset(); - bv->update(); + bv->updateInset(text->inset_owner); return changed; } diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index afdf0b4fef..47ac36ae6f 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -124,7 +124,7 @@ void PreviewedInset::imageReady(PreviewImage const & pimage) const pimage_ = &pimage; if (view()) - view()->updateInset(); + view()->updateInset(inset()); } } // namespace graphics diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index d9b56d7e2a..ff10c841a7 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -66,7 +66,7 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) if (p.getCmdName().empty()) return DISPATCHED; setParams(p); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); cmd.view()->fitCursor(); return DISPATCHED; } diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index b4aa05f59c..c059cea72e 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -125,7 +125,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd) InsetBranchMailer::string2params(cmd.argument, params); params_.branch = params.branch; setButtonLabel(); - bv->updateInset(); + bv->updateInset(this); return DISPATCHED; } case LFUN_INSET_EDIT: diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index bc88b3b279..f8a4d2fcd5 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -210,7 +210,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv) inset.insetUnlock(bv); if (scroll()) 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) { collapsed_ = false; - bv->updateInset(); + bv->updateInset(this); bv->buffer()->markDirty(); return; } @@ -241,7 +241,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd) collapsed_ = true; bv->unlockInset(this); } - bv->updateInset(); + bv->updateInset(this); bv->buffer()->markDirty(); lyxerr << "InsetCollapsable::lfunMouseRelease\n"; } else if (!collapsed_ && cmd.y > button_dim.y2) { @@ -296,7 +296,7 @@ InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd) lyxerr << "branch collapsed_" << endl; collapsed_ = false; if (bv->lockInset(this)) { - bv->updateInset(); + bv->updateInset(this); bv->buffer()->markDirty(); inset.localDispatch(cmd); first_after_edit = true; @@ -324,7 +324,7 @@ InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd) first_after_edit = true; if (!bv->lockInset(this)) return DISPATCHED; - bv->updateInset(); + bv->updateInset(this); bv->buffer()->markDirty(); inset.localDispatch(cmd); } else { @@ -488,7 +488,7 @@ void InsetCollapsable::open(BufferView * bv) return; collapsed_ = false; - bv->updateInset(); + bv->updateInset(this); } @@ -498,7 +498,7 @@ void InsetCollapsable::close(BufferView * bv) const return; collapsed_ = true; - bv->updateInset(); + bv->updateInset(this); } diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 11ae9ae51e..009119d21d 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -102,7 +102,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) return UNDISPATCHED; setParams(p); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 0628ad540a..a0a7071fdd 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -455,7 +455,7 @@ InsetOld::RESULT InsetERT::localDispatch(FuncRequest const & cmd) * taken by the text). */ inset.getLyXText(cmd.view())->fullRebreak(); - bv->updateInset(); + bv->updateInset(this); result = DISPATCHED; } break; @@ -603,7 +603,7 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const break; } if (bv) { - bv->updateInset(); + bv->updateInset(this); bv->buffer()->markDirty(); } } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index c8823466b1..84167ff165 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -127,7 +127,7 @@ void InsetExternal::statusChanged() { BufferView * bv = renderer_->view(); if (bv) - bv->updateInset(); + bv->updateInset(this); } @@ -152,7 +152,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) InsetExternal::Params p; InsetExternalMailer::string2params(cmd.argument, *buffer, p); setParams(p, buffer); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index a910e9e960..b46e114f5e 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -172,7 +172,7 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd) params_.wide = params.wide; wide(params_.wide, cmd.view()->buffer()->params); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 21162b67bd..0c67703e80 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -170,10 +170,8 @@ InsetGraphics::~InsetGraphics() void InsetGraphics::statusChanged() { BufferView * bv = graphic_->view(); - if (bv) { - bv->text->redoParagraph(outerPar(*bv->buffer(), this)); - bv->updateInset(); - } + if (bv) + bv->updateInset(this); } @@ -186,7 +184,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) InsetGraphicsMailer::string2params(cmd.argument, buffer, p); if (!p.filename.empty()) { setParams(p); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); } return DISPATCHED; } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 7ffd3d3504..1dceaaedd6 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -138,7 +138,7 @@ dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) if (!p.cparams.getCmdName().empty()) { set(p); params_.masterFilename_ = cmd.view()->buffer()->fileName(); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); } return DISPATCHED; } @@ -600,7 +600,7 @@ void InsetInclude::PreviewImpl::restartLoading() lyxerr << "restartLoading()" << std::endl; removePreview(); if (view()) - view()->updateInset(); + view()->updateInset(&parent()); generatePreview(); } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index ebe0545cb3..1d164b0c20 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -68,7 +68,7 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) } setParams(p); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index e7ebb7b32f..5111184a34 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -111,7 +111,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) /* FIXME: I refuse to believe we have to live * with ugliness like this ... */ inset.getLyXText(cmd.view())->fullRebreak(); - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index 68b329d0dc..efa2de5d91 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -141,7 +141,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd) InsetNoteMailer::string2params(cmd.argument, params); params_.type = params.type; setButtonLabel(); - bv->updateInset(); + bv->updateInset(this); return DISPATCHED; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 69a1f91c08..72068ed550 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -422,7 +422,7 @@ void InsetTabular::insetUnlock(BufferView * bv) void InsetTabular::updateLocal(BufferView * bv) const { - bv->updateInset(); + bv->updateInset(this); if (locked) resetPos(bv); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index e184d8b893..e2d4f46981 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -317,7 +317,7 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/) text_.selection.cursor = text_.cursor; bv->fitCursor(); - bv->updateInset(); + bv->updateInset(this); bv->owner()->view_state_changed(); bv->owner()->updateMenubar(); bv->owner()->updateToolbar(); diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index f87a44adab..77b59e2a8c 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -91,7 +91,7 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd) params_.placement = params.placement; params_.width = params.width; - cmd.view()->updateInset(); + cmd.view()->updateInset(this); return DISPATCHED; } diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 10e5a640d0..e65b4f9290 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -125,7 +125,7 @@ InsetOld::RESULT UpdatableInset::localDispatch(FuncRequest const & ev) int const xx = strToInt(ev.argument); scroll(ev.view(), xx); } - ev.view()->updateInset(); + ev.view()->updateInset(this); return DISPATCHED; } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index bd5fdcc8a7..004e045025 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -153,12 +153,12 @@ void InsetFormulaBase::insetUnlock(BufferView * bv) if (mathcursor) { if (mathcursor->inMacroMode()) { mathcursor->macroModeClose(); - bv->updateInset(); + bv->updateInset(this); } releaseMathCursor(bv); } generatePreview(); - bv->updateInset(); + bv->updateInset(this); } @@ -204,7 +204,7 @@ void InsetFormulaBase::fitInsetCursor(BufferView * bv) const void InsetFormulaBase::toggleInsetSelection(BufferView * bv) { if (mathcursor) - bv->updateInset(); + bv->updateInset(this); } @@ -214,7 +214,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) return UNDISPATCHED; BufferView * bv = cmd.view(); - bv->updateInset(); + bv->updateInset(this); //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl; if (cmd.button() == mouse_button::button3) { @@ -233,7 +233,7 @@ dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd) mathcursor->selClear(); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); mathcursor->insert(ar); - bv->updateInset(); + bv->updateInset(this); return DISPATCHED; } @@ -280,7 +280,7 @@ dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd) return DISPATCHED; } - bv->updateInset(); + bv->updateInset(this); return DISPATCHED; } @@ -308,7 +308,7 @@ dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd) BufferView * bv = cmd.view(); mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); - bv->updateInset(); + bv->updateInset(this); 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 // inset for the first time - bv->updateInset(); + bv->updateInset(this); return DISPATCHED; case LFUN_MOUSE_PRESS: @@ -720,7 +720,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) } if (result == DISPATCHED) - bv->updateInset(); + bv->updateInset(this); mathcursor->normalize(); mathcursor->touch(); @@ -850,7 +850,7 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str, mathcursor->setSelection(it, ar.size()); current = it; it.jump(ar.size()); - bv->updateInset(); + bv->updateInset(this); return true; } } diff --git a/src/text2.C b/src/text2.C index c4848d91be..45d3be00ce 100644 --- a/src/text2.C +++ b/src/text2.C @@ -282,7 +282,7 @@ void LyXText::toggleInset() else inset->open(bv()); - bv()->updateInset(); + bv()->updateInset(inset); } @@ -848,7 +848,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom, setSelection(); setCursor(tmpcursor.par(), tmpcursor.pos()); if (inset_owner) - bv()->updateInset(); + bv()->updateInset(inset_owner); } diff --git a/src/text3.C b/src/text3.C index a13e519283..e2795e8239 100644 --- a/src/text3.C +++ b/src/text3.C @@ -355,7 +355,7 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind) if (!bv->insertInset(new_inset)) delete new_inset; else - bv->updateInset(); + bv->updateInset(new_inset); }