[Libreoffice-commits] libvisio.git: src/lib src/test

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 24 01:20:21 PST 2014


 src/lib/VSDXMetaData.cpp    |   22 ++++++++++++++++++++++
 src/lib/VSDXMetaData.h      |    1 +
 src/lib/tokens.txt          |    1 +
 src/test/data/fdo86664.vsdx |binary
 src/test/importtest.cpp     |    1 +
 5 files changed, 25 insertions(+)

New commits:
commit a110b6351ae38eccd0bd089918941fbfea677397
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 24 10:19:19 2014 +0100

    VSDX: import <dc:creator>
    
    Sigh, ODF has <dc:creator> as well, but with different semantics.
    
    Change-Id: I9425dc1b45c3c3cd9a1a97fb31f0ee087044814e

diff --git a/src/lib/VSDXMetaData.cpp b/src/lib/VSDXMetaData.cpp
index 697d003..3f0d9bc 100644
--- a/src/lib/VSDXMetaData.cpp
+++ b/src/lib/VSDXMetaData.cpp
@@ -56,6 +56,24 @@ void libvisio::VSDXMetaData::readSubject(xmlTextReaderPtr reader)
   m_metaData.insert("dc:subject", subject);
 }
 
+void libvisio::VSDXMetaData::readCreator(xmlTextReaderPtr reader)
+{
+  int ret = 1;
+  int tokenId = XML_TOKEN_INVALID;
+  int tokenType = -1;
+  librevenge::RVNGString creator;
+  do
+  {
+    ret = xmlTextReaderRead(reader);
+    tokenId = getElementToken(reader);
+    tokenType = xmlTextReaderNodeType(reader);
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
+      creator.append((const char *)xmlTextReaderConstValue(reader));
+  }
+  while ((XML_DC_CREATOR != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
+  m_metaData.insert("meta:initial-creator", creator);
+}
+
 void libvisio::VSDXMetaData::readCreated(xmlTextReaderPtr reader)
 {
   int ret = 1;
@@ -116,6 +134,10 @@ void libvisio::VSDXMetaData::readCoreProperties(xmlTextReaderPtr reader)
       if (tokenType == XML_READER_TYPE_ELEMENT)
         readSubject(reader);
       break;
+    case XML_DC_CREATOR:
+      if (tokenType == XML_READER_TYPE_ELEMENT)
+        readCreator(reader);
+      break;
     case XML_DCTERMS_CREATED:
       if (tokenType == XML_READER_TYPE_ELEMENT)
         readCreated(reader);
diff --git a/src/lib/VSDXMetaData.h b/src/lib/VSDXMetaData.h
index f8a8f9c..4ef382c 100644
--- a/src/lib/VSDXMetaData.h
+++ b/src/lib/VSDXMetaData.h
@@ -32,6 +32,7 @@ private:
   void readCoreProperties(xmlTextReaderPtr reader);
   void readTitle(xmlTextReaderPtr reader);
   void readSubject(xmlTextReaderPtr reader);
+  void readCreator(xmlTextReaderPtr reader);
   void readCreated(xmlTextReaderPtr reader);
   void readModified(xmlTextReaderPtr reader);
 
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index 8e0db55..84cc90d 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -227,6 +227,7 @@ XForm
 XForm1D
 Y
 cp:coreProperties
+dc:creator
 dc:subject
 dc:title
 dcterms:created
diff --git a/src/test/data/fdo86664.vsdx b/src/test/data/fdo86664.vsdx
index 1aafa80..2cfd89a 100644
Binary files a/src/test/data/fdo86664.vsdx and b/src/test/data/fdo86664.vsdx differ
diff --git a/src/test/importtest.cpp b/src/test/importtest.cpp
index b98269a..b42d256 100644
--- a/src/test/importtest.cpp
+++ b/src/test/importtest.cpp
@@ -141,6 +141,7 @@ void ImportTest::testVsdxMetadataTitle()
   // The setDocumentMetaData() call was missing, so the node did not exist.
   assertXPath(m_doc, "/document/setDocumentMetaData", "title", "mytitle");
   assertXPath(m_doc, "/document/setDocumentMetaData", "subject", "mysubject");
+  assertXPath(m_doc, "/document/setDocumentMetaData", "initial-creator", "vmiklos creator");
   // Test <dcterms:created> and <dcterms:modified>.
   assertXPath(m_doc, "/document/setDocumentMetaData", "creation-date", "2014-11-24T10:35:17Z");
   assertXPath(m_doc, "/document/setDocumentMetaData", "date", "2014-11-24T10:41:22Z");


More information about the Libreoffice-commits mailing list