MWAWPictOLEContainer.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* 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 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/* This header contains code specific to an ole object which can be stored in a
* WPXBinaryData
*/
#ifndef MWAW_PICT_OLECONTAINER
# define MWAW_PICT_OLECONTAINER
# include <assert.h>
# include <ostream>
# include <libwpd/libwpd.h>
# include "libmwaw_internal.hxx"
# include "MWAWPict.hxx"
class WPXBinaryData;
class MWAWPictOLEContainer : public MWAWPict
{
public:
virtual Type getType() const {
return MWAWPict::OleContainer;
}
virtual bool getBinary(WPXBinaryData &res, std::string &s) const {
if (!valid() || isEmpty()) return false;
s = "object/ole";
res = m_data;
return true;
}
virtual bool valid() const {
return !m_empty;
}
bool isEmpty() const {
return m_empty;
}
static MWAWPictOLEContainer *get(MWAWInputStreamPtr input, int size) {
MWAWPictOLEContainer *res = 0L;
Box2f box;
if (checkOrGet(input, size, box, &res) == MWAW_R_BAD) return 0L;
return res;
}
virtual int cmp(MWAWPict const &a) const {
int diff = MWAWPict::cmp(a);
if (diff) return diff;
MWAWPictOLEContainer const &aPict = static_cast<MWAWPictOLEContainer const &>(a);
diff = (int) m_empty - (int) aPict.m_empty;
if (diff) return (diff < 0) ? -1 : 1;
long diffL = (long) m_data.size() - (long) aPict.m_data.size();
if (diffL) return (diffL < 0) ? -1 : 1;
return 0;
}
protected:
MWAWPictOLEContainer(Box2f ) : m_data(), m_empty(false) { }
MWAWPictOLEContainer( ) : m_data(), m_empty(false) { }
static ReadResult checkOrGet(MWAWInputStreamPtr input, int size,
Box2f &box, MWAWPictOLEContainer **result = 0L);
WPXBinaryData m_data;
bool m_empty;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWPictOLEContainer::cmp
virtual int cmp(MWAWPict const &a) const
a virtual function used to obtain a strict order, must be redefined in the subs class ...
Definition: MWAWPictOLEContainer.hxx:91
libmwaw_internal.hxx
Box2< float >
MWAWPict::ReadResult
ReadResult
an enum to defined the result of a parsing use by some picture's classes which can read their data ...
Definition: MWAWPict.hxx:77
MWAWPictOLEContainer::m_empty
bool m_empty
some picture can be valid but empty
Definition: MWAWPictOLEContainer.hxx:120
MWAWPictOLEContainer::MWAWPictOLEContainer
MWAWPictOLEContainer()
Definition: MWAWPictOLEContainer.hxx:107
MWAWPict::cmp
virtual int cmp(MWAWPict const &a) const
a virtual function used to obtain a strict order, must be redefined in the subs class ...
Definition: MWAWPict.hxx:102
MWAWPictOLEContainer::valid
virtual bool valid() const
returns true if the picture is valid
Definition: MWAWPictOLEContainer.hxx:70
MWAWPictOLEContainer::isEmpty
bool isEmpty() const
returns true if the picture is valid and has size 0 or contains no oleContainer
Definition: MWAWPictOLEContainer.hxx:75
MWAWPict::OleContainer
Definition: MWAWPict.hxx:67
MWAWPict.hxx
MWAWPictOLEContainer::checkOrGet
static ReadResult checkOrGet(MWAWInputStreamPtr input, int size, Box2f &box, MWAWPictOLEContainer **result=0L)
checks if size is >= 0
Definition: MWAWPictOLEContainer.cxx:45
MWAWPictOLEContainer::getBinary
virtual bool getBinary(WPXBinaryData &res, std::string &s) const
returns the final WPXBinary oleContainer
Definition: MWAWPictOLEContainer.hxx:61
MWAWPict::Type
Type
the different picture types:
Definition: MWAWPict.hxx:67
MWAWPictOLEContainer::getType
virtual Type getType() const
returns the picture type
Definition: MWAWPictOLEContainer.hxx:56
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MWAWPictOLEContainer::m_data
WPXBinaryData m_data
the oleContainer size (without the empty header of 512 characters)
Definition: MWAWPictOLEContainer.hxx:117
MWAWPict::MWAW_R_BAD
Definition: MWAWPict.hxx:77
MWAWPictOLEContainer::MWAWPictOLEContainer
MWAWPictOLEContainer(Box2f)
protected constructor: use check to construct a picture
Definition: MWAWPictOLEContainer.hxx:106
MWAWPictOLEContainer
an abstract class which defines a simple container to store ole data
Definition: MWAWPictOLEContainer.hxx:52
MWAWPict
Generic function used to define/store a picture.
Definition: MWAWPict.hxx:53