| 1 |
#!/usr/bin/env python |
| 2 |
# Copyright (C) 2008 Søren Roug, European Environment Agency |
| 3 |
# |
| 4 |
# This library is free software; you can redistribute it and/or |
| 5 |
# modify it under the terms of the GNU Lesser General Public |
| 6 |
# License as published by the Free Software Foundation; either |
| 7 |
# version 2.1 of the License, or (at your option) any later version. |
| 8 |
# |
| 9 |
# This library is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
# Lesser General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU Lesser General Public |
| 15 |
# License along with this library; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 |
# |
| 18 |
# Contributor(s): |
| 19 |
# |
| 20 |
|
| 21 |
|
| 22 |
from .namespaces import ( |
| 23 |
ANIMNS, |
| 24 |
CHARTNS, |
| 25 |
DR3DNS, |
| 26 |
DRAWNS, |
| 27 |
FORMNS, |
| 28 |
MANIFESTNS, |
| 29 |
METANS, |
| 30 |
NUMBERNS, |
| 31 |
OFFICENS, |
| 32 |
PRESENTATIONNS, |
| 33 |
SCRIPTNS, |
| 34 |
STYLENS, |
| 35 |
SVGNS, |
| 36 |
TABLENS, |
| 37 |
TEXTNS, |
| 38 |
) |
| 39 |
|
| 40 |
# Inline element don't cause a box |
| 41 |
# They are analogous to the HTML elements SPAN, B, I etc. |
| 42 |
inline_elements = ( |
| 43 |
(TEXTNS, 'a'), |
| 44 |
(TEXTNS, 'author-initials'), |
| 45 |
(TEXTNS, 'author-name'), |
| 46 |
(TEXTNS, 'bibliography-mark'), |
| 47 |
(TEXTNS, 'bookmark-ref'), |
| 48 |
(TEXTNS, 'chapter'), |
| 49 |
(TEXTNS, 'character-count'), |
| 50 |
(TEXTNS, 'conditional-text'), |
| 51 |
(TEXTNS, 'creation-date'), |
| 52 |
(TEXTNS, 'creation-time'), |
| 53 |
(TEXTNS, 'creator'), |
| 54 |
(TEXTNS, 'database-display'), |
| 55 |
(TEXTNS, 'database-name'), |
| 56 |
(TEXTNS, 'database-next'), |
| 57 |
(TEXTNS, 'database-row-number'), |
| 58 |
(TEXTNS, 'database-row-select'), |
| 59 |
(TEXTNS, 'date'), |
| 60 |
(TEXTNS, 'dde-connection'), |
| 61 |
(TEXTNS, 'description'), |
| 62 |
(TEXTNS, 'editing-cycles'), |
| 63 |
(TEXTNS, 'editing-duration'), |
| 64 |
(TEXTNS, 'execute-macro'), |
| 65 |
(TEXTNS, 'expression'), |
| 66 |
(TEXTNS, 'file-name'), |
| 67 |
(TEXTNS, 'hidden-paragraph'), |
| 68 |
(TEXTNS, 'hidden-text'), |
| 69 |
(TEXTNS, 'image-count'), |
| 70 |
(TEXTNS, 'initial-creator'), |
| 71 |
(TEXTNS, 'keywords'), |
| 72 |
(TEXTNS, 'measure'), |
| 73 |
(TEXTNS, 'modification-date'), |
| 74 |
(TEXTNS, 'modification-time'), |
| 75 |
(TEXTNS, 'note-ref'), |
| 76 |
(TEXTNS, 'object-count'), |
| 77 |
(TEXTNS, 'page-continuation'), |
| 78 |
(TEXTNS, 'page-count'), |
| 79 |
(TEXTNS, 'page-number'), |
| 80 |
(TEXTNS, 'page-variable-get'), |
| 81 |
(TEXTNS, 'page-variable-set'), |
| 82 |
(TEXTNS, 'paragraph-count'), |
| 83 |
(TEXTNS, 'placeholder'), |
| 84 |
(TEXTNS, 'print-date'), |
| 85 |
(TEXTNS, 'printed-by'), |
| 86 |
(TEXTNS, 'print-time'), |
| 87 |
(TEXTNS, 'reference-ref'), |
| 88 |
(TEXTNS, 'ruby'), |
| 89 |
(TEXTNS, 'ruby-base'), |
| 90 |
(TEXTNS, 'ruby-text'), |
| 91 |
(TEXTNS, 'script'), |
| 92 |
(TEXTNS, 'sender-city'), |
| 93 |
(TEXTNS, 'sender-company'), |
| 94 |
(TEXTNS, 'sender-country'), |
| 95 |
(TEXTNS, 'sender-email'), |
| 96 |
(TEXTNS, 'sender-fax'), |
| 97 |
(TEXTNS, 'sender-firstname'), |
| 98 |
(TEXTNS, 'sender-initials'), |
| 99 |
(TEXTNS, 'sender-lastname'), |
| 100 |
(TEXTNS, 'sender-phone-private'), |
| 101 |
(TEXTNS, 'sender-phone-work'), |
| 102 |
(TEXTNS, 'sender-position'), |
| 103 |
(TEXTNS, 'sender-postal-code'), |
| 104 |
(TEXTNS, 'sender-state-or-province'), |
| 105 |
(TEXTNS, 'sender-street'), |
| 106 |
(TEXTNS, 'sender-title'), |
| 107 |
(TEXTNS, 'sequence'), |
| 108 |
(TEXTNS, 'sequence-ref'), |
| 109 |
(TEXTNS, 'sheet-name'), |
| 110 |
(TEXTNS, 'span'), |
| 111 |
(TEXTNS, 'subject'), |
| 112 |
(TEXTNS, 'table-count'), |
| 113 |
(TEXTNS, 'table-formula'), |
| 114 |
(TEXTNS, 'template-name'), |
| 115 |
(TEXTNS, 'text-input'), |
| 116 |
(TEXTNS, 'time'), |
| 117 |
(TEXTNS, 'title'), |
| 118 |
(TEXTNS, 'user-defined'), |
| 119 |
(TEXTNS, 'user-field-get'), |
| 120 |
(TEXTNS, 'user-field-input'), |
| 121 |
(TEXTNS, 'variable-get'), |
| 122 |
(TEXTNS, 'variable-input'), |
| 123 |
(TEXTNS, 'variable-set'), |
| 124 |
(TEXTNS, 'word-count'), |
| 125 |
) |
| 126 |
|
| 127 |
|
| 128 |
# It is almost impossible to determine what elements are block elements. |
| 129 |
# There are so many that don't fit the form |
| 130 |
block_elements = ( |
| 131 |
(TEXTNS, 'h'), |
| 132 |
(TEXTNS, 'p'), |
| 133 |
(TEXTNS, 'list'), |
| 134 |
(TEXTNS, 'list-item'), |
| 135 |
(TEXTNS, 'section'), |
| 136 |
) |
| 137 |
|
| 138 |
declarative_elements = ( |
| 139 |
(OFFICENS, 'font-face-decls'), |
| 140 |
(PRESENTATIONNS, 'date-time-decl'), |
| 141 |
(PRESENTATIONNS, 'footer-decl'), |
| 142 |
(PRESENTATIONNS, 'header-decl'), |
| 143 |
(TABLENS, 'table-template'), |
| 144 |
(TEXTNS, 'alphabetical-index-entry-template'), |
| 145 |
(TEXTNS, 'alphabetical-index-source'), |
| 146 |
(TEXTNS, 'bibliography-entry-template'), |
| 147 |
(TEXTNS, 'bibliography-source'), |
| 148 |
(TEXTNS, 'dde-connection-decls'), |
| 149 |
(TEXTNS, 'illustration-index-entry-template'), |
| 150 |
(TEXTNS, 'illustration-index-source'), |
| 151 |
(TEXTNS, 'index-source-styles'), |
| 152 |
(TEXTNS, 'index-title-template'), |
| 153 |
(TEXTNS, 'note-continuation-notice-backward'), |
| 154 |
(TEXTNS, 'note-continuation-notice-forward'), |
| 155 |
(TEXTNS, 'notes-configuration'), |
| 156 |
(TEXTNS, 'object-index-entry-template'), |
| 157 |
(TEXTNS, 'object-index-source'), |
| 158 |
(TEXTNS, 'sequence-decls'), |
| 159 |
(TEXTNS, 'table-index-entry-template'), |
| 160 |
(TEXTNS, 'table-index-source'), |
| 161 |
(TEXTNS, 'table-of-content-entry-template'), |
| 162 |
(TEXTNS, 'table-of-content-source'), |
| 163 |
(TEXTNS, 'user-field-decls'), |
| 164 |
(TEXTNS, 'user-index-entry-template'), |
| 165 |
(TEXTNS, 'user-index-source'), |
| 166 |
(TEXTNS, 'variable-decls'), |
| 167 |
) |
| 168 |
|
| 169 |
empty_elements = ( |
| 170 |
(ANIMNS, 'animate'), |
| 171 |
(ANIMNS, 'animateColor'), |
| 172 |
(ANIMNS, 'animateMotion'), |
| 173 |
(ANIMNS, 'animateTransform'), |
| 174 |
(ANIMNS, 'audio'), |
| 175 |
(ANIMNS, 'param'), |
| 176 |
(ANIMNS, 'set'), |
| 177 |
(ANIMNS, 'transitionFilter'), |
| 178 |
(CHARTNS, 'categories'), |
| 179 |
(CHARTNS, 'data-point'), |
| 180 |
(CHARTNS, 'domain'), |
| 181 |
(CHARTNS, 'error-indicator'), |
| 182 |
(CHARTNS, 'floor'), |
| 183 |
(CHARTNS, 'grid'), |
| 184 |
(CHARTNS, 'legend'), |
| 185 |
(CHARTNS, 'mean-value'), |
| 186 |
(CHARTNS, 'regression-curve'), |
| 187 |
(CHARTNS, 'stock-gain-marker'), |
| 188 |
(CHARTNS, 'stock-loss-marker'), |
| 189 |
(CHARTNS, 'stock-range-line'), |
| 190 |
(CHARTNS, 'symbol-image'), |
| 191 |
(CHARTNS, 'wall'), |
| 192 |
(DR3DNS, 'cube'), |
| 193 |
(DR3DNS, 'extrude'), |
| 194 |
(DR3DNS, 'light'), |
| 195 |
(DR3DNS, 'rotate'), |
| 196 |
(DR3DNS, 'sphere'), |
| 197 |
(DRAWNS, 'contour-path'), |
| 198 |
(DRAWNS, 'contour-polygon'), |
| 199 |
(DRAWNS, 'equation'), |
| 200 |
(DRAWNS, 'fill-image'), |
| 201 |
(DRAWNS, 'floating-frame'), |
| 202 |
(DRAWNS, 'glue-point'), |
| 203 |
(DRAWNS, 'gradient'), |
| 204 |
(DRAWNS, 'handle'), |
| 205 |
(DRAWNS, 'hatch'), |
| 206 |
(DRAWNS, 'layer'), |
| 207 |
(DRAWNS, 'marker'), |
| 208 |
(DRAWNS, 'opacity'), |
| 209 |
(DRAWNS, 'page-thumbnail'), |
| 210 |
(DRAWNS, 'param'), |
| 211 |
(DRAWNS, 'stroke-dash'), |
| 212 |
(FORMNS, 'connection-resource'), |
| 213 |
(FORMNS, 'list-value'), |
| 214 |
(FORMNS, 'property'), |
| 215 |
(MANIFESTNS, 'algorithm'), |
| 216 |
(MANIFESTNS, 'key-derivation'), |
| 217 |
(METANS, 'auto-reload'), |
| 218 |
(METANS, 'document-statistic'), |
| 219 |
(METANS, 'hyperlink-behaviour'), |
| 220 |
(METANS, 'template'), |
| 221 |
(NUMBERNS, 'am-pm'), |
| 222 |
(NUMBERNS, 'boolean'), |
| 223 |
(NUMBERNS, 'day'), |
| 224 |
(NUMBERNS, 'day-of-week'), |
| 225 |
(NUMBERNS, 'era'), |
| 226 |
(NUMBERNS, 'fraction'), |
| 227 |
(NUMBERNS, 'hours'), |
| 228 |
(NUMBERNS, 'minutes'), |
| 229 |
(NUMBERNS, 'month'), |
| 230 |
(NUMBERNS, 'quarter'), |
| 231 |
(NUMBERNS, 'scientific-number'), |
| 232 |
(NUMBERNS, 'seconds'), |
| 233 |
(NUMBERNS, 'text-content'), |
| 234 |
(NUMBERNS, 'week-of-year'), |
| 235 |
(NUMBERNS, 'year'), |
| 236 |
(OFFICENS, 'dde-source'), |
| 237 |
(PRESENTATIONNS, 'date-time'), |
| 238 |
(PRESENTATIONNS, 'footer'), |
| 239 |
(PRESENTATIONNS, 'header'), |
| 240 |
(PRESENTATIONNS, 'placeholder'), |
| 241 |
(PRESENTATIONNS, 'play'), |
| 242 |
(PRESENTATIONNS, 'show'), |
| 243 |
(PRESENTATIONNS, 'sound'), |
| 244 |
(SCRIPTNS, 'event-listener'), |
| 245 |
(STYLENS, 'column'), |
| 246 |
(STYLENS, 'column-sep'), |
| 247 |
(STYLENS, 'drop-cap'), |
| 248 |
(STYLENS, 'footnote-sep'), |
| 249 |
(STYLENS, 'list-level-properties'), |
| 250 |
(STYLENS, 'map'), |
| 251 |
(STYLENS, 'ruby-properties'), |
| 252 |
(STYLENS, 'table-column-properties'), |
| 253 |
(STYLENS, 'tab-stop'), |
| 254 |
(STYLENS, 'text-properties'), |
| 255 |
(SVGNS, 'definition-src'), |
| 256 |
(SVGNS, 'font-face-format'), |
| 257 |
(SVGNS, 'font-face-name'), |
| 258 |
(SVGNS, 'stop'), |
| 259 |
(TABLENS, 'body'), |
| 260 |
(TABLENS, 'cell-address'), |
| 261 |
(TABLENS, 'cell-range-source'), |
| 262 |
(TABLENS, 'change-deletion'), |
| 263 |
(TABLENS, 'consolidation'), |
| 264 |
(TABLENS, 'database-source-query'), |
| 265 |
(TABLENS, 'database-source-sql'), |
| 266 |
(TABLENS, 'database-source-table'), |
| 267 |
(TABLENS, 'data-pilot-display-info'), |
| 268 |
(TABLENS, 'data-pilot-field-reference'), |
| 269 |
(TABLENS, 'data-pilot-group-member'), |
| 270 |
(TABLENS, 'data-pilot-layout-info'), |
| 271 |
(TABLENS, 'data-pilot-member'), |
| 272 |
(TABLENS, 'data-pilot-sort-info'), |
| 273 |
(TABLENS, 'data-pilot-subtotal'), |
| 274 |
(TABLENS, 'dependency'), |
| 275 |
(TABLENS, 'error-macro'), |
| 276 |
(TABLENS, 'even-columns'), |
| 277 |
(TABLENS, 'even-rows'), |
| 278 |
(TABLENS, 'filter-condition'), |
| 279 |
(TABLENS, 'first-column'), |
| 280 |
(TABLENS, 'first-row'), |
| 281 |
(TABLENS, 'highlighted-range'), |
| 282 |
(TABLENS, 'insertion-cut-off'), |
| 283 |
(TABLENS, 'iteration'), |
| 284 |
(TABLENS, 'label-range'), |
| 285 |
(TABLENS, 'last-column'), |
| 286 |
(TABLENS, 'last-row'), |
| 287 |
(TABLENS, 'movement-cut-off'), |
| 288 |
(TABLENS, 'named-expression'), |
| 289 |
(TABLENS, 'named-range'), |
| 290 |
(TABLENS, 'null-date'), |
| 291 |
(TABLENS, 'odd-columns'), |
| 292 |
(TABLENS, 'odd-rows'), |
| 293 |
(TABLENS, 'operation'), |
| 294 |
(TABLENS, 'scenario'), |
| 295 |
(TABLENS, 'sort-by'), |
| 296 |
(TABLENS, 'sort-groups'), |
| 297 |
(TABLENS, 'source-range-address'), |
| 298 |
(TABLENS, 'source-service'), |
| 299 |
(TABLENS, 'subtotal-field'), |
| 300 |
(TABLENS, 'table-column'), |
| 301 |
(TABLENS, 'table-source'), |
| 302 |
(TABLENS, 'target-range-address'), |
| 303 |
(TEXTNS, 'alphabetical-index-auto-mark-file'), |
| 304 |
(TEXTNS, 'alphabetical-index-mark'), |
| 305 |
(TEXTNS, 'alphabetical-index-mark-end'), |
| 306 |
(TEXTNS, 'alphabetical-index-mark-start'), |
| 307 |
(TEXTNS, 'bookmark'), |
| 308 |
(TEXTNS, 'bookmark-end'), |
| 309 |
(TEXTNS, 'bookmark-start'), |
| 310 |
(TEXTNS, 'change'), |
| 311 |
(TEXTNS, 'change-end'), |
| 312 |
(TEXTNS, 'change-start'), |
| 313 |
(TEXTNS, 'dde-connection-decl'), |
| 314 |
(TEXTNS, 'index-entry-bibliography'), |
| 315 |
(TEXTNS, 'index-entry-chapter'), |
| 316 |
(TEXTNS, 'index-entry-link-end'), |
| 317 |
(TEXTNS, 'index-entry-link-start'), |
| 318 |
(TEXTNS, 'index-entry-page-number'), |
| 319 |
(TEXTNS, 'index-entry-tab-stop'), |
| 320 |
(TEXTNS, 'index-entry-text'), |
| 321 |
(TEXTNS, 'index-source-style'), |
| 322 |
(TEXTNS, 'line-break'), |
| 323 |
(TEXTNS, 'page'), |
| 324 |
(TEXTNS, 'reference-mark'), |
| 325 |
(TEXTNS, 'reference-mark-end'), |
| 326 |
(TEXTNS, 'reference-mark-start'), |
| 327 |
(TEXTNS, 's'), |
| 328 |
(TEXTNS, 'section-source'), |
| 329 |
(TEXTNS, 'sequence-decl'), |
| 330 |
(TEXTNS, 'soft-page-break'), |
| 331 |
(TEXTNS, 'sort-key'), |
| 332 |
(TEXTNS, 'tab'), |
| 333 |
(TEXTNS, 'toc-mark'), |
| 334 |
(TEXTNS, 'toc-mark-end'), |
| 335 |
(TEXTNS, 'toc-mark-start'), |
| 336 |
(TEXTNS, 'user-field-decl'), |
| 337 |
(TEXTNS, 'user-index-mark'), |
| 338 |
(TEXTNS, 'user-index-mark-end'), |
| 339 |
(TEXTNS, 'user-index-mark-start'), |
| 340 |
(TEXTNS, 'variable-decl'), |
| 341 |
) |