| 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) 2006 Ariya Hidayat ([email protected]) |
| 18 |
* Copyright (C) 2004 Marc Oude Kotte ([email protected]) |
| 19 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 20 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 21 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 22 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 23 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 24 |
* |
| 25 |
* |
| 26 |
* All Rights Reserved. |
| 27 |
* |
| 28 |
* For minor contributions see the git repository. |
| 29 |
* |
| 30 |
* Alternatively, the contents of this file may be used under the terms of |
| 31 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 32 |
* in which case the provisions of the LGPLv2+ are applicable |
| 33 |
* instead of those above. |
| 34 |
*/ |
| 35 |
|
| 36 |
#include <string.h> |
| 37 |
|
| 38 |
#include <map> |
| 39 |
#include <sstream> |
| 40 |
#include <string> |
| 41 |
|
| 42 |
#include <librevenge/librevenge.h> |
| 43 |
#include <libmwaw/libmwaw.hxx> |
| 44 |
|
| 45 |
#include "libmwaw_internal.hxx" |
| 46 |
|
| 47 |
#include "MWAWPropertyHandler.hxx" |
| 48 |
|
| 49 |
#include "MWAWGraphicEncoder.hxx" |
| 50 |
|
| 51 |
//! a name space used to define internal data of MWAWGraphicEncoder |
| 52 |
namespace MWAWGraphicEncoderInternal |
| 53 |
{ |
| 54 |
//! the state of a MWAWGraphicEncoder |
| 55 |
struct State { |
| 56 |
//! constructor |
| 57 |
State() |
| 58 |
: m_encoder() |
| 59 |
{ |
| 60 |
} |
| 61 |
//! the encoder |
| 62 |
MWAWPropertyHandlerEncoder m_encoder; |
| 63 |
}; |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
MWAWGraphicEncoder::MWAWGraphicEncoder() |
| 68 |
: librevenge::RVNGDrawingInterface() |
| 69 |
, m_state(new MWAWGraphicEncoderInternal::State) |
| 70 |
{ |
| 71 |
} |
| 72 |
|
| 73 |
MWAWGraphicEncoder::~MWAWGraphicEncoder() |
| 74 |
{ |
| 75 |
} |
| 76 |
|
| 77 |
bool MWAWGraphicEncoder::getBinaryResult(MWAWEmbeddedObject &result) |
| 78 |
{ |
| 79 |
librevenge::RVNGBinaryData data; |
| 80 |
if (!m_state->m_encoder.getData(data)) |
| 81 |
return false; |
| 82 |
result=MWAWEmbeddedObject(data, "image/mwaw-odg"); |
| 83 |
return true; |
| 84 |
} |
| 85 |
|
| 86 |
void MWAWGraphicEncoder::startDocument(const librevenge::RVNGPropertyList &list) |
| 87 |
{ |
| 88 |
m_state->m_encoder.insertElement("StartDocument", list); |
| 89 |
} |
| 90 |
|
| 91 |
void MWAWGraphicEncoder::endDocument() |
| 92 |
{ |
| 93 |
m_state->m_encoder.insertElement("EndDocument"); |
| 94 |
} |
| 95 |
|
| 96 |
void MWAWGraphicEncoder::setDocumentMetaData(const librevenge::RVNGPropertyList &list) |
| 97 |
{ |
| 98 |
m_state->m_encoder.insertElement("SetDocumentMetaData", list); |
| 99 |
} |
| 100 |
|
| 101 |
void MWAWGraphicEncoder::defineEmbeddedFont(const librevenge::RVNGPropertyList &list) |
| 102 |
{ |
| 103 |
m_state->m_encoder.insertElement("DefineEmbeddedFont", list); |
| 104 |
} |
| 105 |
|
| 106 |
void MWAWGraphicEncoder::startPage(const librevenge::RVNGPropertyList &list) |
| 107 |
{ |
| 108 |
m_state->m_encoder.insertElement("StartPage", list); |
| 109 |
} |
| 110 |
|
| 111 |
void MWAWGraphicEncoder::endPage() |
| 112 |
{ |
| 113 |
m_state->m_encoder.insertElement("EndPage"); |
| 114 |
} |
| 115 |
|
| 116 |
void MWAWGraphicEncoder::startMasterPage(const librevenge::RVNGPropertyList &list) |
| 117 |
{ |
| 118 |
m_state->m_encoder.insertElement("StartMasterPage", list); |
| 119 |
} |
| 120 |
|
| 121 |
void MWAWGraphicEncoder::endMasterPage() |
| 122 |
{ |
| 123 |
m_state->m_encoder.insertElement("EndMasterPage"); |
| 124 |
} |
| 125 |
|
| 126 |
void MWAWGraphicEncoder::setStyle(const librevenge::RVNGPropertyList &list) |
| 127 |
{ |
| 128 |
m_state->m_encoder.insertElement("SetStyle", list); |
| 129 |
} |
| 130 |
|
| 131 |
void MWAWGraphicEncoder::startLayer(const librevenge::RVNGPropertyList &list) |
| 132 |
{ |
| 133 |
m_state->m_encoder.insertElement("StartLayer", list); |
| 134 |
} |
| 135 |
|
| 136 |
void MWAWGraphicEncoder::endLayer() |
| 137 |
{ |
| 138 |
m_state->m_encoder.insertElement("EndLayer"); |
| 139 |
} |
| 140 |
|
| 141 |
void MWAWGraphicEncoder::startEmbeddedGraphics(const librevenge::RVNGPropertyList &list) |
| 142 |
{ |
| 143 |
m_state->m_encoder.insertElement("StartEmbeddedGraphics", list); |
| 144 |
} |
| 145 |
|
| 146 |
void MWAWGraphicEncoder::endEmbeddedGraphics() |
| 147 |
{ |
| 148 |
m_state->m_encoder.insertElement("StartEmbeddedGraphics"); |
| 149 |
} |
| 150 |
|
| 151 |
void MWAWGraphicEncoder::openGroup(const librevenge::RVNGPropertyList &list) |
| 152 |
{ |
| 153 |
m_state->m_encoder.insertElement("OpenGroup", list); |
| 154 |
} |
| 155 |
|
| 156 |
void MWAWGraphicEncoder::closeGroup() |
| 157 |
{ |
| 158 |
m_state->m_encoder.insertElement("CloseGroup"); |
| 159 |
} |
| 160 |
|
| 161 |
void MWAWGraphicEncoder::drawRectangle(const librevenge::RVNGPropertyList &list) |
| 162 |
{ |
| 163 |
m_state->m_encoder.insertElement("DrawRectangle", list); |
| 164 |
} |
| 165 |
|
| 166 |
void MWAWGraphicEncoder::drawEllipse(const librevenge::RVNGPropertyList &list) |
| 167 |
{ |
| 168 |
m_state->m_encoder.insertElement("DrawEllipse", list); |
| 169 |
} |
| 170 |
|
| 171 |
void MWAWGraphicEncoder::drawPolygon(const librevenge::RVNGPropertyList &vertices) |
| 172 |
{ |
| 173 |
m_state->m_encoder.insertElement("DrawPolygon", vertices); |
| 174 |
} |
| 175 |
|
| 176 |
void MWAWGraphicEncoder::drawPolyline(const librevenge::RVNGPropertyList &vertices) |
| 177 |
{ |
| 178 |
m_state->m_encoder.insertElement("DrawPolyline", vertices); |
| 179 |
} |
| 180 |
|
| 181 |
void MWAWGraphicEncoder::drawPath(const librevenge::RVNGPropertyList &path) |
| 182 |
{ |
| 183 |
m_state->m_encoder.insertElement("DrawPath", path); |
| 184 |
} |
| 185 |
|
| 186 |
void MWAWGraphicEncoder::drawConnector(const librevenge::RVNGPropertyList &list) |
| 187 |
{ |
| 188 |
m_state->m_encoder.insertElement("DrawConnector", list); |
| 189 |
} |
| 190 |
|
| 191 |
void MWAWGraphicEncoder::drawGraphicObject(const librevenge::RVNGPropertyList &list) |
| 192 |
{ |
| 193 |
m_state->m_encoder.insertElement("DrawGraphicObject", list); |
| 194 |
} |
| 195 |
|
| 196 |
void MWAWGraphicEncoder::startTextObject(const librevenge::RVNGPropertyList &list) |
| 197 |
{ |
| 198 |
m_state->m_encoder.insertElement("StartTextObject", list); |
| 199 |
} |
| 200 |
|
| 201 |
void MWAWGraphicEncoder::endTextObject() |
| 202 |
{ |
| 203 |
m_state->m_encoder.insertElement("EndTextObject"); |
| 204 |
} |
| 205 |
|
| 206 |
void MWAWGraphicEncoder::startTableObject(const librevenge::RVNGPropertyList &list) |
| 207 |
{ |
| 208 |
m_state->m_encoder.insertElement("StartTableObject", list); |
| 209 |
} |
| 210 |
|
| 211 |
void MWAWGraphicEncoder::endTableObject() |
| 212 |
{ |
| 213 |
m_state->m_encoder.insertElement("EndTableObject"); |
| 214 |
} |
| 215 |
|
| 216 |
void MWAWGraphicEncoder::openTableRow(const librevenge::RVNGPropertyList &list) |
| 217 |
{ |
| 218 |
m_state->m_encoder.insertElement("OpenTableRow", list); |
| 219 |
} |
| 220 |
|
| 221 |
void MWAWGraphicEncoder::closeTableRow() |
| 222 |
{ |
| 223 |
m_state->m_encoder.insertElement("CloseTableRow"); |
| 224 |
} |
| 225 |
|
| 226 |
void MWAWGraphicEncoder::openTableCell(const librevenge::RVNGPropertyList &list) |
| 227 |
{ |
| 228 |
m_state->m_encoder.insertElement("OpenTableCell", list); |
| 229 |
} |
| 230 |
|
| 231 |
void MWAWGraphicEncoder::closeTableCell() |
| 232 |
{ |
| 233 |
m_state->m_encoder.insertElement("CloseTableCell"); |
| 234 |
} |
| 235 |
|
| 236 |
void MWAWGraphicEncoder::insertCoveredTableCell(const librevenge::RVNGPropertyList &list) |
| 237 |
{ |
| 238 |
m_state->m_encoder.insertElement("InsertCoveredTableCell", list); |
| 239 |
} |
| 240 |
|
| 241 |
void MWAWGraphicEncoder::insertTab() |
| 242 |
{ |
| 243 |
m_state->m_encoder.insertElement("InsertTab"); |
| 244 |
} |
| 245 |
|
| 246 |
void MWAWGraphicEncoder::insertSpace() |
| 247 |
{ |
| 248 |
m_state->m_encoder.insertElement("InsertSpace"); |
| 249 |
} |
| 250 |
|
| 251 |
void MWAWGraphicEncoder::insertText(const librevenge::RVNGString &text) |
| 252 |
{ |
| 253 |
m_state->m_encoder.characters(text); |
| 254 |
} |
| 255 |
|
| 256 |
void MWAWGraphicEncoder::insertLineBreak() |
| 257 |
{ |
| 258 |
m_state->m_encoder.insertElement("InsertLineBreak"); |
| 259 |
} |
| 260 |
|
| 261 |
void MWAWGraphicEncoder::insertField(const librevenge::RVNGPropertyList &list) |
| 262 |
{ |
| 263 |
m_state->m_encoder.insertElement("InsertField", list); |
| 264 |
} |
| 265 |
|
| 266 |
void MWAWGraphicEncoder::openLink(const librevenge::RVNGPropertyList &list) |
| 267 |
{ |
| 268 |
m_state->m_encoder.insertElement("OpenLink", list); |
| 269 |
} |
| 270 |
|
| 271 |
void MWAWGraphicEncoder::closeLink() |
| 272 |
{ |
| 273 |
m_state->m_encoder.insertElement("CloseLink"); |
| 274 |
} |
| 275 |
|
| 276 |
void MWAWGraphicEncoder::openOrderedListLevel(const librevenge::RVNGPropertyList &list) |
| 277 |
{ |
| 278 |
m_state->m_encoder.insertElement("OpenOrderedListLevel", list); |
| 279 |
} |
| 280 |
|
| 281 |
void MWAWGraphicEncoder::openUnorderedListLevel(const librevenge::RVNGPropertyList &list) |
| 282 |
{ |
| 283 |
m_state->m_encoder.insertElement("OpenUnorderedListLevel", list); |
| 284 |
} |
| 285 |
|
| 286 |
void MWAWGraphicEncoder::closeOrderedListLevel() |
| 287 |
{ |
| 288 |
m_state->m_encoder.insertElement("CloseOrderedListLevel"); |
| 289 |
} |
| 290 |
|
| 291 |
void MWAWGraphicEncoder::closeUnorderedListLevel() |
| 292 |
{ |
| 293 |
m_state->m_encoder.insertElement("CloseOrderedListLevel"); |
| 294 |
} |
| 295 |
|
| 296 |
void MWAWGraphicEncoder::openListElement(const librevenge::RVNGPropertyList &list) |
| 297 |
{ |
| 298 |
m_state->m_encoder.insertElement("OpenListElement", list); |
| 299 |
} |
| 300 |
|
| 301 |
void MWAWGraphicEncoder::closeListElement() |
| 302 |
{ |
| 303 |
m_state->m_encoder.insertElement("CloseListElement"); |
| 304 |
} |
| 305 |
|
| 306 |
void MWAWGraphicEncoder::defineParagraphStyle(const librevenge::RVNGPropertyList &list) |
| 307 |
{ |
| 308 |
m_state->m_encoder.insertElement("DefineParagraphStyle", list); |
| 309 |
} |
| 310 |
|
| 311 |
void MWAWGraphicEncoder::openParagraph(const librevenge::RVNGPropertyList &list) |
| 312 |
{ |
| 313 |
m_state->m_encoder.insertElement("OpenParagraph", list); |
| 314 |
} |
| 315 |
|
| 316 |
void MWAWGraphicEncoder::closeParagraph() |
| 317 |
{ |
| 318 |
m_state->m_encoder.insertElement("CloseParagraph"); |
| 319 |
} |
| 320 |
|
| 321 |
void MWAWGraphicEncoder::defineCharacterStyle(const librevenge::RVNGPropertyList &list) |
| 322 |
{ |
| 323 |
m_state->m_encoder.insertElement("DefineCharacterStyle", list); |
| 324 |
} |
| 325 |
|
| 326 |
void MWAWGraphicEncoder::openSpan(const librevenge::RVNGPropertyList &list) |
| 327 |
{ |
| 328 |
m_state->m_encoder.insertElement("OpenSpan", list); |
| 329 |
} |
| 330 |
|
| 331 |
void MWAWGraphicEncoder::closeSpan() |
| 332 |
{ |
| 333 |
m_state->m_encoder.insertElement("CloseSpan"); |
| 334 |
} |
| 335 |
|
| 336 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |