Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/docx/opc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ class RELATIONSHIP_TYPE:
"http://schemas.openxmlformats.org/package/2006/relationships/metada"
"ta/core-properties"
)
CORE_PROPERTIES_OFFICEDOCUMENT = (
"http://schemas.openxmlformats.org/officedocument/2006/relationships"
"/metadata/core-properties"
)
CUSTOM_PROPERTIES = (
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"
"/custom-properties"
Expand Down
12 changes: 9 additions & 3 deletions src/docx/opc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,15 @@ def _core_properties_part(self) -> CorePropertiesPart:
try:
return cast(CorePropertiesPart, self.part_related_by(RT.CORE_PROPERTIES))
except KeyError:
core_properties_part = CorePropertiesPart.default(self)
self.relate_to(core_properties_part, RT.CORE_PROPERTIES)
return core_properties_part
try:
office_document_part = self.part_related_by(RT.CORE_PROPERTIES_OFFICEDOCUMENT)
rel = self.relate_to(office_document_part, RT.CORE_PROPERTIES_OFFICEDOCUMENT)
self.rels[rel].reltype = RT.CORE_PROPERTIES
return cast(CorePropertiesPart, office_document_part)
except KeyError:
core_properties_part = CorePropertiesPart.default(self)
self.relate_to(core_properties_part, RT.CORE_PROPERTIES)
return core_properties_part


class Unmarshaller:
Expand Down
4 changes: 4 additions & 0 deletions src/docx/opc/rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def is_external(self) -> bool:
def reltype(self) -> str:
return self._reltype

@reltype.setter
def reltype(self, value: str):
self._reltype = value

@property
def rId(self) -> str:
return self._rId
Expand Down