Table Cache
Cache classes for Table and Row.
Classes:
| Name | Description |
|---|---|
RowCache |
Cache for Row (internal). |
TableCache |
Cache for Table (internal). |
_XP_CELL_IDX
module-attribute
_XP_CELL_IDX = xpath_compile(
"(table:table-cell|table:covered-table-cell)[$idx]"
)
_XP_COLUMN_IDX
module-attribute
_XP_COLUMN_IDX = xpath_compile(
"(table:table-column|table:table-columns/table:table-column|table:table-header-columns/table:table-column)[$idx]"
)
_XP_ROW_IDX
module-attribute
_XP_ROW_IDX = xpath_compile(
"(table:table-row|table:table-rows/table:table-row|table:table-header-rows/table:table-row|table:table-row-group/child::table:table-row)[$idx]"
)
RowCache
Cache for Row (internal).
Methods:
| Name | Description |
|---|---|
__init__ |
|
__str__ |
|
cached_cell |
Retrieve Cell in cache. |
cell_idx |
Find cell index in the map from the position. |
cell_map_length |
|
clear_cell_indexes |
|
copy |
|
delete_cell_in_cache |
|
insert_cell_in_cache |
|
insert_cell_map_once |
|
make_cell_map |
|
set_cell_in_cache |
|
store_cell |
Store Cell in cache. |
width |
Get the number of expected cells in the row, i.e. addition |
Attributes:
| Name | Type | Description |
|---|---|---|
__slots__ |
|
|
cell_elements |
dict[int, Cell]
|
|
cell_map |
list[int]
|
|
Source code in odfdo/table_cache.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
__slots__
class-attribute
instance-attribute
__slots__ = ('cell_elements', 'cell_map')
cell_elements
instance-attribute
cell_elements: dict[int, Cell] = {}
cell_map
instance-attribute
cell_map: list[int] = []
__init__
__init__() -> None
Source code in odfdo/table_cache.py
265 266 267 | |
__str__
__str__() -> str
Source code in odfdo/table_cache.py
269 270 | |
cached_cell
cached_cell(idx: int) -> Cell | None
Retrieve Cell in cache.
Source code in odfdo/table_cache.py
303 304 305 | |
cell_idx
cell_idx(position: int) -> int | None
Find cell index in the map from the position.
Source code in odfdo/table_cache.py
293 294 295 296 297 298 | |
cell_map_length
cell_map_length() -> int
Source code in odfdo/table_cache.py
300 301 | |
clear_cell_indexes
clear_cell_indexes() -> None
Source code in odfdo/table_cache.py
290 291 | |
copy
classmethod
copy(source: RowCache) -> RowCache
Source code in odfdo/table_cache.py
272 273 274 275 276 | |
delete_cell_in_cache
delete_cell_in_cache(x: int, vault: Row) -> None
Source code in odfdo/table_cache.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
insert_cell_in_cache
insert_cell_in_cache(
x: int, cell: Cell, vault: Row
) -> Cell
Source code in odfdo/table_cache.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
insert_cell_map_once
insert_cell_map_once(repeated: int) -> None
Source code in odfdo/table_cache.py
311 312 | |
make_cell_map
make_cell_map(
idx_repeated_sequence: list[tuple[int, int]],
) -> None
Source code in odfdo/table_cache.py
317 318 | |
set_cell_in_cache
set_cell_in_cache(
x: int, cell: Cell, vault: Row, clone: bool
) -> Cell
Source code in odfdo/table_cache.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
store_cell
store_cell(cell: Cell, idx: int) -> None
Store Cell in cache.
Source code in odfdo/table_cache.py
307 308 309 | |
width
width() -> int
Get the number of expected cells in the row, i.e. addition repetitions.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of expected cells in the row. |
Source code in odfdo/table_cache.py
278 279 280 281 282 283 284 285 286 287 288 | |
TableCache
Cache for Table (internal).
Methods:
| Name | Description |
|---|---|
__init__ |
|
__str__ |
|
cached_col |
Retrieve Column in cache. |
cached_row |
Retrieve Row in cache. |
clear_col_indexes |
|
clear_row_indexes |
|
col_idx |
Find column index in the map from the position. |
col_map_length |
|
copy |
|
delete_col_in_cache |
|
delete_row_in_cache |
|
height |
Get the current height of the table. |
insert_col_in_cache |
|
insert_col_map_once |
|
insert_row_in_cache |
|
insert_row_map_once |
|
make_col_map |
|
make_row_map |
|
row_idx |
Find row index in the map from the position. |
set_col_in_cache |
|
set_row_in_cache |
|
store_col |
Store Column in cache. |
store_row |
Store Row in cache. |
width |
Get the current width of the table, measured on columns. |
Attributes:
| Name | Type | Description |
|---|---|---|
__slots__ |
|
|
col_elements |
dict[int, Column]
|
|
col_map |
list[int]
|
|
row_elements |
dict[int, Row]
|
|
row_map |
list[int]
|
|
Source code in odfdo/table_cache.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
__slots__
class-attribute
instance-attribute
__slots__ = (
"col_elements",
"col_map",
"row_elements",
"row_map",
)
col_elements
instance-attribute
col_elements: dict[int, Column] = {}
col_map
instance-attribute
col_map: list[int] = []
row_elements
instance-attribute
row_elements: dict[int, Row] = {}
row_map
instance-attribute
row_map: list[int] = []
__init__
__init__() -> None
Source code in odfdo/table_cache.py
403 404 405 406 407 | |
__str__
__str__() -> str
Source code in odfdo/table_cache.py
409 410 | |
cached_col
cached_col(idx: int) -> Column | None
Retrieve Column in cache.
Source code in odfdo/table_cache.py
471 472 473 | |
cached_row
cached_row(idx: int) -> Row | None
Retrieve Row in cache.
Source code in odfdo/table_cache.py
467 468 469 | |
clear_col_indexes
clear_col_indexes() -> None
Source code in odfdo/table_cache.py
447 448 | |
clear_row_indexes
clear_row_indexes() -> None
Source code in odfdo/table_cache.py
444 445 | |
col_idx
col_idx(position: int) -> int | None
Find column index in the map from the position.
Source code in odfdo/table_cache.py
457 458 459 460 461 462 | |
col_map_length
col_map_length() -> int
Source code in odfdo/table_cache.py
464 465 | |
copy
classmethod
copy(source: TableCache) -> TableCache
Source code in odfdo/table_cache.py
412 413 414 415 416 417 | |
delete_col_in_cache
delete_col_in_cache(x: int, vault: Table) -> None
Source code in odfdo/table_cache.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
delete_row_in_cache
delete_row_in_cache(y: int, vault: Table) -> None
Source code in odfdo/table_cache.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
height
height() -> int
Get the current height of the table.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current height of the table. |
Source code in odfdo/table_cache.py
419 420 421 422 423 424 425 426 427 428 | |
insert_col_in_cache
insert_col_in_cache(
x: int, column: Column, vault: Table
) -> Column
Source code in odfdo/table_cache.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | |
insert_col_map_once
insert_col_map_once(repeated: int) -> None
Source code in odfdo/table_cache.py
489 490 | |
insert_row_in_cache
insert_row_in_cache(y: int, row: Row, vault: Table) -> Row
Source code in odfdo/table_cache.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
insert_row_map_once
insert_row_map_once(repeated: int) -> None
Source code in odfdo/table_cache.py
483 484 | |
make_col_map
make_col_map(
idx_repeated_sequence: list[tuple[int, int]],
) -> None
Source code in odfdo/table_cache.py
498 499 | |
make_row_map
make_row_map(
idx_repeated_sequence: list[tuple[int, int]],
) -> None
Source code in odfdo/table_cache.py
495 496 | |
row_idx
row_idx(position: int) -> int | None
Find row index in the map from the position.
Source code in odfdo/table_cache.py
450 451 452 453 454 455 | |
set_col_in_cache
set_col_in_cache(
x: int, column: Column, vault: Table
) -> Column
Source code in odfdo/table_cache.py
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
set_row_in_cache
set_row_in_cache(
y: int, row: Row, vault: Table, clone: bool
) -> Row
Source code in odfdo/table_cache.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
store_col
store_col(col: Column, idx: int) -> None
Store Column in cache.
Source code in odfdo/table_cache.py
479 480 481 | |
store_row
store_row(row: Row, idx: int) -> None
Store Row in cache.
Source code in odfdo/table_cache.py
475 476 477 | |
width
width() -> int
Get the current width of the table, measured on columns.
Rows may have different widths, use the Table API to ensure width consistency.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The current width of the table. |
Source code in odfdo/table_cache.py
430 431 432 433 434 435 436 437 438 439 440 441 442 | |
_delete_item_in_vault
_delete_item_in_vault(
idx: int,
current_item: Cell | Row | Column,
vault: Row | Table,
vault_map: list[int],
) -> list[int]
Source code in odfdo/table_cache.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
_erase_map_once
_erase_map_once(
cache_map: list[int], odf_idx: int
) -> list[int]
Remove an item (cell or row) from the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_map
|
list[int]
|
Cache map. |
required |
odf_idx
|
int
|
Index in ODF XML. |
required |
Source code in odfdo/table_cache.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
_insert_item_in_vault
_insert_item_in_vault(
position: int,
item: Cell | Row | Column,
idx: int,
current_item: Cell | Row | Column,
vault: Row | Table,
vault_map: list[int],
) -> tuple[list[int], Cell | Row | Column]
Source code in odfdo/table_cache.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
_insert_map_once
_insert_map_once(
cache_map: list[int], odf_idx: int, repeated: int
) -> list[int]
Add an item (cell or row) to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_map
|
list[int]
|
Cache map. |
required |
odf_idx
|
int
|
Index in ODF XML. |
required |
repeated
|
int
|
Repeated value of item, 1 or more. |
required |
odf_idx is NOT position (col or row), neither raw XML position, but ODF index
Source code in odfdo/table_cache.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
_make_cache_map
_make_cache_map(
idx_repeated_seq: list[tuple[int, int]],
) -> list[int]
Build the initial cache map of the table.
Source code in odfdo/table_cache.py
49 50 51 52 53 54 | |
_set_item_in_vault
_set_item_in_vault(
position: int,
item: Cell | Row | Column,
idx: int,
current_item: Cell | Row | Column,
vault: Row | Table,
vault_map: list[int],
vault_scheme: XPath,
clone: bool = True,
) -> tuple[list[int], Cell | Row | Column]
Set the item (cell, row) in its vault (row, table), updating the cache map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
int
|
Position of the item. |
required |
item
|
Cell | Row | Column
|
The item to set. |
required |
idx
|
int
|
Index in ODF XML. |
required |
current_item
|
Cell | Row | Column
|
Current item. |
required |
vault
|
Row | Table
|
Vault. |
required |
vault_map
|
list[int]
|
Vault map. |
required |
vault_scheme
|
XPath
|
Vault scheme. |
required |
clone
|
bool
|
Whether to clone the item. |
True
|
Source code in odfdo/table_cache.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |