-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feature: tab stops #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
feature: tab stops #261
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5bd5b8d
acpt: add scenarios for TabStop property getters
DKWoods 062afba
tabs: add TabStop.position
DKWoods 565c20e
tabs: add TabStop.alignment
DKWoods 8d61431
tabs: add TabStop.leader
DKWoods 934624b
acpt: add scenarios for TabStop property setters
DKWoods 189075f
tabs: add TabStop.position setter
DKWoods a32122c
tabs: add TabStop.alignment setter
DKWoods 276ebe9
tabs: add TabStop.leader setter
DKWoods 76eab78
acpt: add scenarios for add/remove tab stop
DKWoods fe8b5d7
tab: add TabStops.add_tab_stop()
DKWoods 435f6d0
tab: add TabStops.__delitem__()
DKWoods d2a72cd
tab: add TabStops.clear_all()
DKWoods 358233d
acpt: Adjust tests for keeping tabs in position order when changing p…
DKWoods 409b2c1
tabs: when changing TabStop.position, keep TabStops in position order
DKWoods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _WdTabAlignment: | ||
|
||
``WD_TAB_ALIGNMENT`` | ||
==================== | ||
|
||
Specifies the tab stop alignment to apply. | ||
|
||
---- | ||
|
||
LEFT | ||
Left-aligned. | ||
|
||
CENTER | ||
Center-aligned. | ||
|
||
RIGHT | ||
Right-aligned. | ||
|
||
DECIMAL | ||
Decimal-aligned. | ||
|
||
BAR | ||
Bar-aligned. | ||
|
||
LIST | ||
List-aligned. (deprecated) | ||
|
||
CLEAR | ||
Clear an inherited tab stop. | ||
|
||
END | ||
Right-aligned. (deprecated) | ||
|
||
NUM | ||
Left-aligned. (deprecated) | ||
|
||
START | ||
Left-aligned. (deprecated) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _WdTabLeader: | ||
|
||
``WD_TAB_LEADER`` | ||
================= | ||
|
||
Specifies the character to use as the leader with formatted tabs. | ||
|
||
---- | ||
|
||
SPACES | ||
Spaces. Default. | ||
|
||
DOTS | ||
Dots. | ||
|
||
DASHES | ||
Dashes. | ||
|
||
LINES | ||
Double lines. | ||
|
||
HEAVY | ||
A heavy line. | ||
|
||
MIDDLE_DOT | ||
A vertically-centered dot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
Custom element classes related to paragraph properties (CT_PPr). | ||
""" | ||
|
||
from ...enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING | ||
from ...enum.text import ( | ||
WD_ALIGN_PARAGRAPH, WD_LINE_SPACING, WD_TAB_ALIGNMENT, WD_TAB_LEADER | ||
) | ||
from ...shared import Length | ||
from ..simpletypes import ST_SignedTwipsMeasure, ST_TwipsMeasure | ||
from ..xmlchemy import ( | ||
|
@@ -315,8 +317,32 @@ class CT_Spacing(BaseOxmlElement): | |
lineRule = OptionalAttribute('w:lineRule', WD_LINE_SPACING) | ||
|
||
|
||
class CT_TabStop(BaseOxmlElement): | ||
""" | ||
``<w:tab>`` element, representing an individual tab stop. | ||
""" | ||
val = RequiredAttribute('w:val', WD_TAB_ALIGNMENT) | ||
leader = OptionalAttribute( | ||
'w:leader', WD_TAB_LEADER, default=WD_TAB_LEADER.SPACES | ||
) | ||
pos = RequiredAttribute('w:pos', ST_SignedTwipsMeasure) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CT_TabStop is not needed to pass this test. Dropped from this commit. |
||
|
||
class CT_TabStops(BaseOxmlElement): | ||
""" | ||
``<w:tabs>`` element, container for a sorted sequence of tab stops. | ||
""" | ||
tab = OneOrMore('w:tab', successors=()) | ||
|
||
def insert_tab_in_order(self, pos, align, leader): | ||
""" | ||
Insert a newly created `w:tab` child element in *pos* order. | ||
""" | ||
new_tab = self._new_tab() | ||
new_tab.pos, new_tab.val, new_tab.leader = pos, align, leader | ||
for tab in self.tab_lst: | ||
if new_tab.pos < tab.pos: | ||
tab.addprevious(new_tab) | ||
return new_tab | ||
self.append(new_tab) | ||
return new_tab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DKWoods All these changes are merged in here: https://github.com/python-openxml/python-docx/commits/feature/tabstops
..these comments are just so you can know for next time. Check the merged commit for actual specifics.