VSDXMLHelper.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libvisio
00003  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
00017  *
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00025  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00026  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef __VSDXMLHELPER_H__
00031 #define __VSDXMLHELPER_H__
00032 
00033 #include <map>
00034 #include <string>
00035 #include <libwpd-stream/libwpd-stream.h>
00036 #include <libxml/xmlreader.h>
00037 #include "VSDTypes.h"
00038 
00039 namespace libvisio
00040 {
00041 
00042 // create an xmlTextReader pointer from a WPXInputStream pointer
00043 // needs to be freed using xmlTextReaderFree function.
00044 
00045 xmlTextReaderPtr xmlReaderForStream(WPXInputStream *input,
00046                                     const char *URL,
00047                                     const char *encoding,
00048                                     int options);
00049 
00050 Colour xmlStringToColour(const xmlChar *s);
00051 
00052 long xmlStringToLong(const xmlChar *s);
00053 
00054 double xmlStringToDouble(const xmlChar *s);
00055 
00056 bool xmlStringToBool(const xmlChar *s);
00057 
00058 
00059 class VSDCollector;
00060 
00061 // Helper classes to properly handle OPC relationships
00062 
00063 class VSDXRelationship
00064 {
00065 public:
00066   VSDXRelationship(xmlTextReaderPtr reader);
00067   VSDXRelationship();
00068   ~VSDXRelationship();
00069 
00070   void rebaseTarget(const char *baseDir);
00071 
00072   const std::string getId() const
00073   {
00074     return m_id;
00075   }
00076   const std::string getType() const
00077   {
00078     return m_type;
00079   }
00080   const std::string getTarget() const
00081   {
00082     return m_target;
00083   }
00084 
00085 private:
00086   std::string m_id;
00087   std::string m_type;
00088   std::string m_target;
00089 };
00090 
00091 class VSDXRelationships
00092 {
00093 public:
00094   VSDXRelationships(WPXInputStream *input);
00095   ~VSDXRelationships();
00096 
00097   void rebaseTargets(const char *baseDir);
00098 
00099   const VSDXRelationship *getRelationshipByType(const char *type) const;
00100   const VSDXRelationship *getRelationshipById(const char *id) const;
00101 
00102   bool empty() const
00103   {
00104     return m_relsByType.empty() && m_relsById.empty();
00105   }
00106 
00107 private:
00108   std::map<std::string, VSDXRelationship> m_relsByType;
00109   std::map<std::string, VSDXRelationship> m_relsById;
00110 };
00111 
00112 } // namespace libvisio
00113 
00114 #endif // __VSDXMLHELPER_H__
00115 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */