Commit 07e26ff2 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

support adding a new property in setMetadata.

parent 257be770
......@@ -232,11 +232,18 @@ class UnoConverter(object):
"""
document_properties = self.document_loaded.getDocumentProperties()
user_defined_properties = document_properties.getUserDefinedProperties()
new_properties = []
for prop, value in metadata.items():
for container in [document_properties, user_defined_properties]:
if getattr(container, prop, None) is not None:
setattr(container, prop, value)
container
break
else:
new_properties.append([prop, value])
for prop, value in new_properties:
if isinstance(value, unicode):
user_defined_properties.addProperty(prop, 0, '')
user_defined_properties.setPropertyValue(prop, value)
self.document_loaded.store()
self.document_loaded.dispose()
......
......@@ -161,10 +161,9 @@ class TestServer(TestCase):
return [
# Test server using method updateFileMetadata
(join('data', 'testMetadata.odt'), "odt", dict(Title='testSetMetadata')),
# XXX adding a custom metadata is not yet supported
# # Test server using method updateFileMetadata with unsual metadata
# (join('data', 'testMetadata.odt'), "odt", dict(Reference='testSet'+
# 'Metadata')),
# Test server using method updateFileMetadata with unsual metadata
(join('data', 'testMetadata.odt'), "odt", dict(Reference='testSet'+
'Metadata')),
# Test document that already has metadata. Check if the metadata is
# not deleted, but updated
(join('data', 'testMetadata.odt'), "odt", dict(Title='cloudooo Title')),
......@@ -187,9 +186,8 @@ class TestServer(TestCase):
self.assertEquals(self._getFileType(new_odf_data),
'application/vnd.oasis.opendocument.text')
metadata_dict = self.proxy.getFileMetadataItemList(new_odf_data, 'odt')
# XXX adding a custom metadata is not yet supported
# self.assertEquals(metadata_dict.get("Reference"), "new value")
# self.assertEquals(metadata_dict.get("Something"), "ABC")
self.assertEquals(metadata_dict.get("Reference"), "new value")
self.assertEquals(metadata_dict.get("Something"), "ABC")
def ConvertScenarioList(self):
return [
......
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