WPS8Struct.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* libwps
* Version: MPL 2.0 / LGPLv2.1+
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Major Contributor(s):
* Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU Lesser General Public License Version 2.1 or later
* (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
* applicable instead of those above.
*
* For further information visit http://libwps.sourceforge.net
*/
#ifndef WPS8_STRUCT_H
#define WPS8_STRUCT_H
#include <string>
#include <vector>
#include "libwps_internal.h"
// Internal structure
namespace WPS8Struct
{
struct FileData;
bool readData(WPXInputStreamPtr input, long endPos, FileData &dt, std::string &error);
bool readBlockData(WPXInputStreamPtr input, long endPos, FileData &dt, std::string &error);
std::ostream &operator<< (std::ostream &o, FileData const &dt);
struct FileData
{
FileData() : m_value(0), m_text(""), m_recursData(), m_type(-1), m_id(-1), m_beginOffset(-1), m_endOffset(-1), m_input() {}
bool isBad() const
{
return m_type==-1;
}
bool hasStr() const
{
return m_text.size() != 0;
}
bool isNumber() const
{
return !hasStr() && (m_type & 0x30) != 0;
}
uint32_t getRGBColor() const
{
uint32_t col = (uint32_t) (m_value&0xFFFFFF);
return (((col>>16)&0xFF) |(col&0xFF00)|((col&0xFF)<<16));
}
WPSBorder::Style getBorderStyle(std::string &mess) const;
bool isBool() const
{
return !hasStr() && (m_type & 0xb0)==0;
}
bool isTrue() const
{
return m_type == 0xa;
}
bool isFalse() const
{
return m_type == 0x2;
}
bool isArray() const
{
return !hasStr() && (m_type & 0x80)==0x80;
}
bool isRead() const
{
return (m_type & 0x80) !=0x80 || !(m_input.get() && m_beginOffset > 0 && m_endOffset >= m_beginOffset+2);
}
int type() const
{
if (m_type == 0xa) return 2;
return m_type;
}
int id() const
{
return m_id;
}
bool readArrayBlock() const;
long m_value;
std::string m_text;
std::vector<FileData> m_recursData;
long begin() const
{
return m_beginOffset;
}
long end() const
{
return m_endOffset;
}
protected:
static std::string createErrorString(WPXInputStreamPtr input, long endPos);
int m_type;
int m_id;
long m_beginOffset , m_endOffset ;
WPXInputStreamPtr m_input;
friend std::ostream &operator<< (std::ostream &o, FileData const &dt);
friend bool readData(WPXInputStreamPtr input, long endPos, FileData &dt, std::string &error);
friend bool readBlockData(WPXInputStreamPtr input, long endPos, FileData &dt, std::string &error);
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */