From: Lars Gullik Bjønnes Date: Sat, 14 Aug 2004 00:27:15 +0000 (+0000) Subject: bug 1096 X-Git-Tag: 1.6.10~15076 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a13a346b0ef28ef152c382a73f356dfb144e022d;p=features.git bug 1096 Try to fix the move to references label bug. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8920 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index f33b0f8012..1fdc75a779 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -111,6 +111,20 @@ boost::signals::connection selectioncon; boost::signals::connection lostcon; +/// Get next inset of this class from current cursor position +template +T * getInsetByCode(LCursor & cur, InsetBase::Code code) +{ + T * inset = 0; + DocIterator it = cur; + if (it.nextInset() && + it.nextInset()->lyxCode() == code) { + inset = static_cast(it.nextInset()); + } + return inset; +} + + } // anon namespace @@ -730,24 +744,6 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const } -InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code) -{ -#ifdef WITH_WARNINGS -#warning Does not work for mathed. (Still true?) -#endif - // Ok, this is a little bit too brute force but it - // should work for now. Better infrastructure is coming. (Lgb) - LCursor & cur = bv_->cursor(); - DocIterator it = cur; - for (it.forwardInset(); it; it.forwardInset()) { - BOOST_ASSERT(it.nextInset()); - if (it.nextInset()->lyxCode() == code) - return it.nextInset(); - } - return 0; -} - - void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm) { string filename = filenm; @@ -1038,7 +1034,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) string label = cmd.argument; if (label.empty()) { InsetRef * inset = - static_cast(getInsetByCode(InsetBase::REF_CODE)); + getInsetByCode(bv_->cursor(), + InsetBase::REF_CODE); if (inset) { label = inset->getContents(); savePosition(0); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 6c6766af2b..0e47a24df4 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -173,8 +173,6 @@ private: }; /// std::vector saved_positions; - /// Get next inset of this class from current cursor position - InsetBase * getInsetByCode(InsetBase::Code code); /// void MenuInsertLyXFile(std::string const & filen); /// our workarea diff --git a/src/ChangeLog b/src/ChangeLog index 39eddedea9..80c5d889b4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-08-14 Lars Gullik Bjonnes + + bug 1096 + * BufferView_pimpl.C (getInsetByCode): move function out of class + and change in to a template in anon namespace. Also fix to do what + suits us better. + 2004-08-13 Lars Gullik Bjonnes bug 1305 @@ -26,7 +33,7 @@ optional argument, enclose the argument with curly brackets (in case it contains a closing square bracket) - * text2.C (editXY): + * text2.C (editXY): * text2.C (editXY): * text3.C (checkInsetHit): constify