desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'A |SettingsPart| object providing access to the document-level settings for this document. Creates a default settings part if one is not present.'
@property def _settings_part(self):
try: return self.part_related_by(RT.SETTINGS) except KeyError: settings_part = SettingsPart.default(self.package) self.relate_to(settings_part, RT.SETTINGS) return settings_part
'Instance of |StylesPart| for this document. Creates an empty styles part if one is not present.'
@property def _styles_part(self):
try: return self.part_related_by(RT.STYLES) except KeyError: styles_part = StylesPart.default(self.package) self.relate_to(styles_part, RT.STYLES) return styles_part
'Native width of this image, calculated from its width in pixels and horizontal dots per inch (dpi).'
@property def default_cx(self):
px_width = self.image.px_width horz_dpi = self.image.horz_dpi width_in_inches = (px_width / horz_dpi) return Inches(width_in_inches)
'Native height of this image, calculated from its height in pixels and vertical dots per inch (dpi).'
@property def default_cy(self):
px_height = self.image.px_height horz_dpi = self.image.horz_dpi height_in_emu = ((914400 * px_height) / horz_dpi) return Emu(height_in_emu)
'Filename from which this image part was originally created. A generic name, e.g. \'image.png\', is substituted if no name is available, for example when the image was loaded from an unnamed stream. In that case a default extension is applied based on the detected MIME type of the image.'
@property def filename(self):
if (self._image is not None): return self._image.filename return (u'image.%s' % self.partname.ext)
'Return an |ImagePart| instance newly created from *image* and assigned *partname*.'
@classmethod def from_image(cls, image, partname):
return ImagePart(partname, image.content_type, image.blob, image)
'Called by ``docx.opc.package.PartFactory`` to load an image part from a package being opened by ``Document(...)`` call.'
@classmethod def load(cls, partname, content_type, blob, package):
return cls(partname, content_type, blob)
'SHA1 hash digest of the blob of this image part.'
@property def sha1(self):
return hashlib.sha1(self._blob).hexdigest()
'Enables dictionary-style access to a latent style by name.'
def __getitem__(self, key):
style_name = BabelFish.ui2internal(key) lsdException = self._element.get_by_name(style_name) if (lsdException is None): raise KeyError((u"no latent style with name '%s'" % key)) return _LatentStyle(lsdException)
'Return a newly added |_LatentStyle| object to override the inherited defaults defined in this latent styles object for the built-in style having *name*.'
def add_latent_style(self, name):
lsdException = self._element.add_lsdException() lsdException.name = BabelFish.ui2internal(name) return _LatentStyle(lsdException)
'Integer between 0 and 99 inclusive specifying the default sort order for latent styles in style lists and the style gallery. |None| if no value is assigned, which causes Word to use the default value 99.'
@property def default_priority(self):
return self._element.defUIPriority
'Boolean specifying whether the default behavior for latent styles is to be hidden. A hidden style does not appear in the recommended list or in the style gallery.'
@property def default_to_hidden(self):
return self._element.bool_prop(u'defSemiHidden')
'Boolean specifying whether the default behavior for latent styles is to be locked. A locked style does not appear in the styles panel or the style gallery and cannot be applied to document content. This behavior is only active when formatting protection is turned on for the document (via the Developer menu).'
@property def default_to_locked(self):
return self._element.bool_prop(u'defLockedState')
'Boolean specifying whether the default behavior for latent styles is to appear in the style gallery when not hidden.'
@property def default_to_quick_style(self):
return self._element.bool_prop(u'defQFormat')
'Boolean specifying whether the default behavior for latent styles is to be unhidden when first applied to content.'
@property def default_to_unhide_when_used(self):
return self._element.bool_prop(u'defUnhideWhenUsed')
'Integer specifying the number of built-in styles to initialize to the defaults specified in this |LatentStyles| object. |None| if there is no setting in the XML (very uncommon). The default Word 2011 template sets this value to 276, accounting for the built-in styles in Word 2010.'
@property def load_count(self):
return self._element.count
'Remove this latent style definition such that the defaults defined in the containing |LatentStyles| object provide the effective value for each of its attributes. Attempting to access any attributes on this object after calling this method will raise |AttributeError|.'
def delete(self):
self._element.delete() self._element = None
'Tri-state value specifying whether this latent style should appear in the recommended list. |None| indicates the effective value is inherited from the parent ``<w:latentStyles>`` element.'
@property def hidden(self):
return self._element.on_off_prop(u'semiHidden')
'Tri-state value specifying whether this latent styles is locked. A locked style does not appear in the styles panel or the style gallery and cannot be applied to document content. This behavior is only active when formatting protection is turned on for the document (via the Developer menu).'
@property def locked(self):
return self._element.on_off_prop(u'locked')
'The name of the built-in style this exception applies to.'
@property def name(self):
return BabelFish.internal2ui(self._element.name)
'The integer sort key for this latent style in the Word UI.'
@property def priority(self):
return self._element.uiPriority
'Tri-state value specifying whether this latent style should appear in the Word styles gallery when not hidden. |None| indicates the effective value should be inherited from the default values in its parent |LatentStyles| object.'
@property def quick_style(self):
return self._element.on_off_prop(u'qFormat')
'Tri-state value specifying whether this style should have its :attr:`hidden` attribute set |False| the next time the style is applied to content. |None| indicates the effective value should be inherited from the default specified by its parent |LatentStyles| object.'
@property def unhide_when_used(self):
return self._element.on_off_prop(u'unhideWhenUsed')
'Return the internal style name corresponding to *ui_style_name*, such as \'heading 1\' for \'Heading 1\'.'
@classmethod def ui2internal(cls, ui_style_name):
return cls.internal_style_names.get(ui_style_name, ui_style_name)
'Return the user interface style name corresponding to *internal_style_name*, such as \'Heading 1\' for \'heading 1\'.'
@classmethod def internal2ui(cls, internal_style_name):
return cls.ui_style_names.get(internal_style_name, internal_style_name)
'Enables `in` operator on style name.'
def __contains__(self, name):
internal_name = BabelFish.ui2internal(name) for style in self._element.style_lst: if (style.name_val == internal_name): return True return False
'Enables dictionary-style access by UI name. Lookup by style id is deprecated, triggers a warning, and will be removed in a near-future release.'
def __getitem__(self, key):
style_elm = self._element.get_by_name(BabelFish.ui2internal(key)) if (style_elm is not None): return StyleFactory(style_elm) style_elm = self._element.get_by_id(key) if (style_elm is not None): msg = u'style lookup by style_id is deprecated. Use style name as key instead.' warn(msg, UserWarning) return StyleFactory(style_elm) raise KeyError((u"no style with name '%s'" % key))
'Return a newly added style object of *style_type* and identified by *name*. A builtin style can be defined by passing True for the optional *builtin* argument.'
def add_style(self, name, style_type, builtin=False):
style_name = BabelFish.ui2internal(name) if (style_name in self): raise ValueError((u"document already contains style '%s'" % name)) style = self._element.add_style_of_type(style_name, style_type, builtin) return StyleFactory(style)
'Return the default style for *style_type* or |None| if no default is defined for that type (not common).'
def default(self, style_type):
style = self._element.default_for(style_type) if (style is None): return None return StyleFactory(style)
'Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or is |None|, or if the style having *style_id* is not of *style_type*.'
def get_by_id(self, style_id, style_type):
if (style_id is None): return self.default(style_type) return self._get_by_id(style_id, style_type)
'Return the id of the style corresponding to *style_or_name*, or |None| if *style_or_name* is |None|. If *style_or_name* is not a style object, the style is looked up using *style_or_name* as a style name, raising |ValueError| if no style with that name is defined. Raises |ValueError| if the target style is not of *style_type*.'
def get_style_id(self, style_or_name, style_type):
if (style_or_name is None): return None elif isinstance(style_or_name, BaseStyle): return self._get_style_id_from_style(style_or_name, style_type) else: return self._get_style_id_from_name(style_or_name, style_type)
'A |LatentStyles| object providing access to the default behaviors for latent styles and the collection of |_LatentStyle| objects that define overrides of those defaults for a particular named latent style.'
@property def latent_styles(self):
return LatentStyles(self._element.get_or_add_latentStyles())
'Return the style of *style_type* matching *style_id*. Returns the default for *style_type* if *style_id* is not found or if the style having *style_id* is not of *style_type*.'
def _get_by_id(self, style_id, style_type):
style = self._element.get_by_id(style_id) if ((style is None) or (style.type != style_type)): return self.default(style_type) return StyleFactory(style)
'Return the id of the style of *style_type* corresponding to *style_name*. Returns |None| if that style is the default style for *style_type*. Raises |ValueError| if the named style is not found in the document or does not match *style_type*.'
def _get_style_id_from_name(self, style_name, style_type):
return self._get_style_id_from_style(self[style_name], style_type)
'Return the id of *style*, or |None| if it is the default style of *style_type*. Raises |ValueError| if style is not of *style_type*.'
def _get_style_id_from_style(self, style, style_type):
if (style.type != style_type): raise ValueError((u'assigned style is type %s, need type %s' % (style.type, style_type))) if (style == self.default(style_type)): return None return style.style_id
'Read-only. |True| if this style is a built-in style. |False| indicates it is a custom (user-defined) style. Note this value is based on the presence of a `customStyle` attribute in the XML, not on specific knowledge of which styles are built into Word.'
@property def builtin(self):
return (not self._element.customStyle)
'Remove this style definition from the document. Note that calling this method does not remove or change the style applied to any document content. Content items having the deleted style will be rendered using the default style, as is any content with a style not defined in the document.'
def delete(self):
self._element.delete() self._element = None
'|True| if display of this style in the style gallery and list of recommended styles is suppressed. |False| otherwise. In order to be shown in the style gallery, this value must be |False| and :attr:`.quick_style` must be |True|.'
@property def hidden(self):
return self._element.semiHidden_val
'Read/write Boolean. |True| if this style is locked. A locked style does not appear in the styles panel or the style gallery and cannot be applied to document content. This behavior is only active when formatting protection is turned on for the document (via the Developer menu).'
@property def locked(self):
return self._element.locked_val
'The UI name of this style.'
@property def name(self):
name = self._element.name_val if (name is None): return None return BabelFish.internal2ui(name)
'The integer sort key governing display sequence of this style in the Word UI. |None| indicates no setting is defined, causing Word to use the default value of 0. Style name is used as a secondary sort key to resolve ordering of styles having the same priority value.'
@property def priority(self):
return self._element.uiPriority_val
'|True| if this style should be displayed in the style gallery when :attr:`.hidden` is |False|. Read/write Boolean.'
@property def quick_style(self):
return self._element.qFormat_val
'The unique key name (string) for this style. This value is subject to rewriting by Word and should generally not be changed unless you are familiar with the internals involved.'
@property def style_id(self):
return self._element.styleId
'Member of :ref:`WdStyleType` corresponding to the type of this style, e.g. ``WD_STYLE_TYPE.PARAGRAPH``.'
@property def type(self):
type = self._element.type if (type is None): return WD_STYLE_TYPE.PARAGRAPH return type
'|True| if an application should make this style visible the next time it is applied to content. False otherwise. Note that |docx| does not automatically unhide a style having |True| for this attribute when it is applied to content.'
@property def unhide_when_used(self):
return self._element.unhideWhenUsed_val
'Style object this style inherits from or |None| if this style is not based on another style.'
@property def base_style(self):
base_style = self._element.base_style if (base_style is None): return None return StyleFactory(base_style)
'The |Font| object providing access to the character formatting properties for this style, such as font name and size.'
@property def font(self):
return Font(self._element)
'|_ParagraphStyle| object representing the style to be applied automatically to a new paragraph inserted after a paragraph of this style. Returns self if no next paragraph style is defined. Assigning |None| or *self* removes the setting such that new paragraphs are created using this same style.'
@property def next_paragraph_style(self):
next_style_elm = self._element.next_style if (next_style_elm is None): return self if (next_style_elm.type != WD_STYLE_TYPE.PARAGRAPH): return self return StyleFactory(next_style_elm)
'The |ParagraphFormat| object providing access to the paragraph formatting properties for this style such as indentation.'
@property def paragraph_format(self):
return ParagraphFormat(self._element)
'The ``<w:tc>`` element appearing at grid column *idx*. Raises |ValueError| if no ``w:tc`` element begins at that grid column.'
def tc_at_grid_col(self, idx):
grid_col = 0 for tc in self.tc_lst: if (grid_col == idx): return tc grid_col += tc.grid_span if (grid_col > idx): raise ValueError((u'no cell on grid column %d' % idx)) raise ValueError(u'index out of bounds')
'The index of this ``<w:tr>`` element within its parent ``<w:tbl>`` element.'
@property def tr_idx(self):
return self.getparent().tr_lst.index(self)
'Value of `w:tblPr/w:bidiVisual/@w:val` or |None| if not present. Controls whether table cells are displayed right-to-left or left-to-right.'
@property def bidiVisual_val(self):
bidiVisual = self.tblPr.bidiVisual if (bidiVisual is None): return None return bidiVisual.val
'The number of grid columns in this table.'
@property def col_count(self):
return len(self.tblGrid.gridCol_lst)
'Generate each of the `w:tc` elements in this table, left to right and top to bottom. Each cell in the first row is generated, followed by each cell in the second row, etc.'
def iter_tcs(self):
for tr in self.tr_lst: for tc in tr.tc_lst: (yield tc)
'Return a new `w:tbl` element having *rows* rows and *cols* columns with *width* distributed evenly between the columns.'
@classmethod def new_tbl(cls, rows, cols, width):
return parse_xml(cls._tbl_xml(rows, cols, width))
'Value of `w:tblPr/w:tblStyle/@w:val` (a table style id) or |None| if not present.'
@property def tblStyle_val(self):
tblStyle = self.tblPr.tblStyle if (tblStyle is None): return None return tblStyle.val
'Set the value of `w:tblPr/w:tblStyle/@w:val` (a table style id) to *styleId*. If *styleId* is None, remove the `w:tblStyle` element.'
@tblStyle_val.setter def tblStyle_val(self, styleId):
tblPr = self.tblPr tblPr._remove_tblStyle() if (styleId is None): return tblPr._add_tblStyle().val = styleId
'The index of this ``<w:gridCol>`` element within its parent ``<w:tblGrid>`` element.'
@property def gridCol_idx(self):
return self.getparent().gridCol_lst.index(self)
'Member of :ref:`WdRowAlignment` enumeration or |None|, based on the contents of the `w:val` attribute of `./w:jc`. |None| if no `w:jc` element is present.'
@property def alignment(self):
jc = self.jc if (jc is None): return None return jc.val
'Return |False| if there is a ``<w:tblLayout>`` child with ``w:type`` attribute set to ``\'fixed\'``. Otherwise return |True|.'
@property def autofit(self):
tblLayout = self.tblLayout if (tblLayout is None): return True return (False if (tblLayout.type == u'fixed') else True)
'Return the value of the ``val`` attribute of the ``<w:tblStyle>`` child or |None| if not present.'
@property def style(self):
tblStyle = self.tblStyle if (tblStyle is None): return None return tblStyle.val
'Return the EMU length value represented by the combined ``w:w`` and ``w:type`` attributes.'
@property def width(self):
if (self.type != u'dxa'): return None return Twips(self.w)
'The row index that marks the bottom extent of the vertical span of this cell. This is one greater than the index of the bottom-most row of the span, similar to how a slice of the cell\'s rows would be specified.'
@property def bottom(self):
if (self.vMerge is not None): tc_below = self._tc_below if ((tc_below is not None) and (tc_below.vMerge == ST_Merge.CONTINUE)): return tc_below.bottom return (self._tr_idx + 1)
'Remove all content child elements, preserving the ``<w:tcPr>`` element if present. Note that this leaves the ``<w:tc>`` element in an invalid state because it doesn\'t contain at least one block-level element. It\'s up to the caller to add a ``<w:p>``child element as the last content element.'
def clear_content(self):
new_children = [] tcPr = self.tcPr if (tcPr is not None): new_children.append(tcPr) self[:] = new_children
'The integer number of columns this cell spans. Determined by ./w:tcPr/w:gridSpan/@val, it defaults to 1.'
@property def grid_span(self):
tcPr = self.tcPr if (tcPr is None): return 1 return tcPr.grid_span
'Generate a reference to each of the block-level content elements in this cell, in the order they appear.'
def iter_block_items(self):
block_item_tags = (qn(u'w:p'), qn(u'w:tbl'), qn(u'w:sdt')) for child in self: if (child.tag in block_item_tags): (yield child)
'The grid column index at which this ``<w:tc>`` element appears.'
@property def left(self):
return self._grid_col
'Return the top-left ``<w:tc>`` element of a new span formed by merging the rectangular region defined by using this tc element and *other_tc* as diagonal corners.'
def merge(self, other_tc):
(top, left, height, width) = self._span_dimensions(other_tc) top_tc = self._tbl.tr_lst[top].tc_at_grid_col(left) top_tc._grow_to(width, height) return top_tc
'Return a new ``<w:tc>`` element, containing an empty paragraph as the required EG_BlockLevelElt.'
@classmethod def new(cls):
return parse_xml((u'<w:tc %s>\n <w:p/>\n</w:tc>' % nsdecls(u'w')))
'The grid column index that marks the right-side extent of the horizontal span of this cell. This is one greater than the index of the right-most column of the span, similar to how a slice of the cell\'s columns would be specified.'
@property def right(self):
return (self._grid_col + self.grid_span)
'The top-most row index in the vertical span of this cell.'
@property def top(self):
if ((self.vMerge is None) or (self.vMerge == ST_Merge.RESTART)): return self._tr_idx return self._tc_above.top
'The value of the ./w:tcPr/w:vMerge/@val attribute, or |None| if the w:vMerge element is not present.'
@property def vMerge(self):
tcPr = self.tcPr if (tcPr is None): return None return tcPr.vMerge_val
'Return the EMU length value represented in the ``./w:tcPr/w:tcW`` child element or |None| if not present.'
@property def width(self):
tcPr = self.tcPr if (tcPr is None): return None return tcPr.width
'Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width.'
def _add_width_of(self, other_tc):
if (self.width and other_tc.width): self.width += other_tc.width
'The grid column at which this cell begins.'
@property def _grid_col(self):
tr = self._tr idx = tr.tc_lst.index(self) preceding_tcs = tr.tc_lst[:idx] return sum((tc.grid_span for tc in preceding_tcs))
'Grow this cell to *width* grid columns and *height* rows by expanding horizontal spans and creating continuation cells to form vertical spans.'
def _grow_to(self, width, height, top_tc=None):
def vMerge_val(top_tc): if (top_tc is not self): return ST_Merge.CONTINUE if (height == 1): return None return ST_Merge.RESTART top_tc = (self if (top_tc is None) else top_tc) self._span_to_width(width, top_tc, vMerge_val(top_tc)) if (height > 1): self._tc_below._grow_to(width, (height - 1), top_tc)
'``tcPr`` has a bunch of successors, but it comes first if it appears, so just overriding and using insert(0, ...) rather than spelling out successors.'
def _insert_tcPr(self, tcPr):
self.insert(0, tcPr) return tcPr
'True if this cell contains only a single empty ``<w:p>`` element.'
@property def _is_empty(self):
block_items = list(self.iter_block_items()) if (len(block_items) > 1): return False p = block_items[0] if (len(p.r_lst) == 0): return True return False
'Append the content of this cell to *other_tc*, leaving this cell with a single empty ``<w:p>`` element.'
def _move_content_to(self, other_tc):
if (other_tc is self): return if self._is_empty: return other_tc._remove_trailing_empty_p() for block_element in self.iter_block_items(): other_tc.append(block_element) self.append(self._new_p())
'The `w:tc` element immediately following this one in this row, or |None| if this is the last `w:tc` element in the row.'
@property def _next_tc(self):
following_tcs = self.xpath(u'./following-sibling::w:tc') return (following_tcs[0] if following_tcs else None)
'Remove this `w:tc` element from the XML tree.'
def _remove(self):
self.getparent().remove(self)
'Remove the last content element from this cell if it is an empty ``<w:p>`` element.'
def _remove_trailing_empty_p(self):
block_items = list(self.iter_block_items()) last_content_elm = block_items[(-1)] if (last_content_elm.tag != qn(u'w:p')): return p = last_content_elm if (len(p.r_lst) > 0): return self.remove(p)
'Return a (top, left, height, width) 4-tuple specifying the extents of the merged cell formed by using this tc and *other_tc* as opposite corner extents.'
def _span_dimensions(self, other_tc):
def raise_on_inverted_L(a, b): if ((a.top == b.top) and (a.bottom != b.bottom)): raise InvalidSpanError(u'requested span not rectangular') if ((a.left == b.left) and (a.right != b.right)): raise InvalidSpanError(u'requested span not rectangular') def raise_on_tee_shaped(a, b): (top_most, other) = ((a, b) if (a.top < b.top) else (b, a)) if ((top_most.top < other.top) and (top_most.bottom > other.bottom)): raise InvalidSpanError(u'requested span not rectangular') (left_most, other) = ((a, b) if (a.left < b.left) else (b, a)) if ((left_most.left < other.left) and (left_most.right > other.right)): raise InvalidSpanError(u'requested span not rectangular') raise_on_inverted_L(self, other_tc) raise_on_tee_shaped(self, other_tc) top = min(self.top, other_tc.top) left = min(self.left, other_tc.left) bottom = max(self.bottom, other_tc.bottom) right = max(self.right, other_tc.right) return (top, left, (bottom - top), (right - left))
'Incorporate and then remove `w:tc` elements to the right of this one until this cell spans *grid_width*. Raises |ValueError| if *grid_width* cannot be exactly achieved, such as when a merged cell would drive the span width greater than *grid_width* or if not enough grid columns are available to make this cell that wide. All content from incorporated cells is appended to *top_tc*. The val attribute of the vMerge element on the single remaining cell is set to *vMerge*. If *vMerge* is |None|, the vMerge element is removed if present.'
def _span_to_width(self, grid_width, top_tc, vMerge):
self._move_content_to(top_tc) while (self.grid_span < grid_width): self._swallow_next_tc(grid_width, top_tc) self.vMerge = vMerge
'Extend the horizontal span of this `w:tc` element to incorporate the following `w:tc` element in the row and then delete that following `w:tc` element. Any content in the following `w:tc` element is appended to the content of *top_tc*. The width of the following `w:tc` element is added to this one, if present. Raises |InvalidSpanError| if the width of the resulting cell is greater than *grid_width* or if there is no next `<w:tc>` element in the row.'
def _swallow_next_tc(self, grid_width, top_tc):
def raise_on_invalid_swallow(next_tc): if (next_tc is None): raise InvalidSpanError(u'not enough grid columns') if ((self.grid_span + next_tc.grid_span) > grid_width): raise InvalidSpanError(u'span is not rectangular') next_tc = self._next_tc raise_on_invalid_swallow(next_tc) next_tc._move_content_to(top_tc) self._add_width_of(next_tc) self.grid_span += next_tc.grid_span next_tc._remove()
'The tbl element this tc element appears in.'
@property def _tbl(self):
return self.xpath(u'./ancestor::w:tbl[position()=1]')[0]
'The `w:tc` element immediately above this one in its grid column.'
@property def _tc_above(self):
return self._tr_above.tc_at_grid_col(self._grid_col)
'The tc element immediately below this one in its grid column.'
@property def _tc_below(self):
tr_below = self._tr_below if (tr_below is None): return None return tr_below.tc_at_grid_col(self._grid_col)
'The tr element this tc element appears in.'
@property def _tr(self):
return self.xpath(u'./ancestor::w:tr[position()=1]')[0]
'The tr element prior in sequence to the tr this cell appears in. Raises |ValueError| if called on a cell in the top-most row.'
@property def _tr_above(self):
tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) if (tr_idx == 0): raise ValueError(u'no tr above topmost tr') return tr_lst[(tr_idx - 1)]
'The tr element next in sequence after the tr this cell appears in, or |None| if this cell appears in the last row.'
@property def _tr_below(self):
tr_lst = self._tbl.tr_lst tr_idx = tr_lst.index(self._tr) try: return tr_lst[(tr_idx + 1)] except IndexError: return None
'The row index of the tr element this tc element appears in.'
@property def _tr_idx(self):
return self._tbl.tr_lst.index(self._tr)
'The integer number of columns this cell spans. Determined by ./w:gridSpan/@val, it defaults to 1.'
@property def grid_span(self):
gridSpan = self.gridSpan if (gridSpan is None): return 1 return gridSpan.val
'The value of the ./w:vMerge/@val attribute, or |None| if the w:vMerge element is not present.'
@property def vMerge_val(self):
vMerge = self.vMerge if (vMerge is None): return None return vMerge.val
'Return the EMU length value represented in the ``<w:tcW>`` child element or |None| if not present or its type is not \'dxa\'.'
@property def width(self):
tcW = self.tcW if (tcW is None): return None return tcW.width
'Return a newly added CT_NumLvl (<w:lvlOverride>) element having its ``ilvl`` attribute set to *ilvl*.'
def add_lvlOverride(self, ilvl):
return self._add_lvlOverride(ilvl=ilvl)
'Return a new ``<w:num>`` element having numId of *num_id* and having a ``<w:abstractNumId>`` child with val attribute set to *abstractNum_id*.'
@classmethod def new(cls, num_id, abstractNum_id):
num = OxmlElement('w:num') num.numId = num_id abstractNumId = CT_DecimalNumber.new('w:abstractNumId', abstractNum_id) num.append(abstractNumId) return num
'Return a newly added CT_DecimalNumber element having tagname ``w:startOverride`` and ``val`` attribute set to *val*.'
def add_startOverride(self, val):
return self._add_startOverride(val=val)
'Return a newly added CT_Num (<w:num>) element referencing the abstract numbering definition identified by *abstractNum_id*.'
def add_num(self, abstractNum_id):
next_num_id = self._next_numId num = CT_Num.new(next_num_id, abstractNum_id) return self._insert_num(num)
'Return the ``<w:num>`` child element having ``numId`` attribute matching *numId*.'
def num_having_numId(self, numId):
xpath = ('./w:num[@w:numId="%d"]' % numId) try: return self.xpath(xpath)[0] except IndexError: raise KeyError(('no <w:num> element with numId %d' % numId))