Changeset 27590
- Timestamp:
- 11/16/08 22:28:06 (2 months ago)
- Files:
-
- lyx-devel/trunk/src/Buffer.cpp (modified) (4 diffs)
- lyx-devel/trunk/src/Buffer.h (modified) (4 diffs)
- lyx-devel/trunk/src/BufferView.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lyx-devel/trunk/src/Buffer.cpp
r27565 r27590 102 102 #include <iomanip> 103 103 #include <map> 104 #include <set> 104 105 #include <sstream> 105 106 #include <stack> … … 124 125 125 126 } // namespace anon 127 128 class BufferSet : public std::set<Buffer const *> {}; 126 129 127 130 class Buffer::Impl … … 1683 1686 1684 1687 1685 Buffer const * Buffer::parent() 1688 Buffer const * Buffer::parent() const 1686 1689 { 1687 1690 return d->parent_buffer; 1691 } 1692 1693 1694 void Buffer::collectRelatives(BufferSet & bufs) const 1695 { 1696 bufs.insert(this); 1697 if (parent()) 1698 parent()->collectRelatives(bufs); 1699 1700 // loop over children 1701 Impl::BufferPositionMap::iterator it = d->children_positions.begin(); 1702 Impl::BufferPositionMap::iterator end = d->children_positions.end(); 1703 for (; it != end; ++it) 1704 bufs.insert(const_cast<Buffer *>(it->first)); 1705 } 1706 1707 1708 std::vector<Buffer const *> Buffer::allRelatives() const 1709 { 1710 BufferSet bufs; 1711 collectRelatives(bufs); 1712 BufferSet::iterator it = bufs.begin(); 1713 std::vector<Buffer const *> ret; 1714 for (; it != bufs.end(); ++it) 1715 ret.push_back(*it); 1716 return ret; 1688 1717 } 1689 1718 … … 1701 1730 { 1702 1731 return d->children_positions.find(child) != d->children_positions.end(); 1732 } 1733 1734 1735 DocIterator Buffer::firstChildPosition(Buffer const * child) 1736 { 1737 Impl::BufferPositionMap::iterator it; 1738 it = d->children_positions.find(child); 1739 if (it == d->children_positions.end()) 1740 return DocIterator(); 1741 return it->second; 1703 1742 } 1704 1743 lyx-devel/trunk/src/Buffer.h
r27565 r27590 27 27 class BiblioInfo; 28 28 class BufferParams; 29 class BufferSet; 29 30 class DocIterator; 30 31 class ErrorItem; … … 273 274 /// Set document's parent Buffer. 274 275 void setParent(Buffer const *); 275 Buffer const * parent(); 276 Buffer const * parent() const; 277 278 // Collect all relative buffer 279 std::vector<Buffer const *> allRelatives() const; 276 280 277 281 /** Get the document's master (or \c this if this is not a … … 359 363 /// 360 364 ParConstIterator par_iterator_end() const; 365 366 // Position of the child buffer where it appears first in the master. 367 DocIterator firstChildPosition(Buffer const * child); 361 368 362 369 /** \returns true only when the file is fully loaded. … … 484 491 485 492 /// 493 void collectRelatives(BufferSet & bufs) const; 494 495 /// 486 496 bool readFileHelper(support::FileName const & s); 487 497 /// lyx-devel/trunk/src/BufferView.cpp
r27578 r27590 1075 1075 if (label.empty()) { 1076 1076 InsetRef * inset = 1077 getInsetByCode<InsetRef>(d->cursor_, 1078 REF_CODE); 1077 getInsetByCode<InsetRef>(d->cursor_, REF_CODE); 1079 1078 if (inset) { 1080 1079 label = inset->getParam("reference"); … … 1083 1082 } 1084 1083 } 1085 1086 if (!label.empty()) 1084 if (!label.empty()) 1087 1085 gotoLabel(label); 1088 1086 break; … … 1810 1808 void BufferView::gotoLabel(docstring const & label) 1811 1809 { 1812 Toc & toc = buffer().tocBackend().toc("label"); 1813 TocIterator toc_it = toc.begin(); 1814 TocIterator end = toc.end(); 1815 for (; toc_it != end; ++toc_it) { 1816 if (label == toc_it->str()) 1817 dispatch(toc_it->action()); 1818 } 1819 //FIXME: We could do a bit more searching thanks to this: 1820 //InsetLabel const * inset = buffer_.insetLabel(label); 1810 std::vector<Buffer const *> bufs = buffer().allRelatives(); 1811 std::vector<Buffer const *>::iterator it = bufs.begin(); 1812 for (; it != bufs.end(); ++it) { 1813 Buffer const * buf = *it; 1814 1815 // find label 1816 Toc & toc = buf->tocBackend().toc("label"); 1817 TocIterator toc_it = toc.begin(); 1818 TocIterator end = toc.end(); 1819 for (; toc_it != end; ++toc_it) { 1820 if (label == toc_it->str()) { 1821 dispatch(toc_it->action()); 1822 return; 1823 } 1824 } 1825 } 1821 1826 } 1822 1827
