StarGraphicStruct.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 -*- */
/* libstaroffice
* 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.
*/
#ifndef STAR_GRAPHIC_STRUCT
# define STAR_GRAPHIC_STRUCT
#include <ostream>
#include <string>
#include <vector>
#include "libstaroffice_internal.hxx"
class StarBitmap;
class StarObject;
class StarZone;
namespace StarGraphicStruct
{
class StarBrush
{
public:
StarBrush()
: m_transparency(0)
, m_color(STOFFColor::white())
, m_fillColor(STOFFColor::white())
, m_style(0)
, m_position(0)
, m_linkName("")
, m_filterName("")
, m_extra("")
{
}
bool isEmpty() const
{
return m_style<=0 || m_style>=11 || m_transparency>=255;
}
bool hasUniqueColor() const
{
return m_style==1;
}
bool getColor(STOFFColor &color) const;
bool getPattern(STOFFEmbeddedObject &object, STOFFVec2i &sz) const;
bool read(StarZone &zone, int nVers, long endPos, StarObject &document);
friend std::ostream &operator<<(std::ostream &o, StarBrush const &brush);
int m_transparency;
STOFFColor m_color;
STOFFColor m_fillColor;
int m_style;
int m_position;
librevenge::RVNGString m_linkName;
librevenge::RVNGString m_filterName;
std::string m_extra;
};
class StarGraphic
{
public:
StarGraphic()
: m_object()
, m_bitmap()
{
}
bool read(StarZone &zone, long lastPos=-1);
STOFFEmbeddedObject m_object;
std::shared_ptr<StarBitmap> m_bitmap;
};
class StarPolygon
{
public:
struct Point {
explicit Point(STOFFVec2i point=STOFFVec2i(), int flag=0)
: m_point(point)
, m_flags(flag)
{
}
friend std::ostream &operator<<(std::ostream &o, Point const &point)
{
o << point.m_point;
switch (point.m_flags) {
case 0:
break;
case 1: // smooth
o << ":s";
break;
case 2: // control
o << ":c";
break;
case 3: // symetric
o << ":S";
break;
default:
STOFF_DEBUG_MSG(("StarObjectSmallGraphicStruct::StarPolygon::Point::operator<< unexpected flag\n"));
o << ":[##" << point.m_flags << "]";
}
return o;
}
STOFFVec2i m_point;
int m_flags;
};
StarPolygon()
: m_points()
{
}
bool hasSpecialPoints() const
{
for (auto const &pt : m_points) {
if (pt.m_flags)
return true;
}
return false;
}
bool empty() const
{
return m_points.empty();
}
size_t size() const
{
return m_points.size();
}
void addToPath(librevenge::RVNGPropertyListVector &path, bool isClosed, double relUnit, STOFFVec2f const &decal) const;
bool convert(librevenge::RVNGString &path, librevenge::RVNGString &viewbox, double relUnit, STOFFVec2f const &decal) const;
friend std::ostream &operator<<(std::ostream &o, StarPolygon const &poly);
std::vector<Point> m_points;
};
}
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
StarBitmap
the main class to read/.
Definition StarBitmap.hxx:63
StarGraphicStruct::StarBrush
Class to store a brush.
Definition StarGraphicStruct.hxx:52
StarGraphicStruct::StarBrush::getPattern
bool getPattern(STOFFEmbeddedObject &object, STOFFVec2i &sz) const
try to return a pattern corresponding to the brush
Definition StarGraphicStruct.cxx:434
StarGraphicStruct::StarBrush::hasUniqueColor
bool hasUniqueColor() const
returns true is the brush has unique color
Definition StarGraphicStruct.hxx:72
StarGraphicStruct::StarBrush::getColor
bool getColor(STOFFColor &color) const
try to return a color corresponding to the brush
Definition StarGraphicStruct.cxx:420
StarGraphicStruct::StarBrush::m_filterName
librevenge::RVNGString m_filterName
the filter name
Definition StarGraphicStruct.hxx:98
StarGraphicStruct::StarBrush::m_position
int m_position
the position(none, lt, mt, rt, lm, mm, rm, lb, mb, rb, area, tiled)
Definition StarGraphicStruct.hxx:94
StarGraphicStruct::StarBrush::StarBrush
StarBrush()
constructor
Definition StarGraphicStruct.hxx:55
StarGraphicStruct::StarBrush::operator<<
friend std::ostream & operator<<(std::ostream &o, StarBrush const &brush)
operator<<
Definition StarGraphicStruct.cxx:463
StarGraphicStruct::StarBrush::m_style
int m_style
the brush style(pattern): BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT, BRUSH_CROSS,...
Definition StarGraphicStruct.hxx:92
StarGraphicStruct::StarBrush::m_extra
std::string m_extra
extra data
Definition StarGraphicStruct.hxx:100
StarGraphicStruct::StarBrush::m_fillColor
STOFFColor m_fillColor
the fill color
Definition StarGraphicStruct.hxx:89
StarGraphicStruct::StarBrush::read
bool read(StarZone &zone, int nVers, long endPos, StarObject &document)
try to read a brush
Definition StarGraphicStruct.cxx:498
StarGraphicStruct::StarBrush::m_transparency
int m_transparency
the transparency
Definition StarGraphicStruct.hxx:85
StarGraphicStruct::StarBrush::m_linkName
librevenge::RVNGString m_linkName
the link name
Definition StarGraphicStruct.hxx:96
StarGraphicStruct::StarBrush::m_color
STOFFColor m_color
the color
Definition StarGraphicStruct.hxx:87
StarGraphicStruct::StarBrush::isEmpty
bool isEmpty() const
returns true if the brush is empty
Definition StarGraphicStruct.hxx:67
StarGraphicStruct::StarGraphic::read
bool read(StarZone &zone, long lastPos=-1)
try to read a graphic, give lastPos if you are sure of the end graphic position
Definition StarGraphicStruct.cxx:549
StarGraphicStruct::StarGraphic::m_object
STOFFEmbeddedObject m_object
the embedded object
Definition StarGraphicStruct.hxx:116
StarGraphicStruct::StarGraphic::StarGraphic
StarGraphic()
constructor
Definition StarGraphicStruct.hxx:108
StarGraphicStruct::StarGraphic::m_bitmap
std::shared_ptr< StarBitmap > m_bitmap
the bitmap
Definition StarGraphicStruct.hxx:118
StarGraphicStruct::StarPolygon
Class to store a polygon.
Definition StarGraphicStruct.hxx:123
StarGraphicStruct::StarPolygon::hasSpecialPoints
bool hasSpecialPoints() const
check if a polygon has special point
Definition StarGraphicStruct.hxx:166
StarGraphicStruct::StarPolygon::size
size_t size() const
returns true if the polygon is empty
Definition StarGraphicStruct.hxx:180
StarGraphicStruct::StarPolygon::operator<<
friend std::ostream & operator<<(std::ostream &o, StarPolygon const &poly)
operator<<
Definition StarGraphicStruct.cxx:731
StarGraphicStruct::StarPolygon::m_points
std::vector< Point > m_points
the list of points
Definition StarGraphicStruct.hxx:191
StarGraphicStruct::StarPolygon::convert
bool convert(librevenge::RVNGString &path, librevenge::RVNGString &viewbox, double relUnit, STOFFVec2f const &decal) const
convert a path in a string and update the bdbox
Definition StarGraphicStruct.cxx:716
StarGraphicStruct::StarPolygon::StarPolygon
StarPolygon()
contructor
Definition StarGraphicStruct.hxx:161
StarGraphicStruct::StarPolygon::addToPath
void addToPath(librevenge::RVNGPropertyListVector &path, bool isClosed, double relUnit, STOFFVec2f const &decal) const
add the polygon to a path
Definition StarGraphicStruct.cxx:678
StarGraphicStruct::StarPolygon::empty
bool empty() const
returns true if the polygon is empty
Definition StarGraphicStruct.hxx:175
StarObject
an object corresponding to an OLE directory
Definition StarObject.hxx:65
StarZone
a zone in a StarOffice file
Definition StarZone.hxx:57
libstaroffice_internal.hxx
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition libstaroffice_internal.hxx:767
STOFFVec2f
STOFFVec2< float > STOFFVec2f
STOFFVec2 of float.
Definition libstaroffice_internal.hxx:771
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition libstaroffice_internal.hxx:129
StarGraphicStruct
a name use to define basic StarOffice graphic structure
Definition StarGraphicStruct.cxx:51
STOFFColor
the class to store a color
Definition libstaroffice_internal.hxx:189
STOFFEmbeddedObject
small class use to define a embedded object
Definition libstaroffice_internal.hxx:408
StarGraphicStruct::StarPolygon::Point::operator<<
friend std::ostream & operator<<(std::ostream &o, Point const &point)
operator<<
Definition StarGraphicStruct.hxx:134
StarGraphicStruct::StarPolygon::Point::Point
Point(STOFFVec2i point=STOFFVec2i(), int flag=0)
constructor
Definition StarGraphicStruct.hxx:128
StarGraphicStruct::StarPolygon::Point::m_flags
int m_flags
the flags
Definition StarGraphicStruct.hxx:158
StarGraphicStruct::StarPolygon::Point::m_point
STOFFVec2i m_point
the point
Definition StarGraphicStruct.hxx:156