StarGraphicStruct.hxx Source File documentation

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
41#include "libstaroffice_internal.hxx"
42
43class StarBitmap;
44class StarObject;
45class StarZone;
46
48namespace StarGraphicStruct
49{
51 class StarBrush
52{
53public:
55 StarBrush() : m_transparency(0), m_color(STOFFColor::white()), m_fillColor(STOFFColor::white()), m_style(0), m_position(0), m_linkName(""), m_filterName(""), m_extra("")
56 {
57 }
58
59 bool isEmpty() const
60 {
61 return m_style<=0 || m_style>=11 || m_transparency>=255;
62 }
63
64 bool hasUniqueColor() const
65 {
66 return m_style==1;
67 }
68
69 bool getColor(STOFFColor &color) const;
71 bool getPattern(STOFFEmbeddedObject &object, STOFFVec2i &sz) const;
73 bool read(StarZone &zone, int nVers, long endPos, StarObject &document);
75 friend std::ostream &operator<<(std::ostream &o, StarBrush const &brush);
77 int m_transparency;
79 STOFFColor m_color;
81 STOFFColor m_fillColor;
84 int m_style;
86 int m_position;
88 librevenge::RVNGString m_linkName;
90 librevenge::RVNGString m_filterName;
92 std::string m_extra;
93};
94
96 class StarGraphic
97{
98public:
100 StarGraphic() : m_object(), m_bitmap()
101 {
102 }
103
104 bool read(StarZone &zone, long lastPos=-1);
106 STOFFEmbeddedObject m_object;
108 shared_ptr<StarBitmap> m_bitmap;
109};
110
112 class StarPolygon
113{
114public:
116 struct Point {
118 explicit Point(STOFFVec2i point=STOFFVec2i(), int flag=0) : m_point(point), m_flags(flag)
119 {
120 }
121
122 friend std::ostream &operator<<(std::ostream &o, Point const &point)
123 {
124 o << point.m_point;
125 switch (point.m_flags) {
126 case 0:
127 break;
128 case 1: // smooth
129 o << ":s";
130 break;
131 case 2: // control
132 o << ":c";
133 break;
134 case 3: // symetric
135 o << ":S";
136 break;
137 default:
138 STOFF_DEBUG_MSG(("StarObjectSmallGraphicStruct::StarPolygon::Point::operator<< unexpected flag\n"));
139 o << ":[##" << point.m_flags << "]";
140 }
141 return o;
142 }
143
144 STOFFVec2i m_point;
146 int m_flags;
147 };
148
149 StarPolygon() : m_points()
150 {
151 }
152
153 bool hasSpecialPoints() const
154 {
155 for (size_t i=0; i<m_points.size(); ++i) {
156 if (m_points[i].m_flags)
157 return true;
158 }
159 return false;
160 }
161
162 bool empty() const
163 {
164 return m_points.empty();
165 }
166
167 size_t size() const
168 {
169 return m_points.size();
170 }
171
172 void addToPath(librevenge::RVNGPropertyListVector &path, bool isClosed) const;
174 bool convert(librevenge::RVNGString &path, librevenge::RVNGString &viewbox) const;
176 friend std::ostream &operator<<(std::ostream &o, StarPolygon const &poly);
178 std::vector<Point> m_points;
179};
180
181}
182
183#endif
184// 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:438
StarGraphicStruct::StarBrush::hasUniqueColor
bool hasUniqueColor() const
returns true is the brush has unique color
Definition StarGraphicStruct.hxx:64
StarGraphicStruct::StarBrush::getColor
bool getColor(STOFFColor &color) const
try to return a color corresponding to the brush
Definition StarGraphicStruct.cxx:424
StarGraphicStruct::StarBrush::m_filterName
librevenge::RVNGString m_filterName
the filter name
Definition StarGraphicStruct.hxx:90
StarGraphicStruct::StarBrush::m_position
int m_position
the position(none, lt, mt, rt, lm, mm, rm, lb, mb, rb, area, tiled)
Definition StarGraphicStruct.hxx:86
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:467
StarGraphicStruct::StarBrush::m_style
int m_style
the brush style(pattern): BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT, BRUSH_CROSS,...
Definition StarGraphicStruct.hxx:84
StarGraphicStruct::StarBrush::m_extra
std::string m_extra
extra data
Definition StarGraphicStruct.hxx:92
StarGraphicStruct::StarBrush::m_fillColor
STOFFColor m_fillColor
the fill color
Definition StarGraphicStruct.hxx:81
StarGraphicStruct::StarBrush::read
bool read(StarZone &zone, int nVers, long endPos, StarObject &document)
try to read a brush
Definition StarGraphicStruct.cxx:502
StarGraphicStruct::StarBrush::m_transparency
int m_transparency
the transparency
Definition StarGraphicStruct.hxx:77
StarGraphicStruct::StarBrush::m_linkName
librevenge::RVNGString m_linkName
the link name
Definition StarGraphicStruct.hxx:88
StarGraphicStruct::StarBrush::m_color
STOFFColor m_color
the color
Definition StarGraphicStruct.hxx:79
StarGraphicStruct::StarBrush::isEmpty
bool isEmpty() const
returns true if the brush is empty
Definition StarGraphicStruct.hxx:59
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:553
StarGraphicStruct::StarGraphic::m_object
STOFFEmbeddedObject m_object
the embedded object
Definition StarGraphicStruct.hxx:106
StarGraphicStruct::StarGraphic::m_bitmap
shared_ptr< StarBitmap > m_bitmap
the bitmap
Definition StarGraphicStruct.hxx:108
StarGraphicStruct::StarGraphic::StarGraphic
StarGraphic()
constructor
Definition StarGraphicStruct.hxx:100
StarGraphicStruct::StarPolygon
Class to store a polygon.
Definition StarGraphicStruct.hxx:113
StarGraphicStruct::StarPolygon::hasSpecialPoints
bool hasSpecialPoints() const
check if a polygon has special point
Definition StarGraphicStruct.hxx:153
StarGraphicStruct::StarPolygon::size
size_t size() const
returns true if the polygon is empty
Definition StarGraphicStruct.hxx:167
StarGraphicStruct::StarPolygon::convert
bool convert(librevenge::RVNGString &path, librevenge::RVNGString &viewbox) const
convert a path in a string and update the bdbox
Definition StarGraphicStruct.cxx:720
StarGraphicStruct::StarPolygon::operator<<
friend std::ostream & operator<<(std::ostream &o, StarPolygon const &poly)
operator<<
Definition StarGraphicStruct.cxx:735
StarGraphicStruct::StarPolygon::m_points
std::vector< Point > m_points
the list of points
Definition StarGraphicStruct.hxx:178
StarGraphicStruct::StarPolygon::StarPolygon
StarPolygon()
contructor
Definition StarGraphicStruct.hxx:149
StarGraphicStruct::StarPolygon::empty
bool empty() const
returns true if the polygon is empty
Definition StarGraphicStruct.hxx:162
StarGraphicStruct::StarPolygon::addToPath
void addToPath(librevenge::RVNGPropertyListVector &path, bool isClosed) const
add the polygon to a path
Definition StarGraphicStruct.cxx:682
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:748
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition libstaroffice_internal.hxx:127
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:179
STOFFEmbeddedObject
small class use to define a embedded object
Definition libstaroffice_internal.hxx:398
StarGraphicStruct::StarPolygon::Point::operator<<
friend std::ostream & operator<<(std::ostream &o, Point const &point)
operator<<
Definition StarGraphicStruct.hxx:122
StarGraphicStruct::StarPolygon::Point::Point
Point(STOFFVec2i point=STOFFVec2i(), int flag=0)
constructor
Definition StarGraphicStruct.hxx:118
StarGraphicStruct::StarPolygon::Point::m_flags
int m_flags
the flags
Definition StarGraphicStruct.hxx:146
StarGraphicStruct::StarPolygon::Point::m_point
STOFFVec2i m_point
the point
Definition StarGraphicStruct.hxx:144