]> git.lyx.org Git - features.git/commitdiff
bug 1096
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 14 Aug 2004 00:27:15 +0000 (00:27 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 14 Aug 2004 00:27:15 +0000 (00:27 +0000)
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

src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/ChangeLog

index f33b0f8012cc377708ed606385f580550a7db078..1fdc75a779953f43b533583a1e87b2f6d3787d7b 100644 (file)
@@ -111,6 +111,20 @@ boost::signals::connection selectioncon;
 boost::signals::connection lostcon;
 
 
+/// Get next inset of this class from current cursor position
+template <class T>
+T * getInsetByCode(LCursor & cur, InsetBase::Code code)
+{
+       T * inset = 0;
+       DocIterator it = cur;
+       if (it.nextInset() &&
+           it.nextInset()->lyxCode() == code) {
+               inset = static_cast<T*>(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<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
+                               getInsetByCode<InsetRef>(bv_->cursor(),
+                                                        InsetBase::REF_CODE);
                        if (inset) {
                                label = inset->getContents();
                                savePosition(0);
index 6c6766af2b110bc82d012edca9fbc9bc06b67a29..0e47a24df4212edc6795261a33c97409d4ef2a0a 100644 (file)
@@ -173,8 +173,6 @@ private:
        };
        ///
        std::vector<Position> 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
index 39eddedea93e07e5fad753d5647283e85e99332b..80c5d889b44a86bad5c3697aa03e3102631c725f 100644 (file)
@@ -1,3 +1,10 @@
+2004-08-14  Lars Gullik Bjonnes  <larsbj@lyx.org>
+
+       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  <larsbj@lyx.org>
 
        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