diff --git a/src/ChangeLog b/src/ChangeLog index f8a316c79d..e0690c303d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-11-21 Michael Schmitt + + * factory.C: change call to InsetERT constructor to avoid + additional invocation of method status + * text2.C (toggleInset): remove redundant update() call + * InsetList.[Ch] (insetsOpenCloseBranch): Pass Buffer reference + instead of a Bufferview pointer 2003-11-21 André Pönitz diff --git a/src/InsetList.C b/src/InsetList.C index b167b686f4..1921cc108a 100644 --- a/src/InsetList.C +++ b/src/InsetList.C @@ -158,18 +158,17 @@ void InsetList::decreasePosAfterPos(pos_type pos) } -void InsetList::insetsOpenCloseBranch(BufferView * bv) +void InsetList::insetsOpenCloseBranch(Buffer const & buf) { - BufferParams const & bp = bv->buffer()->params(); List::iterator it = list.begin(); List::iterator end = list.end(); for (; it != end; ++it) { if (it->inset && it->inset->lyxCode() == InsetOld::BRANCH_CODE) { InsetBranch * inset = static_cast(it->inset); - if (bp.branchlist().selected(inset->params().branch)) { - inset->open(bv); + if (buf.params().branchlist().selected(inset->params().branch)) { + inset->open(); } else { - inset->close(bv); + inset->close(); } } } diff --git a/src/InsetList.h b/src/InsetList.h index 6f86f3a444..1141a8a84a 100644 --- a/src/InsetList.h +++ b/src/InsetList.h @@ -17,7 +17,7 @@ #include class InsetOld; -class BufferView; +class Buffer; /// @@ -66,7 +66,7 @@ public: /// void decreasePosAfterPos(lyx::pos_type pos); /// - void insetsOpenCloseBranch(BufferView * bv); + void insetsOpenCloseBranch(Buffer const & buf); private: /// diff --git a/src/factory.C b/src/factory.C index 987bed6457..41b8dcf02f 100644 --- a/src/factory.C +++ b/src/factory.C @@ -229,11 +229,9 @@ InsetOld * createInset(FuncRequest const & cmd) return new InsetCitation(icp); } else if (name == "ert") { - InsetERT * inset = new InsetERT(params); InsetERT::ERTStatus s; InsetERTMailer::string2params(cmd.argument, s); - inset->status(bv, s); - return inset; + return new InsetERT(params, s); } else if (name == "external") { Buffer const & buffer = *cmd.view()->buffer(); diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index d39c233afa..13b213ab57 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-11-21 Michael Schmitt + + * ControlDocument.C: Change call to insetsOpenCloseBranch + 2003-11-07 Alfredo Braunstein * ControlSpellchecker.C (isLetter): skip ert diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index 0088f07e9f..302d2d84cd 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -90,7 +90,7 @@ void ControlDocument::apply() ParIterator pit = buffer()->par_iterator_begin(); ParIterator pend = buffer()->par_iterator_end(); for (; pit != pend; ++pit) { - pit->insetlist.insetsOpenCloseBranch(bufferview()); + pit->insetlist.insetsOpenCloseBranch(*buffer()); } } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 943f852436..b19b4952e0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-11-21 Michael Schmitt + + * inset.h: + * insetcollapsable.[Ch]: + * insetert.[Ch]: remove bufferview parameter in methods + open, close, status, and updateStatus. 2003-11-21 Michael Schmitt diff --git a/src/insets/inset.h b/src/insets/inset.h index 7849c187a3..de97674da7 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -233,9 +233,9 @@ public: // is the inset open? virtual bool isOpen() const { return false; } /// open the inset - virtual void open(BufferView *) {} + virtual void open() {} /// close the inset - virtual void close(BufferView *) const {} + virtual void close() const {} /// check if the font of the char we want inserting is correct /// and modify it if it is not. virtual bool checkInsertChar(LyXFont &); diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 46ae13c37d..3e2ab79535 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -264,7 +264,7 @@ void InsetCollapsable::edit(BufferView * bv, bool left) { lyxerr << "InsetCollapsable: edit left/right" << endl; inset.edit(bv, left); - open(bv); + open(); bv->cursor().push(this); } @@ -380,7 +380,7 @@ LyXText * InsetCollapsable::getText(int i) const } -void InsetCollapsable::open(BufferView *) +void InsetCollapsable::open() { if (!collapsed_) return; @@ -389,7 +389,7 @@ void InsetCollapsable::open(BufferView *) } -void InsetCollapsable::close(BufferView * bv) const +void InsetCollapsable::close() const { if (collapsed_) return; diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index a5a96a8651..ff4f88458a 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -108,9 +108,9 @@ public: /// bool isOpen() const; /// - void open(BufferView *); + void open(); /// - void close(BufferView *) const; + void close() const; /// void markErased(); /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 9cfab1397e..9189e5f0bf 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -119,12 +119,12 @@ void InsetERT::read(Buffer const & buf, LyXLex & lex) string const tmp_token = lex.getString(); if (tmp_token == "Inlined") { - status(0, Inlined); + status(Inlined); } else if (tmp_token == "Collapsed") { - status(0, Collapsed); + status(Collapsed); } else { // leave this as default! - status(0, Open); + status(Open); } token_found = true; @@ -154,9 +154,9 @@ void InsetERT::read(Buffer const & buf, LyXLex & lex) if (!token_found) { if (isOpen()) - status(0, Open); + status(Open); else - status(0, Collapsed); + status(Collapsed); } setButtonLabel(); } @@ -237,13 +237,13 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall) } -void InsetERT::updateStatus(BufferView * bv, bool swap) const +void InsetERT::updateStatus(bool swap) const { if (status_ != Inlined) { if (isOpen()) - status(bv, swap ? Collapsed : Open); + status(swap ? Collapsed : Open); else - status(bv, swap ? Open : Collapsed); + status(swap ? Open : Collapsed); } } @@ -276,7 +276,7 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd) } if (status_ != Inlined && hitButton(cmd)) { - updateStatus(bv, true); + updateStatus(true); } else { FuncRequest cmd1 = cmd; #warning metrics? @@ -409,7 +409,7 @@ void InsetERT::edit(BufferView * bv, bool left) InsetCollapsable::edit(bv, left); } set_latex_font(bv); - updateStatus(bv); + updateStatus(); } @@ -426,7 +426,7 @@ InsetERT::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos) case LFUN_INSET_MODIFY: { InsetERT::ERTStatus status_; InsetERTMailer::string2params(cmd.argument, status_); - status(bv, status_); + status(status_); bv->update(); return DispatchResult(true, true); } @@ -537,13 +537,13 @@ void InsetERT::set_latex_font(BufferView * /*bv*/) } -// attention this function can be called with bv == 0 -void InsetERT::status(BufferView * bv, ERTStatus const st) const +void InsetERT::status(ERTStatus const st) const { if (st == status_) return; status_ = st; + switch (st) { case Inlined: break; @@ -554,16 +554,8 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const case Collapsed: setCollapsed(true); setButtonLabel(); -#ifdef LOCK - if (bv) - bv->unlockInset(); -#endif break; } - if (bv) { - bv->update(); - bv->buffer()->markDirty(); - } } @@ -574,19 +566,19 @@ bool InsetERT::showInsetDialog(BufferView * bv) const } -void InsetERT::open(BufferView * bv) +void InsetERT::open() { if (!isOpen()) - status(bv, Open); + status(Open); } -void InsetERT::close(BufferView * bv) const +void InsetERT::close() const { if (status_ == Collapsed || status_ == Inlined) return; - status(bv, Collapsed); + status(Collapsed); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 05aa837364..d3e75966f5 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -88,15 +88,15 @@ public: /// ERTStatus status() const { return status_; } /// - void open(BufferView *); + void open(); /// - void close(BufferView *) const; + void close() const; /// void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// set the status of the inset - void status(BufferView *, ERTStatus const st) const; + void status(ERTStatus const st) const; /// bool showInsetDialog(BufferView *) const; /// @@ -130,7 +130,7 @@ private: /// void set_latex_font(BufferView *); /// update status on button - void updateStatus(BufferView *, bool = false) const; + void updateStatus(bool = false) const; /// void edit(BufferView * bv, bool left); /// diff --git a/src/rowpainter.C b/src/rowpainter.C index 529f760782..1c63af6d4b 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -361,8 +361,6 @@ void RowPainter::paintFromPos(pos_type & vpos) } paintForeignMark(orig_x, orig_font); - - return; } diff --git a/src/text2.C b/src/text2.C index af4e26a4e4..6796c10945 100644 --- a/src/text2.C +++ b/src/text2.C @@ -256,7 +256,7 @@ void LyXText::toggleInset() if (inset_owner && inset_owner->owner() && inset_owner->owner()->isOpen()) { finishUndo(); - inset_owner->owner()->close(bv()); + inset_owner->owner()->close(); bv()->getLyXText()->cursorRight(true); bv()->updateParagraphDialog(); } @@ -269,11 +269,9 @@ void LyXText::toggleInset() recUndo(cursor.par()); if (inset->isOpen()) - inset->close(bv()); + inset->close(); else - inset->open(bv()); - - bv()->update(); + inset->open(); }