StarGraphicStruct.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libstaroffice
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 (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
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 STAR_GRAPHIC_STRUCT
35 # define STAR_GRAPHIC_STRUCT
36 
37 #include <ostream>
38 #include <string>
39 #include <vector>
40 
42 
43 class StarBitmap;
44 class StarObject;
45 class StarZone;
46 
48 namespace StarGraphicStruct
49 {
51 class StarBrush
52 {
53 public:
56  : m_transparency(0)
57  , m_color(STOFFColor::white())
58  , m_fillColor(STOFFColor::white())
59  , m_style(0)
60  , m_position(0)
61  , m_linkName("")
62  , m_filterName("")
63  , m_extra("")
64  {
65  }
67  bool isEmpty() const
68  {
69  return m_style<=0 || m_style>=11 || m_transparency>=255;
70  }
72  bool hasUniqueColor() const
73  {
74  return m_style==1;
75  }
77  bool getColor(STOFFColor &color) const;
79  bool getPattern(STOFFEmbeddedObject &object, STOFFVec2i &sz) const;
81  bool read(StarZone &zone, int nVers, long endPos, StarObject &document);
83  friend std::ostream &operator<<(std::ostream &o, StarBrush const &brush);
92  int m_style;
96  librevenge::RVNGString m_linkName;
98  librevenge::RVNGString m_filterName;
100  std::string m_extra;
101 };
102 
105 {
106 public:
109  : m_object()
110  , m_bitmap()
111  {
112  }
114  bool read(StarZone &zone, long lastPos=-1);
118  std::shared_ptr<StarBitmap> m_bitmap;
119 };
120 
123 {
124 public:
126  struct Point {
128  explicit Point(STOFFVec2i point=STOFFVec2i(), int flag=0)
129  : m_point(point)
130  , m_flags(flag)
131  {
132  }
134  friend std::ostream &operator<<(std::ostream &o, Point const &point)
135  {
136  o << point.m_point;
137  switch (point.m_flags) {
138  case 0:
139  break;
140  case 1: // smooth
141  o << ":s";
142  break;
143  case 2: // control
144  o << ":c";
145  break;
146  case 3: // symetric
147  o << ":S";
148  break;
149  default:
150  STOFF_DEBUG_MSG(("StarObjectSmallGraphicStruct::StarPolygon::Point::operator<< unexpected flag\n"));
151  o << ":[##" << point.m_flags << "]";
152  }
153  return o;
154  }
158  int m_flags;
159  };
162  : m_points()
163  {
164  }
166  bool hasSpecialPoints() const
167  {
168  for (auto const &pt : m_points) {
169  if (pt.m_flags)
170  return true;
171  }
172  return false;
173  }
175  bool empty() const
176  {
177  return m_points.empty();
178  }
180  size_t size() const
181  {
182  return m_points.size();
183  }
185  void addToPath(librevenge::RVNGPropertyListVector &path, bool isClosed, double relUnit, STOFFVec2f const &decal) const;
187  bool convert(librevenge::RVNGString &path, librevenge::RVNGString &viewbox, double relUnit, STOFFVec2f const &decal) const;
189  friend std::ostream &operator<<(std::ostream &o, StarPolygon const &poly);
191  std::vector<Point> m_points;
192 };
193 
194 }
195 
196 #endif
197 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
StarFileManager.hxx
StarGraphicStruct::StarPolygon::Point::operator<<
friend std::ostream & operator<<(std::ostream &o, Point const &point)
operator<<
Definition: StarGraphicStruct.hxx:134
StarFileManager
the main class to read/.
Definition: StarFileManager.hxx:61
StarZone::closeVersionCompatHeader
bool closeVersionCompatHeader(std::string const &debugName)
close a zone header
Definition: StarZone.cxx:397
StarGraphicStruct::StarBrush::m_fillColor
STOFFColor m_fillColor
the fill color
Definition: StarGraphicStruct.hxx:89
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::getPathBBox
static bool getPathBBox(const librevenge::RVNGPropertyListVector &path, double &px, double &py, double &qx, double &qy)
Internal: helper to compute a path bdbox.
Definition: StarGraphicStruct.cxx:267
STOFFVec2< int >
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
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition: libstaroffice_internal.cxx:63
StarGraphicStruct::StarPolygon::m_points
std::vector< Point > m_points
the list of points
Definition: StarGraphicStruct.hxx:191
StarZone::ascii
libstoff::DebugFile & ascii()
returns the ascii file
Definition: StarZone.hxx:254
StarGraphicStruct::operator<<
std::ostream & operator<<(std::ostream &o, StarBrush const &brush)
Definition: StarGraphicStruct.cxx:463
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
STOFFColor::barycenter
static STOFFColor barycenter(float alpha, STOFFColor const &colA, float beta, STOFFColor const &colB)
return alpha*colA+beta*colB
Definition: libstaroffice_internal.cxx:200
StarGraphicStruct::StarGraphic
Class to store a graphic.
Definition: StarGraphicStruct.hxx:104
StarGraphicStruct::StarPolygon
Class to store a polygon.
Definition: StarGraphicStruct.hxx:122
StarGraphicStruct.hxx
StarGraphicStruct::StarBrush::hasUniqueColor
bool hasUniqueColor() const
returns true is the brush has unique color
Definition: StarGraphicStruct.hxx:72
StarGraphicStruct::createAndInitBMPData
static std::unique_ptr< unsigned char[]> createAndInitBMPData(STOFFVec2i const &sz, unsigned &dibFileSize, unsigned &bufferPosition)
Internal: helper function to create a BMP for a color bitmap (freely inspired from libpwg::WPGBitmap....
Definition: StarGraphicStruct.cxx:70
StarGraphicStruct::getInchValue
static double getInchValue(librevenge::RVNGProperty const *prop)
Definition: StarGraphicStruct.cxx:181
StarGraphicStruct::writeU32
static void writeU32(unsigned char *buffer, unsigned &position, const unsigned value)
Definition: StarGraphicStruct.cxx:61
StarGraphicStruct::convertPath
static librevenge::RVNGString convertPath(const librevenge::RVNGPropertyListVector &path)
Internal: helper to convert a path in a string.
Definition: StarGraphicStruct.cxx:367
StarZone::readString
bool readString(std::vector< uint32_t > &string, int encoding=-1) const
try to read an unicode string
Definition: StarZone.hxx:220
StarGraphicStruct::StarGraphic::m_bitmap
std::shared_ptr< StarBitmap > m_bitmap
the bitmap
Definition: StarGraphicStruct.hxx:118
STOFFColor::value
uint32_t value() const
return the rgba value
Definition: libstaroffice_internal.hxx:247
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
STOFFColor
the class to store a color
Definition: libstaroffice_internal.hxx:189
StarGraphicStruct::getCubicBezierBBox
static void getCubicBezierBBox(double x0, double y0, double x1, double y1, double x2, double y2, double x, double y, double &xmin, double &ymin, double &xmax, double &ymax)
Definition: StarGraphicStruct.cxx:247
StarBitmap::readBitmap
bool readBitmap(StarZone &zone, bool inFileHeader, long lastPos, librevenge::RVNGBinaryData &data, std::string &type)
low level
Definition: StarBitmap.cxx:214
StarGraphicStruct::getQuadraticBezierBBox
static void getQuadraticBezierBBox(double x0, double y0, double x1, double y1, double x, double y, double &xmin, double &ymin, double &xmax, double &ymax)
Definition: StarGraphicStruct.cxx:219
StarGraphicStruct::StarGraphic::StarGraphic
StarGraphic()
constructor
Definition: StarGraphicStruct.hxx:108
StarBitmap
the main class to read/.
Definition: StarBitmap.hxx:62
StarGraphicStruct::StarGraphic::m_object
STOFFEmbeddedObject m_object
the embedded object
Definition: StarGraphicStruct.hxx:116
STOFFEmbeddedObject
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:408
StarGraphicStruct::StarBrush::StarBrush
StarBrush()
constructor
Definition: StarGraphicStruct.hxx:55
StarGraphicStruct::StarBrush::getPattern
bool getPattern(STOFFEmbeddedObject &object, STOFFVec2i &sz) const
try to return a pattern corresponding to the brush
Definition: StarGraphicStruct.cxx:434
libstaroffice_internal.hxx
StarGraphicStruct::StarPolygon::StarPolygon
StarPolygon()
contructor
Definition: StarGraphicStruct.hxx:161
libstoff::DebugStream::str
static std::string str()
Definition: STOFFDebug.hxx:203
StarGraphicStruct::cubicBase
static double cubicBase(double t, double a, double b, double c, double d)
Definition: StarGraphicStruct.cxx:242
STOFFColor::isWhite
bool isWhite() const
return true if the color is white
Definition: libstaroffice_internal.hxx:282
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::operator<<
friend std::ostream & operator<<(std::ostream &o, StarBrush const &brush)
operator<<
Definition: StarGraphicStruct.cxx:463
StarGraphicStruct::StarPolygon::Point::Point
Point(STOFFVec2i point=STOFFVec2i(), int flag=0)
constructor
Definition: StarGraphicStruct.hxx:128
StarGraphicStruct::StarBrush::getColor
bool getColor(STOFFColor &color) const
try to return a color corresponding to the brush
Definition: StarGraphicStruct.cxx:420
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:485
StarGraphicStruct::StarPolygon::hasSpecialPoints
bool hasSpecialPoints() const
check if a polygon has special point
Definition: StarGraphicStruct.hxx:166
StarGraphicStruct::StarBrush
Class to store a brush.
Definition: StarGraphicStruct.hxx:51
StarZone
a zone in a StarOffice file
Definition: StarZone.hxx:56
StarZone::getRecordLevel
int getRecordLevel() const
returns the record level
Definition: StarZone.hxx:195
StarObject
an object corresponding to an OLE directory
Definition: StarObject.hxx:64
StarGraphicStruct::StarBrush::m_linkName
librevenge::RVNGString m_linkName
the link name
Definition: StarGraphicStruct.hxx:96
StarGraphicStruct::StarPolygon::Point::m_point
STOFFVec2i m_point
the point
Definition: StarGraphicStruct.hxx:156
libstoff::DebugStream
Definition: STOFFDebug.hxx:194
StarGraphicStruct::StarPolygon::empty
bool empty() const
returns true if the polygon is empty
Definition: StarGraphicStruct.hxx:175
StarGraphicStruct::StarPolygon::Point::m_flags
int m_flags
the flags
Definition: StarGraphicStruct.hxx:158
StarGraphicStruct::writeU16
static void writeU16(unsigned char *buffer, unsigned &position, const unsigned value)
Definition: StarGraphicStruct.cxx:55
StarGraphicStruct
a name use to define basic StarOffice graphic structure
Definition: StarGraphicStruct.cxx:50
StarGraphicStruct::StarBrush::m_color
STOFFColor m_color
the color
Definition: StarGraphicStruct.hxx:87
StarBitmap.hxx
StarGraphicStruct::StarPolygon::Point
a structure to keep a point and a flag
Definition: StarGraphicStruct.hxx:126
libstoff::DebugFile::addPos
static void addPos(long)
Definition: STOFFDebug.hxx:223
libstoff::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: STOFFDebug.hxx:225
StarObject.hxx
StarZone.hxx
StarZone::openVersionCompatHeader
bool openVersionCompatHeader()
open a version compat header (version+size)
Definition: StarZone.cxx:372
libstoff::DebugFile
Definition: STOFFDebug.hxx:210
StarGraphicStruct::StarPolygon::size
size_t size() const
returns true if the polygon is empty
Definition: StarGraphicStruct.hxx:180
StarGraphicStruct::StarBrush::read
bool read(StarZone &zone, int nVers, long endPos, StarObject &document)
try to read a brush
Definition: StarGraphicStruct.cxx:498
StarGraphicStruct::getBMPData
bool getBMPData(std::vector< std::vector< STOFFColor > > const &orig, librevenge::RVNGBinaryData &data)
Internal: helper function to create a BMP for a color bitmap (freely inspired from libpwg::WPGBitmap....
Definition: StarGraphicStruct.cxx:125
libstoff::DebugFile::addNote
static void addNote(char const *)
Definition: STOFFDebug.hxx:224
libstoff::DebugFile::skipZone
static void skipZone(long, long)
Definition: STOFFDebug.hxx:230
StarGraphicStruct::StarBrush::isEmpty
bool isEmpty() const
returns true if the brush is empty
Definition: StarGraphicStruct.hxx:67
StarGraphicStruct::StarBrush::m_filterName
librevenge::RVNGString m_filterName
the filter name
Definition: StarGraphicStruct.hxx:98
StarGraphicStruct::StarBrush::m_extra
std::string m_extra
extra data
Definition: StarGraphicStruct.hxx:100
StarGraphicStruct::quadraticExtreme
static double quadraticExtreme(double t, double a, double b, double c)
Definition: StarGraphicStruct.cxx:206
StarZone::input
STOFFInputStreamPtr input()
return the zone input
Definition: StarZone.hxx:247
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
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:763
StarGraphicStruct::quadraticDerivative
static double quadraticDerivative(double a, double b, double c)
Definition: StarGraphicStruct.cxx:211
StarZone::getRecordLastPosition
long getRecordLastPosition() const
returns the actual record last position
Definition: StarZone.hxx:200
StarGraphicStruct::StarPolygon::operator<<
friend std::ostream & operator<<(std::ostream &o, StarPolygon const &poly)
operator<<
Definition: StarGraphicStruct.cxx:731
StarFileManager::readSVGDI
static bool readSVGDI(StarZone &zone)
try to read a SVGDI object
Definition: StarFileManager.cxx:959
StarGraphicStruct::StarBrush::m_transparency
int m_transparency
the transparency
Definition: StarGraphicStruct.hxx:85

Generated on Mon Jan 20 2020 23:02:17 for libstaroffice by doxygen 1.8.16