Commit 7364d4d8 authored by CharlieC's avatar CharlieC
Browse files

Add property for listing charts contained in a drawing.

--HG--
branch : 2.5
parent 0aaf87031ae4
......@@ -338,3 +338,21 @@ class SpreadsheetDrawing(Serialisable):
@property
def path(self):
return self._path.format(self._id)
@property
def _chart_rels(self):
"""
Get relationship information for each chart and bind anchor to it
"""
rels = []
anchors = self.absoluteAnchor + self.oneCellAnchor + self.twoCellAnchor
for anchor in anchors:
if anchor.graphicFrame is not None:
graphic = anchor.graphicFrame.graphic
rel = graphic.graphicData.chart
if rel is not None:
rel.anchor = anchor
rel.anchor.graphicFrame = None
rels.append(rel)
return rels
......@@ -303,9 +303,7 @@ class TestSpreadsheetDrawing:
node = fromstring(xml)
drawing = SpreadsheetDrawing.from_tree(node)
anchor = drawing.oneCellAnchor[0]
assert anchor._from.row == 28
assert anchor._from.col == 1
assert len(drawing._chart_rels) == 1
def test_write_rels(self, SpreadsheetDrawing):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment