[Libreoffice-commits] libvisio.git: src/lib
Miklos Vajna
vmiklos at collabora.co.uk
Thu Dec 25 03:16:26 PST 2014
src/lib/VSDXMetaData.cpp | 92 +++++------------------------------------------
src/lib/VSDXMetaData.h | 7 +--
2 files changed, 12 insertions(+), 87 deletions(-)
New commits:
commit a3d033a7561cfca087d86632e2e3f0b215a1222e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Dec 25 12:16:00 2014 +0100
VSDXMetaData: merge read*() methods into a single one
Change-Id: I218bca925d5fc86d7b492e05b2bebbca2e5675d9
diff --git a/src/lib/VSDXMetaData.cpp b/src/lib/VSDXMetaData.cpp
index 3f0d9bc..b9ba9bb 100644
--- a/src/lib/VSDXMetaData.cpp
+++ b/src/lib/VSDXMetaData.cpp
@@ -20,94 +20,22 @@ libvisio::VSDXMetaData::~VSDXMetaData()
{
}
-void libvisio::VSDXMetaData::readTitle(xmlTextReaderPtr reader)
+librevenge::RVNGString libvisio::VSDXMetaData::readString(xmlTextReaderPtr reader, int stringTokenId)
{
int ret = 1;
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
- librevenge::RVNGString title;
+ librevenge::RVNGString string;
do
{
ret = xmlTextReaderRead(reader);
tokenId = getElementToken(reader);
tokenType = xmlTextReaderNodeType(reader);
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
- title.append((const char *)xmlTextReaderConstValue(reader));
+ string.append((const char *)xmlTextReaderConstValue(reader));
}
- while ((XML_DC_TITLE != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
- m_metaData.insert("dc:title", title);
-}
-
-void libvisio::VSDXMetaData::readSubject(xmlTextReaderPtr reader)
-{
- int ret = 1;
- int tokenId = XML_TOKEN_INVALID;
- int tokenType = -1;
- librevenge::RVNGString subject;
- do
- {
- ret = xmlTextReaderRead(reader);
- tokenId = getElementToken(reader);
- tokenType = xmlTextReaderNodeType(reader);
- if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
- subject.append((const char *)xmlTextReaderConstValue(reader));
- }
- while ((XML_DC_SUBJECT != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
- 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;
- int tokenId = XML_TOKEN_INVALID;
- int tokenType = -1;
- librevenge::RVNGString created;
- do
- {
- ret = xmlTextReaderRead(reader);
- tokenId = getElementToken(reader);
- tokenType = xmlTextReaderNodeType(reader);
- if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
- created.append((const char *)xmlTextReaderConstValue(reader));
- }
- while ((XML_DCTERMS_CREATED != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
- m_metaData.insert("meta:creation-date", created);
-}
-
-void libvisio::VSDXMetaData::readModified(xmlTextReaderPtr reader)
-{
- int ret = 1;
- int tokenId = XML_TOKEN_INVALID;
- int tokenType = -1;
- librevenge::RVNGString modified;
- do
- {
- ret = xmlTextReaderRead(reader);
- tokenId = getElementToken(reader);
- tokenType = xmlTextReaderNodeType(reader);
- if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT)
- modified.append((const char *)xmlTextReaderConstValue(reader));
- }
- while ((XML_DCTERMS_MODIFIED != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
- m_metaData.insert("dc:date", modified);
+ while ((stringTokenId != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret);
+ return string;
}
void libvisio::VSDXMetaData::readCoreProperties(xmlTextReaderPtr reader)
@@ -128,23 +56,23 @@ void libvisio::VSDXMetaData::readCoreProperties(xmlTextReaderPtr reader)
{
case XML_DC_TITLE:
if (tokenType == XML_READER_TYPE_ELEMENT)
- readTitle(reader);
+ m_metaData.insert("dc:title", readString(reader, XML_DC_TITLE));
break;
case XML_DC_SUBJECT:
if (tokenType == XML_READER_TYPE_ELEMENT)
- readSubject(reader);
+ m_metaData.insert("dc:subject", readString(reader, XML_DC_SUBJECT));
break;
case XML_DC_CREATOR:
if (tokenType == XML_READER_TYPE_ELEMENT)
- readCreator(reader);
+ m_metaData.insert("meta:initial-creator", readString(reader, XML_DC_CREATOR));
break;
case XML_DCTERMS_CREATED:
if (tokenType == XML_READER_TYPE_ELEMENT)
- readCreated(reader);
+ m_metaData.insert("meta:creation-date", readString(reader, XML_DCTERMS_CREATED));
break;
case XML_DCTERMS_MODIFIED:
if (tokenType == XML_READER_TYPE_ELEMENT)
- readModified(reader);
+ m_metaData.insert("dc:date", readString(reader, XML_DCTERMS_MODIFIED));
break;
default:
break;
diff --git a/src/lib/VSDXMetaData.h b/src/lib/VSDXMetaData.h
index 4ef382c..b18a0a1 100644
--- a/src/lib/VSDXMetaData.h
+++ b/src/lib/VSDXMetaData.h
@@ -16,6 +16,7 @@
namespace libvisio
{
+/// Parses docProps/core.xml stream of a VSDX file.
class VSDXMetaData
{
public:
@@ -30,11 +31,7 @@ private:
int getElementToken(xmlTextReaderPtr reader);
void readCoreProperties(xmlTextReaderPtr reader);
- void readTitle(xmlTextReaderPtr reader);
- void readSubject(xmlTextReaderPtr reader);
- void readCreator(xmlTextReaderPtr reader);
- void readCreated(xmlTextReaderPtr reader);
- void readModified(xmlTextReaderPtr reader);
+ librevenge::RVNGString readString(xmlTextReaderPtr reader, int stringTokenId);
librevenge::RVNGPropertyList m_metaData;
};
More information about the Libreoffice-commits
mailing list