| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef POWER_POINT7_STRUCT |
| 35 |
# define POWER_POINT7_STRUCT |
| 36 |
|
| 37 |
#include <string> |
| 38 |
#include <sstream> |
| 39 |
|
| 40 |
#include "libmwaw_internal.hxx" |
| 41 |
|
| 42 |
#include "MWAWDebug.hxx" |
| 43 |
#include "MWAWInputStream.hxx" |
| 44 |
|
| 45 |
/** \brief namespace used to define basic struct of a Microsoft PowerPoint 95 files (Windows) |
| 46 |
*/ |
| 47 |
namespace PowerPoint7Struct |
| 48 |
{ |
| 49 |
//! a slide id |
| 50 |
struct SlideId { |
| 51 |
explicit SlideId(unsigned long id=0) |
| 52 |
: m_id(int(id&0x7fffffffL)) |
| 53 |
, m_isMaster((id&0x80000000L) ? true : false) |
| 54 |
, m_inNotes(false) |
| 55 |
, m_inHandout(false) |
| 56 |
{ |
| 57 |
} |
| 58 |
//! returns true if the id is valid |
| 59 |
bool isValid() const |
| 60 |
{ |
| 61 |
return m_isMaster || m_inHandout || m_id!=0; |
| 62 |
} |
| 63 |
//! operator< |
| 64 |
bool operator<(SlideId const &id) const |
| 65 |
{ |
| 66 |
if (m_isMaster!=id.m_isMaster) return m_isMaster; |
| 67 |
if (m_inNotes!=id.m_inNotes) return m_inNotes; |
| 68 |
if (m_inHandout!=id.m_inHandout) return m_inHandout; |
| 69 |
return m_id < id.m_id; |
| 70 |
} |
| 71 |
//! operator== |
| 72 |
bool operator==(SlideId const &id) const |
| 73 |
{ |
| 74 |
if (m_isMaster!=id.m_isMaster) return false; |
| 75 |
if (m_inNotes!=id.m_inNotes) return false; |
| 76 |
if (m_inHandout!=id.m_inHandout) return false; |
| 77 |
return m_id == id.m_id; |
| 78 |
} |
| 79 |
//! operator== |
| 80 |
bool operator!=(SlideId const &id) const |
| 81 |
{ |
| 82 |
return !operator==(id); |
| 83 |
} |
| 84 |
//! operator<< |
| 85 |
friend std::ostream &operator<<(std::ostream &o, SlideId const &id) |
| 86 |
{ |
| 87 |
if (id.m_isMaster) |
| 88 |
o << "MS" << id.m_id; |
| 89 |
else if (id.m_id) |
| 90 |
o << "S" << id.m_id; |
| 91 |
if (id.m_inNotes) |
| 92 |
o << "[note]"; |
| 93 |
if (id.m_inHandout) |
| 94 |
o << "Handout"; |
| 95 |
return o; |
| 96 |
} |
| 97 |
//! the slide id |
| 98 |
int m_id; |
| 99 |
//! a flag to know if this is a master slide or a normal slide |
| 100 |
bool m_isMaster; |
| 101 |
//! a flag to know if the content is in the notes part |
| 102 |
bool m_inNotes; |
| 103 |
//! a flag to know if the content is in the handout part |
| 104 |
bool m_inHandout; |
| 105 |
}; |
| 106 |
//! a zone header of a PowerPoint7Parser |
| 107 |
struct Zone { |
| 108 |
//! constructor |
| 109 |
Zone() : m_type(0), m_dataSize(0) |
| 110 |
{ |
| 111 |
for (auto &val : m_values) val=0; |
| 112 |
} |
| 113 |
//! try to read a zone header |
| 114 |
bool read(MWAWInputStreamPtr stream, long endPos=-1); |
| 115 |
//! returns a basic name |
| 116 |
std::string getName() const |
| 117 |
{ |
| 118 |
std::stringstream s; |
| 119 |
s << "Zone" << std::hex << m_type << std::dec << "A"; |
| 120 |
return s.str(); |
| 121 |
} |
| 122 |
//! operator<< |
| 123 |
friend std::ostream &operator<<(std::ostream &o, Zone const &z) |
| 124 |
{ |
| 125 |
for (int i=0; i<6; ++i) { |
| 126 |
if (z.m_values[i]) o << "z" << i << "=" << z.m_values[i] << ","; |
| 127 |
} |
| 128 |
return o; |
| 129 |
} |
| 130 |
//! the type |
| 131 |
int m_type; |
| 132 |
//! the data size |
| 133 |
long m_dataSize; |
| 134 |
//! some value |
| 135 |
int m_values[6]; |
| 136 |
}; |
| 137 |
} |
| 138 |
#endif |
| 139 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |