|
6 | 6 | absolute_import, division, print_function, unicode_literals |
7 | 7 | ) |
8 | 8 |
|
| 9 | +from docx.shared import lazyproperty |
| 10 | + |
9 | 11 |
|
10 | 12 | class Bookmarks(object): |
11 | 13 | """Sequence of |Bookmark| objects.""" |
12 | 14 |
|
13 | 15 | def __init__(self, document_part): |
14 | 16 | self._document_part = document_part |
| 17 | + |
| 18 | + def __len__(self): |
| 19 | + return len(self._finder.bookmark_pairs) |
| 20 | + |
| 21 | + @lazyproperty |
| 22 | + def _finder(self): |
| 23 | + """_DocumentBookmarkFinder instance for this document.""" |
| 24 | + raise NotImplementedError |
| 25 | + |
| 26 | + |
| 27 | +class _DocumentBookmarkFinder(object): |
| 28 | + """Provides access to bookmark oxml elements in an overall document.""" |
| 29 | + |
| 30 | + @property |
| 31 | + def bookmark_pairs(self): |
| 32 | + """List of (bookmarkStart, bookmarkEnd) element pairs for document. |
| 33 | +
|
| 34 | + The return value is a list of two-tuples (pairs) each containing |
| 35 | + a start and its matching end element. |
| 36 | +
|
| 37 | + All story parts of the document are searched, including the main |
| 38 | + document story, headers, footers, footnotes, and endnotes. The order |
| 39 | + of part searching is not guaranteed, but bookmarks appear in document |
| 40 | + order within a particular part. Only well-formed bookmarks appear. |
| 41 | + Any open bookmarks (start but no end), reversed bookmarks (end before |
| 42 | + start), or duplicate (name same as prior bookmark) bookmarks are |
| 43 | + ignored. |
| 44 | + """ |
| 45 | + raise NotImplementedError |
0 commit comments