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
}
-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;
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);
};
///
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
+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
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