libwps_internal.h Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

libwps_internal.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
11 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 *
20 * For further information visit http://libwps.sourceforge.net
21 */
22
23 #ifndef LIBWPS_INTERNAL_H
24 #define LIBWPS_INTERNAL_H
25
26 #include <assert.h>
27 #ifdef DEBUG
28 #include <stdio.h>
29 #endif
30
31 #include <cmath>
32 #include <iostream>
33 #include <map>
34 #include <string>
35 #include <vector>
36
37 #include <librevenge-stream/librevenge-stream.h>
38 #include <librevenge/librevenge.h>
39
40 #ifndef M_PI
41 #define M_PI 3.14159265358979323846
42 #endif
43
44 #if defined(_MSC_VER) || defined(__DJGPP__)
45 typedef signed char int8_t;
46 typedef unsigned char uint8_t;
47 typedef signed short int16_t;
48 typedef unsigned short uint16_t;
49 typedef signed int int32_t;
50 typedef unsigned int uint32_t;
51 #else /* !_MSC_VER && !__DJGPP__*/
52 # include <inttypes.h>
53 #endif /* _MSC_VER || __DJGPP__*/
54
55 /* ---------- memory --------------- */
56 #ifdef HAVE_CONFIG_H
57 # include "config.h"
58 #endif
59
60 // define localtime_r on Windows, so that can use
61 // thread-safe functions on other environments
62 #ifdef _WIN32
63 # define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
64 # define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
65 #endif
66
67 #if defined(SHAREDPTR_TR1)
68 #include <tr1/memory>
69 using std::tr1::shared_ptr;
70 #elif defined(SHAREDPTR_STD)
71 #include <memory>
72 using std::shared_ptr;
73 #else
74 #include <boost/shared_ptr.hpp>
75 using boost::shared_ptr;
76 #endif
77
79 template <class T>
80 struct WPS_shared_ptr_noop_deleter
81 {
82 void operator()(T *) {}
83 };
84
85 // basic classes and autoptr
87 typedef shared_ptr<librevenge::RVNGInputStream> RVNGInputStreamPtr;
88
89 class WPSCell;
90 class WPSListener;
91 class WPSContentListener;
92 class WPSEntry;
93 class WPSFont;
94 class WPSHeader;
95 class WPSPosition;
96 class WPSSubDocument;
97
98 class WKSContentListener;
99 class WKSSubDocument;
100
102 typedef shared_ptr<WPSCell> WPSCellPtr;
104 typedef shared_ptr<WPSListener> WPSListenerPtr;
106 typedef shared_ptr<WPSContentListener> WPSContentListenerPtr;
108 typedef shared_ptr<WPSHeader> WPSHeaderPtr;
110 typedef shared_ptr<WPSSubDocument> WPSSubDocumentPtr;
111
113 typedef shared_ptr<WKSContentListener> WKSContentListenerPtr;
115 typedef shared_ptr<WKSSubDocument> WKSSubDocumentPtr;
116
117 #if defined(__clang__) || defined(__GNUC__)
118 # define WPS_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((__format__(__printf__, fmt, arg)))
119 #else
120 # define WPS_ATTRIBUTE_PRINTF(fmt, arg)
121 #endif
122 /* ---------- debug --------------- */
123 #ifdef DEBUG
124 namespace libwps
125 {
126 void printDebugMsg(const char *format, ...) WPS_ATTRIBUTE_PRINTF(1, 2);
127 }
128 #define WPS_DEBUG_MSG(M) libwps::printDebugMsg M
129 #else
130 #define WPS_DEBUG_MSG(M)
131 #endif
132
133 /* ---------- exception ------------ */
134 namespace libwps
135 {
136 // Various exceptions
137 class VersionException
138 {
139 // needless to say, we could flesh this class out a bit
140 };
141
142 class FileException
143 {
144 // needless to say, we could flesh this class out a bit
145 };
146
147 class ParseException
148 {
149 // needless to say, we could flesh this class out a bit
150 };
151
152 class GenericException
153 {
154 // needless to say, we could flesh this class out a bit
155 };
156 }
157
158 /* ---------- input ----------------- */
159 namespace libwps
160 {
161 uint8_t readU8(librevenge::RVNGInputStream *input);
162 uint16_t readU16(librevenge::RVNGInputStream *input);
163 uint32_t readU32(librevenge::RVNGInputStream *input);
164
165 int8_t read8(librevenge::RVNGInputStream *input);
166 int16_t read16(librevenge::RVNGInputStream *input);
167 int32_t read32(librevenge::RVNGInputStream *input);
168
169 inline uint8_t readU8(RVNGInputStreamPtr &input)
170 {
171 return readU8(input.get());
172 }
173 inline uint16_t readU16(RVNGInputStreamPtr &input)
174 {
175 return readU16(input.get());
176 }
177 inline uint32_t readU32(RVNGInputStreamPtr &input)
178 {
179 return readU32(input.get());
180 }
181
182 inline int8_t read8(RVNGInputStreamPtr &input)
183 {
184 return read8(input.get());
185 }
186 inline int16_t read16(RVNGInputStreamPtr &input)
187 {
188 return read16(input.get());
189 }
190 inline int32_t read32(RVNGInputStreamPtr &input)
191 {
192 return read32(input.get());
193 }
194
196 bool readDouble4(RVNGInputStreamPtr &input, double &res, bool &isNaN);
198 bool readDouble8(RVNGInputStreamPtr &input, double &res, bool &isNaN);
200 bool readDouble10(RVNGInputStreamPtr &input, double &res, bool &isNaN);
202 bool readDouble2Inv(RVNGInputStreamPtr &input, double &res, bool &isNaN);
204 bool readDouble4Inv(RVNGInputStreamPtr &input, double &res, bool &isNaN);
205
207 bool readData(RVNGInputStreamPtr &input, unsigned long sz, librevenge::RVNGBinaryData &data);
209 bool readDataToEnd(RVNGInputStreamPtr &input, librevenge::RVNGBinaryData &data);
211 void appendUnicode(uint32_t val, librevenge::RVNGString &buffer);
212 }
213
214 #define WPS_LE_GET_GUINT16(p) \
215 (uint16_t)((((uint8_t const *)(p))[0] << 0) | \
216 (((uint8_t const *)(p))[1] << 8))
217 #define WPS_LE_GET_GUINT32(p) \
218 (uint32_t)((((uint8_t const *)(p))[0] << 0) | \
219 (((uint8_t const *)(p))[1] << 8) | \
220 (((uint8_t const *)(p))[2] << 16) | \
221 (((uint8_t const *)(p))[3] << 24))
222
223 #define WPS_LE_PUT_GUINT16(p, v) \
224 *((uint8_t*)(p)) = uint8_t(v); \
225 *(((uint8_t*)(p)) + 1) = uint8_t((v) >> 8)
226
227 #define WPS_LE_PUT_GUINT32(p, v) \
228 *((uint8_t*)(p)) = uint8_t(v); \
229 *(((uint8_t*)(p)) + 1) = uint8_t((v) >> 8); \
230 *(((uint8_t*)(p)) + 2) = uint8_t((v) >> 16); \
231 *(((uint8_t*)(p)) + 3) = uint8_t((v) >> 24)
232
233 // Various helper structures for the parser..
234 /* ---------- small enum/class ------------- */
235
236 struct WPSColumnDefinition
237 {
238 WPSColumnDefinition() : m_width(0), m_leftGutter(0), m_rightGutter(0)
239 {
240 }
241 double m_width;
242 double m_leftGutter;
243 double m_rightGutter;
244 };
245
246 struct WPSColumnProperties
247 {
248 WPSColumnProperties() : m_attributes(0), m_alignment(0)
249 {
250 }
251 uint32_t m_attributes;
252 uint8_t m_alignment;
253 };
254
256 struct WPSColor
257 {
259 WPSColor(uint32_t argb=0) : m_value(argb)
260 {
261 }
263 WPSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) :
264 m_value(uint32_t((a<<24)+(r<<16)+(g<<8)+b))
265 {
266 }
268 WPSColor &operator=(uint32_t argb)
269 {
270 m_value = argb;
271 return *this;
272 }
274 static WPSColor black()
275 {
276 return WPSColor(0,0,0);
277 }
279 static WPSColor white()
280 {
281 return WPSColor(255,255,255);
282 }
283
285 static WPSColor barycenter(float alpha, WPSColor const &colA,
286 float beta, WPSColor const &colB);
288 uint32_t value() const
289 {
290 return m_value;
291 }
293 unsigned char getAlpha() const
294 {
295 return (unsigned char)((m_value>>24)&0xFF);
296 }
298 unsigned char getBlue() const
299 {
300 return (unsigned char)(m_value&0xFF);
301 }
303 unsigned char getRed() const
304 {
305 return (unsigned char)((m_value>>16)&0xFF);
306 }
308 unsigned char getGreen() const
309 {
310 return (unsigned char)((m_value>>8)&0xFF);
311 }
313 bool isBlack() const
314 {
315 return (m_value&0xFFFFFF)==0;
316 }
318 bool isWhite() const
319 {
320 return (m_value&0xFFFFFF)==0xFFFFFF;
321 }
323 bool operator==(WPSColor const &c) const
324 {
325 return (c.m_value&0xFFFFFF)==(m_value&0xFFFFFF);
326 }
328 bool operator!=(WPSColor const &c) const
329 {
330 return !operator==(c);
331 }
333 bool operator<(WPSColor const &c) const
334 {
335 return (c.m_value&0xFFFFFF)<(m_value&0xFFFFFF);
336 }
338 bool operator<=(WPSColor const &c) const
339 {
340 return (c.m_value&0xFFFFFF)<=(m_value&0xFFFFFF);
341 }
343 bool operator>(WPSColor const &c) const
344 {
345 return !operator<=(c);
346 }
348 bool operator>=(WPSColor const &c) const
349 {
350 return !operator<(c);
351 }
353 friend std::ostream &operator<< (std::ostream &o, WPSColor const &c);
355 std::string str() const;
356 protected:
358 uint32_t m_value;
359 };
360
362 struct WPSBorder
363 {
365 enum Style { None, Simple, Dot, LargeDot, Dash };
367 enum Type { Single, Double, Triple };
368 enum Pos { Left = 0, Right = 1, Top = 2, Bottom = 3 };
369 enum { LeftBit = 0x01, RightBit = 0x02, TopBit=0x4, BottomBit = 0x08 };
370
372 WPSBorder() : m_style(Simple), m_type(Single), m_width(1), m_widthsList(), m_color(WPSColor::black()), m_extra("") { }
376 bool addTo(librevenge::RVNGPropertyList &propList, std::string which="") const;
378 bool isEmpty() const
379 {
380 return m_style==None || m_width <= 0;
381 }
382
384 bool operator==(WPSBorder const &orig) const
385 {
386 return m_style == orig.m_style && m_type == orig.m_type && m_width == orig.m_width
387 && m_color == orig.m_color;
388 }
390 bool operator!=(WPSBorder const &orig) const
391 {
392 return !operator==(orig);
393 }
395 int compare(WPSBorder const &orig) const;
396
398 friend std::ostream &operator<< (std::ostream &o, WPSBorder const &border);
400 friend std::ostream &operator<< (std::ostream &o, WPSBorder::Style const &style);
402 Style m_style;
404 Type m_type;
406 int m_width;
410 std::vector<double> m_widthsList;
412 WPSColor m_color;
414 std::string m_extra;
415 };
416
421 struct WPSEmbeddedObject
422 {
424 WPSEmbeddedObject() : m_dataList(), m_typeList()
425 {
426 }
428 WPSEmbeddedObject(librevenge::RVNGBinaryData const &binaryData,
429 std::string type="image/pict") : m_dataList(), m_typeList()
430 {
431 add(binaryData, type);
432 }
434 virtual ~WPSEmbeddedObject()
435 {
436 }
438 bool isEmpty() const
439 {
440 for (size_t i=0; i<m_dataList.size(); ++i)
441 {
442 if (!m_dataList[i].empty())
443 return false;
444 }
445 return true;
446 }
448 void add(librevenge::RVNGBinaryData const &binaryData, std::string type="image/pict")
449 {
450 size_t pos=m_dataList.size();
451 if (pos<m_typeList.size()) pos=m_typeList.size();
452 m_dataList.resize(pos+1);
453 m_dataList[pos]=binaryData;
454 m_typeList.resize(pos+1);
455 m_typeList[pos]=type;
456 }
458 bool addTo(librevenge::RVNGPropertyList &propList) const;
460 friend std::ostream &operator<<(std::ostream &o, WPSEmbeddedObject const &pict);
461
463 std::vector<librevenge::RVNGBinaryData> m_dataList;
465 std::vector<std::string> m_typeList;
466 };
467
468 namespace libwps
469 {
470 enum NumberingType { NONE, BULLET, ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
471 std::string numberingTypeToString(NumberingType type);
472 enum SubDocumentType { DOC_NONE, DOC_HEADER_FOOTER, DOC_NOTE, DOC_TABLE, DOC_TEXT_BOX, DOC_COMMENT_ANNOTATION };
473 enum Justification { JustificationLeft, JustificationFull, JustificationCenter,
474 JustificationRight, JustificationFullAllLines
475 };
476 enum { NoBreakBit = 0x1, NoBreakWithNextBit=0x2};
477 }
478
479 // ATTRIBUTE bits
480 #define WPS_EXTRA_LARGE_BIT 1
481 #define WPS_VERY_LARGE_BIT 2
482 #define WPS_LARGE_BIT 4
483 #define WPS_SMALL_PRINT_BIT 8
484 #define WPS_FINE_PRINT_BIT 0x10
485 #define WPS_SUPERSCRIPT_BIT 0x20
486 #define WPS_SUBSCRIPT_BIT 0x40
487 #define WPS_OUTLINE_BIT 0x80
488 #define WPS_ITALICS_BIT 0x100
489 #define WPS_SHADOW_BIT 0x200
490 #define WPS_REDLINE_BIT 0x400
491 #define WPS_DOUBLE_UNDERLINE_BIT 0x800
492 #define WPS_BOLD_BIT 0x1000
493 #define WPS_STRIKEOUT_BIT 0x2000
494 #define WPS_UNDERLINE_BIT 0x4000
495 #define WPS_SMALL_CAPS_BIT 0x8000
496 #define WPS_BLINK_BIT 0x10000L
497 #define WPS_REVERSEVIDEO_BIT 0x20000L
498 #define WPS_ALL_CAPS_BIT 0x40000L
499 #define WPS_EMBOSS_BIT 0x80000L
500 #define WPS_ENGRAVE_BIT 0x100000L
501 #define WPS_OVERLINE_BIT 0x400000L
502 #define WPS_HIDDEN_BIT 0x800000L
503
504 // BREAK bits
505 #define WPS_PAGE_BREAK 0x00
506 #define WPS_SOFT_PAGE_BREAK 0x01
507 #define WPS_COLUMN_BREAK 0x02
508
509 // Generic bits
510 #define WPS_LEFT 0x00
511 #define WPS_RIGHT 0x01
512 #define WPS_CENTER 0x02
513 #define WPS_TOP 0x03
514 #define WPS_BOTTOM 0x04
515
516 /* ---------- vec2/box2f ------------- */
520 template <class T> class Vec2
521 {
522 public:
524 Vec2(T xx=0,T yy=0) : m_x(xx), m_y(yy) { }
526 template <class U> Vec2(Vec2<U> const &p) : m_x(T(p.x())), m_y(T(p.y())) {}
527
529 T x() const
530 {
531 return m_x;
532 }
534 T y() const
535 {
536 return m_y;
537 }
539 T operator[](int c) const
540 {
541 if (c<0 || c>1) throw libwps::GenericException();
542 return (c==0) ? m_x : m_y;
543 }
545 T &operator[](int c)
546 {
547 if (c<0 || c>1) throw libwps::GenericException();
548 return (c==0) ? m_x : m_y;
549 }
550
552 void set(T xx, T yy)
553 {
554 m_x = xx;
555 m_y = yy;
556 }
558 void setX(T xx)
559 {
560 m_x = xx;
561 }
563 void setY(T yy)
564 {
565 m_y = yy;
566 }
567
569 void add(T dx, T dy)
570 {
571 m_x += dx;
572 m_y += dy;
573 }
574
576 Vec2<T> &operator+=(Vec2<T> const &p)
577 {
578 m_x += p.m_x;
579 m_y += p.m_y;
580 return *this;
581 }
583 Vec2<T> &operator-=(Vec2<T> const &p)
584 {
585 m_x -= p.m_x;
586 m_y -= p.m_y;
587 return *this;
588 }
590 template <class U>
591 Vec2<T> &operator*=(U scale)
592 {
593 m_x = T(m_x*scale);
594 m_y = T(m_y*scale);
595 return *this;
596 }
597
599 friend Vec2<T> operator+(Vec2<T> const &p1, Vec2<T> const &p2)
600 {
601 Vec2<T> p(p1);
602 return p+=p2;
603 }
605 friend Vec2<T> operator-(Vec2<T> const &p1, Vec2<T> const &p2)
606 {
607 Vec2<T> p(p1);
608 return p-=p2;
609 }
611 template <class U>
612 friend Vec2<T> operator*(U scale, Vec2<T> const &p1)
613 {
614 Vec2<T> p(p1);
615 return p *= scale;
616 }
617
619 bool operator==(Vec2<T> const &p) const
620 {
621 return cmpY(p) == 0;
622 }
624 bool operator!=(Vec2<T> const &p) const
625 {
626 return cmpY(p) != 0;
627 }
629 bool operator<(Vec2<T> const &p) const
630 {
631 return cmpY(p) < 0;
632 }
634 int cmp(Vec2<T> const &p) const
635 {
636 if (m_x<p.m_x) return -1;
637 if (m_x>p.m_x) return 1;
638 if (m_y<p.m_y) return -1;
639 if (m_y>p.m_y) return 1;
640 return 0;
641 }
643 int cmpY(Vec2<T> const &p) const
644 {
645 if (m_y<p.m_y) return -1;
646 if (m_y>p.m_y) return 1;
647 if (m_x<p.m_x) return -1;
648 if (m_x>p.m_x) return 1;
649 return 0;
650 }
651
653 friend std::ostream &operator<< (std::ostream &o, Vec2<T> const &f)
654 {
655 o << f.m_x << "x" << f.m_y;
656 return o;
657 }
658
662 struct PosSizeLtX
663 {
665 bool operator()(Vec2<T> const &s1, Vec2<T> const &s2) const
666 {
667 return s1.cmp(s2) < 0;
668 }
669 };
673 typedef std::map<Vec2<T>, T,struct PosSizeLtX> MapX;
674
678 struct PosSizeLtY
679 {
681 bool operator()(Vec2<T> const &s1, Vec2<T> const &s2) const
682 {
683 return s1.cmpY(s2) < 0;
684 }
685 };
689 typedef std::map<Vec2<T>, T,struct PosSizeLtY> MapY;
690 protected:
691 T m_x, m_y;
692 };
693
695 typedef Vec2<bool> Vec2b;
697 typedef Vec2<int> Vec2i;
699 typedef Vec2<float> Vec2f;
700
704 template <class T> class Box2
705 {
706 public:
708 Box2(Vec2<T> minPt=Vec2<T>(), Vec2<T> maxPt=Vec2<T>())
709 {
710 m_pt[0] = minPt;
711 m_pt[1] = maxPt;
712 }
714 template <class U> Box2(Box2<U> const &p)
715 {
716 for (int c=0; c < 2; c++) m_pt[c] = p[c];
717 }
718
720 Vec2<T> const &min() const
721 {
722 return m_pt[0];
723 }
725 Vec2<T> const &max() const
726 {
727 return m_pt[1];
728 }
730 Vec2<T> &min()
731 {
732 return m_pt[0];
733 }
735 Vec2<T> &max()
736 {
737 return m_pt[1];
738 }
739
743 Vec2<T> const &operator[](int c) const
744 {
745 if (c<0 || c>1) throw libwps::GenericException();
746 return m_pt[c];
747 }
749 Vec2<T> size() const
750 {
751 return m_pt[1]-m_pt[0];
752 }
754 Vec2<T> center() const
755 {
756 return 0.5*(m_pt[0]+m_pt[1]);
757 }
758
760 void set(Vec2<T> const &x, Vec2<T> const &y)
761 {
762 m_pt[0] = x;
763 m_pt[1] = y;
764 }
766 void setMin(Vec2<T> const &x)
767 {
768 m_pt[0] = x;
769 }
771 void setMax(Vec2<T> const &y)
772 {
773 m_pt[1] = y;
774 }
775
777 void resizeFromMin(Vec2<T> const &sz)
778 {
779 m_pt[1] = m_pt[0]+sz;
780 }
782 void resizeFromMax(Vec2<T> const &sz)
783 {
784 m_pt[0] = m_pt[1]-sz;
785 }
787 void resizeFromCenter(Vec2<T> const &sz)
788 {
789 Vec2<T> ctr = 0.5*(m_pt[0]+m_pt[1]);
790 m_pt[0] = ctr - 0.5*sz;
791 m_pt[1] = ctr + (sz - 0.5*sz);
792 }
793
795 template <class U> void scale(U factor)
796 {
797 m_pt[0] *= factor;
798 m_pt[1] *= factor;
799 }
800
802 void extend(T val)
803 {
804 m_pt[0] -= Vec2<T>(val/2,val/2);
805 m_pt[1] += Vec2<T>(val-(val/2),val-(val/2));
806 }
808 Box2<T> getUnion(Box2<T> const &box) const
809 {
810 Box2<T> res;
811 res.m_pt[0]=Vec2<T>(m_pt[0][0]<box.m_pt[0][0]?m_pt[0][0] : box.m_pt[0][0],
812 m_pt[0][1]<box.m_pt[0][1]?m_pt[0][1] : box.m_pt[0][1]);
813 res.m_pt[1]=Vec2<T>(m_pt[1][0]>box.m_pt[1][0]?m_pt[1][0] : box.m_pt[1][0],
814 m_pt[1][1]>box.m_pt[1][1]?m_pt[1][1] : box.m_pt[1][1]);
815 return res;
816 }
818 Box2<T> getIntersection(Box2<T> const &box) const
819 {
820 Box2<T> res;
821 res.m_pt[0]=Vec2<T>(m_pt[0][0]>box.m_pt[0][0]?m_pt[0][0] : box.m_pt[0][0],
822 m_pt[0][1]>box.m_pt[0][1]?m_pt[0][1] : box.m_pt[0][1]);
823 res.m_pt[1]=Vec2<T>(m_pt[1][0]<box.m_pt[1][0]?m_pt[1][0] : box.m_pt[1][0],
824 m_pt[1][1]<box.m_pt[1][1]?m_pt[1][1] : box.m_pt[1][1]);
825 return res;
826 }
827
829 bool operator==(Box2<T> const &p) const
830 {
831 return cmp(p) == 0;
832 }
834 bool operator!=(Box2<T> const &p) const
835 {
836 return cmp(p) != 0;
837 }
839 bool operator<(Box2<T> const &p) const
840 {
841 return cmp(p) < 0;
842 }
843
845 int cmp(Box2<T> const &p) const
846 {
847 int diff = m_pt[0].cmpY(p.m_pt[0]);
848 if (diff) return diff;
849 diff = m_pt[1].cmpY(p.m_pt[1]);
850 if (diff) return diff;
851 return 0;
852 }
853
855 friend std::ostream &operator<< (std::ostream &o, Box2<T> const &f)
856 {
857 o << "(" << f.m_pt[0] << "<->" << f.m_pt[1] << ")";
858 return o;
859 }
860
864 struct PosSizeLt
865 {
867 bool operator()(Box2<T> const &s1, Box2<T> const &s2) const
868 {
869 return s1.cmp(s2) < 0;
870 }
871 };
875 typedef std::map<Box2<T>, T,struct PosSizeLt> Map;
876
877 protected:
879 Vec2<T> m_pt[2];
880 };
881
883 typedef Box2<int> Box2i;
885 typedef Box2<float> Box2f;
886
887 #endif /* LIBWPS_INTERNAL_H */
888 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
libwps::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:39
WPSBorder::Dash
Definition: libwps_internal.h:365
libwps::LOWERCASE
Definition: libwps_internal.h:470
WPSContentListenerPtr
shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition: libwps_internal.h:106
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition: libwps_internal.h:699
WPSColor::WPSColor
WPSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
constructor from color
Definition: libwps_internal.h:263
Box2::set
void set(Vec2< T > const &x, Vec2< T > const &y)
resets the data to minimum x and maximum y
Definition: libwps_internal.h:760
Vec2::setY
void setY(T yy)
resets the second element
Definition: libwps_internal.h:563
WPSColor::barycenter
static WPSColor barycenter(float alpha, WPSColor const &colA, float beta, WPSColor const &colB)
return alpha*colA+beta*colB
Definition: libwps_internal.cpp:385
WPSBorder
a border list
Definition: libwps_internal.h:362
WPSBorder::LargeDot
Definition: libwps_internal.h:365
WPSColumnProperties
Definition: libwps_internal.h:246
libwps::GenericException
Definition: libwps_internal.h:152
Vec2::m_x
T m_x
first element
Definition: libwps_internal.h:691
WPSBorder::Triple
Definition: libwps_internal.h:367
libwps
Definition: libwps_internal.cpp:37
Box2::operator[]
Vec2< T > const & operator[](int c) const
the two extremum points which defined the box
Definition: libwps_internal.h:743
Box2::min
Vec2< T > const & min() const
the minimum 2D point (in x and in y)
Definition: libwps_internal.h:720
WPSSubDocumentPtr
shared_ptr< WPSSubDocument > WPSSubDocumentPtr
shared pointer to WPSSubDocument
Definition: libwps_internal.h:110
Box2::operator!=
bool operator!=(Box2< T > const &p) const
comparison operator!=
Definition: libwps_internal.h:834
Box2::cmp
int cmp(Box2< T > const &p) const
comparison function : fist sorts min by Y,X values then max extremity
Definition: libwps_internal.h:845
libwps::NoBreakWithNextBit
Definition: libwps_internal.h:476
Vec2::operator-
friend Vec2< T > operator-(Vec2< T > const &p1, Vec2< T > const &p2)
operator-
Definition: libwps_internal.h:605
WPSBorder::Double
Definition: libwps_internal.h:367
libwps::read32
int32_t read32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:84
WPSEmbeddedObject::WPSEmbeddedObject
WPSEmbeddedObject(librevenge::RVNGBinaryData const &binaryData, std::string type="image/pict")
constructor
Definition: libwps_internal.h:428
Vec2::operator[]
T & operator[](int c)
operator[]
Definition: libwps_internal.h:545
WPSBorder::Top
Definition: libwps_internal.h:368
Box2
small class which defines a 2D Box
Definition: libwps_internal.h:704
WPSBorder::RightBit
Definition: libwps_internal.h:369
Box2::PosSizeLt
internal struct used to create sorted map, sorted first min then max
Definition: libwps_internal.h:864
WPSFont
define the font properties
Definition: WPSFont.h:36
WPSEmbeddedObject::m_typeList
std::vector< std::string > m_typeList
the picture type: one type by representation
Definition: libwps_internal.h:465
WPSColor::operator==
bool operator==(WPSColor const &c) const
operator==
Definition: libwps_internal.h:323
Box2::resizeFromMin
void resizeFromMin(Vec2< T > const &sz)
resize the box keeping the minimum
Definition: libwps_internal.h:777
WPSColumnDefinition::m_leftGutter
double m_leftGutter
Definition: libwps_internal.h:242
WPSBorder::None
Definition: libwps_internal.h:365
WPS_ATTRIBUTE_PRINTF
#define WPS_ATTRIBUTE_PRINTF(fmt, arg)
Definition: libwps_internal.h:120
WPSListener
virtual class for content listener
Definition: WPSListener.h:36
Vec2::PosSizeLtX
internal struct used to create sorted map, sorted by X
Definition: libwps_internal.h:662
WPSColor::black
static WPSColor black()
return the back color
Definition: libwps_internal.h:274
Vec2< bool >::MapY
std::map< Vec2< bool >, bool, struct PosSizeLtY > MapY
Definition: libwps_internal.h:689
WPSBorder::m_width
int m_width
the border width
Definition: libwps_internal.h:406
WPSColor::white
static WPSColor white()
return the white color
Definition: libwps_internal.h:279
libwps::DOC_COMMENT_ANNOTATION
Definition: libwps_internal.h:472
WPSBorder::Left
Definition: libwps_internal.h:368
WPSEmbeddedObject::WPSEmbeddedObject
WPSEmbeddedObject()
empty constructor
Definition: libwps_internal.h:424
Vec2::operator+=
Vec2< T > & operator+=(Vec2< T > const &p)
operator+=
Definition: libwps_internal.h:576
libwps::LOWERCASE_ROMAN
Definition: libwps_internal.h:470
Vec2::set
void set(T xx, T yy)
resets the two elements
Definition: libwps_internal.h:552
libwps::BULLET
Definition: libwps_internal.h:470
Box2::extend
void extend(T val)
extends the bdbox by (val, val) keeping the center
Definition: libwps_internal.h:802
libwps::DOC_TEXT_BOX
Definition: libwps_internal.h:472
WPSContentListener
Definition: WPSContentListener.h:44
WPSColor::operator=
WPSColor & operator=(uint32_t argb)
operator=
Definition: libwps_internal.h:268
libwps::readDouble4
bool readDouble4(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 4 bytes: mantisse 2.5 bytes, exponent 1.5 bytes
Definition: libwps_internal.cpp:89
WPSColumnProperties::m_attributes
uint32_t m_attributes
Definition: libwps_internal.h:251
libwps::DOC_NOTE
Definition: libwps_internal.h:472
WPSColor::getRed
unsigned char getRed() const
returns the red value
Definition: libwps_internal.h:303
WPSColor::operator<<
friend std::ostream & operator<<(std::ostream &o, WPSColor const &c)
operator<< in the form #rrggbb
Definition: libwps_internal.cpp:400
Box2i
Box2< int > Box2i
Box2 of int.
Definition: libwps_internal.h:883
WPSColor::isBlack
bool isBlack() const
return true if the color is black
Definition: libwps_internal.h:313
WPSColor::operator<
bool operator<(WPSColor const &c) const
operator<
Definition: libwps_internal.h:333
WPSColor::operator>=
bool operator>=(WPSColor const &c) const
operator>=
Definition: libwps_internal.h:348
WPSEmbeddedObject::add
void add(librevenge::RVNGBinaryData const &binaryData, std::string type="image/pict")
add a picture
Definition: libwps_internal.h:448
Box2::max
Vec2< T > & max()
the maximum 2D point (in x and in y)
Definition: libwps_internal.h:735
WPSCell
a structure used to defined the cell position, and a format
Definition: WPSCell.h:251
WPSColumnDefinition::m_width
double m_width
Definition: libwps_internal.h:241
Box2::center
Vec2< T > center() const
the box center
Definition: libwps_internal.h:754
libwps::Justification
Justification
Definition: libwps_internal.h:473
WPSColumnDefinition::m_rightGutter
double m_rightGutter
Definition: libwps_internal.h:243
WPSSubDocument
virtual class to define a sub document
Definition: WPSSubDocument.h:33
Vec2::operator==
bool operator==(Vec2< T > const &p) const
comparison==
Definition: libwps_internal.h:619
WPSBorder::Dot
Definition: libwps_internal.h:365
libwps::UPPERCASE
Definition: libwps_internal.h:470
libwps::readDouble10
bool readDouble10(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 10 bytes: mantisse 8 bytes, exponent 2 bytes
Definition: libwps_internal.cpp:223
WPSEmbeddedObject::isEmpty
bool isEmpty() const
return true if the picture contains no data
Definition: libwps_internal.h:438
WPSHeaderPtr
shared_ptr< WPSHeader > WPSHeaderPtr
shared pointer to WPSHeader
Definition: libwps_internal.h:108
WPSBorder::Right
Definition: libwps_internal.h:368
libwps::DOC_TABLE
Definition: libwps_internal.h:472
Vec2::operator!=
bool operator!=(Vec2< T > const &p) const
comparison!=
Definition: libwps_internal.h:624
Vec2::y
T y() const
second element
Definition: libwps_internal.h:534
Vec2::Vec2
Vec2(T xx=0, T yy=0)
constructor
Definition: libwps_internal.h:524
Box2f
Box2< float > Box2f
Box2 of float.
Definition: libwps_internal.h:885
WPSListenerPtr
shared_ptr< WPSListener > WPSListenerPtr
shared pointer to WPSListener
Definition: libwps_internal.h:104
Vec2::setX
void setX(T xx)
resets the first element
Definition: libwps_internal.h:558
libwps::NoBreakBit
Definition: libwps_internal.h:476
Box2< int >::Map
std::map< Box2< int >, int, struct PosSizeLt > Map
Definition: libwps_internal.h:875
WPSBorder::WPSBorder
WPSBorder()
constructor
Definition: libwps_internal.h:372
WPSBorder::Bottom
Definition: libwps_internal.h:368
libwps::SubDocumentType
SubDocumentType
Definition: libwps_internal.h:472
libwps::NONE
Definition: libwps_internal.h:470
libwps::JustificationFull
Definition: libwps_internal.h:473
libwps::DOC_HEADER_FOOTER
Definition: libwps_internal.h:472
libwps::ParseException
Definition: libwps_internal.h:147
WPSBorder::m_widthsList
std::vector< double > m_widthsList
the different length used for each line/sep (if defined)
Definition: libwps_internal.h:410
WKSSubDocument
Basic class used to store a spreadsheet sub document.
Definition: WKSSubDocument.h:35
libwps::JustificationFullAllLines
Definition: libwps_internal.h:474
libwps::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string ( with correct encoding ).
Definition: libwps_internal.cpp:630
WPSColor::isWhite
bool isWhite() const
return true if the color is white
Definition: libwps_internal.h:318
WKSContentListenerPtr
shared_ptr< WKSContentListener > WKSContentListenerPtr
shared pointer to WKSContentListener
Definition: libwps_internal.h:113
WPSHeader
Definition: WPSHeader.h:31
Box2::max
Vec2< T > const & max() const
the maximum 2D point (in x and in y)
Definition: libwps_internal.h:725
WPSBorder::operator!=
bool operator!=(WPSBorder const &orig) const
operator!=
Definition: libwps_internal.h:390
libwps::DOC_NONE
Definition: libwps_internal.h:472
libwps::VersionException
Definition: libwps_internal.h:137
WPSColor::getBlue
unsigned char getBlue() const
returns the green value
Definition: libwps_internal.h:298
Box2::Box2
Box2(Box2< U > const &p)
generic constructor
Definition: libwps_internal.h:714
WPSColor::m_value
uint32_t m_value
the argb color
Definition: libwps_internal.h:358
Vec2::PosSizeLtY
internal struct used to create sorted map, sorted by Y
Definition: libwps_internal.h:678
Box2::m_pt
Vec2< T > m_pt[2]
the two extremities
Definition: libwps_internal.h:879
Vec2::x
T x() const
first element
Definition: libwps_internal.h:529
WPS_shared_ptr_noop_deleter::operator()
void operator()(T *)
Definition: libwps_internal.h:82
WPSBorder::Type
Type
the line repetition
Definition: libwps_internal.h:367
libwps::read8
int8_t read8(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:58
Vec2::add
void add(T dx, T dy)
increases the actuals values by dx and dy
Definition: libwps_internal.h:569
WPSEmbeddedObject::m_dataList
std::vector< librevenge::RVNGBinaryData > m_dataList
the picture content: one data by representation
Definition: libwps_internal.h:463
WPSColumnProperties::m_alignment
uint8_t m_alignment
Definition: libwps_internal.h:252
WPSColumnDefinition
Definition: libwps_internal.h:236
Vec2::PosSizeLtY::operator()
bool operator()(Vec2< T > const &s1, Vec2< T > const &s2) const
comparaison function
Definition: libwps_internal.h:681
WPSBorder::isEmpty
bool isEmpty() const
returns true if the border is empty
Definition: libwps_internal.h:378
WPSColumnProperties::WPSColumnProperties
WPSColumnProperties()
Definition: libwps_internal.h:248
Vec2::operator-=
Vec2< T > & operator-=(Vec2< T > const &p)
operator-=
Definition: libwps_internal.h:583
WPSBorder::m_color
WPSColor m_color
the border color
Definition: libwps_internal.h:412
Vec2::operator*=
Vec2< T > & operator*=(U scale)
generic operator*=
Definition: libwps_internal.h:591
libwps::NumberingType
NumberingType
Definition: libwps_internal.h:470
WPSColor::value
uint32_t value() const
return the rgba value
Definition: libwps_internal.h:288
WPSColor::operator!=
bool operator!=(WPSColor const &c) const
operator!=
Definition: libwps_internal.h:328
WPSBorder::BottomBit
Definition: libwps_internal.h:369
Vec2::cmpY
int cmpY(Vec2< T > const &p) const
a comparison function: which first compares y then x
Definition: libwps_internal.h:643
WPSBorder::addTo
bool addTo(librevenge::RVNGPropertyList &propList, std::string which="") const
add the border property to proplist (if needed )
Definition: libwps_internal.cpp:441
Vec2< bool >::MapX
std::map< Vec2< bool >, bool, struct PosSizeLtX > MapX
Definition: libwps_internal.h:673
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:70
RVNGInputStreamPtr
shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
libwps::readDouble4Inv
bool readDouble4Inv(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 4 bytes: exponent 3.5 bytes, mantisse 0.5 bytes
Definition: libwps_internal.cpp:302
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libwps_internal.h:697
WPSColor
the class to store a color
Definition: libwps_internal.h:256
WPSEmbeddedObject::~WPSEmbeddedObject
virtual ~WPSEmbeddedObject()
destructor
Definition: libwps_internal.h:434
WPSBorder::operator<<
friend std::ostream & operator<<(std::ostream &o, WPSBorder const &border)
operator<<
Definition: libwps_internal.cpp:543
WPSBorder::Simple
Definition: libwps_internal.h:365
WPSBorder::Pos
Pos
Definition: libwps_internal.h:368
libwps::JustificationRight
Definition: libwps_internal.h:474
Vec2::Vec2
Vec2(Vec2< U > const &p)
generic copy constructor
Definition: libwps_internal.h:526
Box2::operator==
bool operator==(Box2< T > const &p) const
comparison operator==
Definition: libwps_internal.h:829
Vec2::operator[]
T operator[](int c) const
operator[]
Definition: libwps_internal.h:539
libwps::readData
bool readData(RVNGInputStreamPtr &input, unsigned long size, librevenge::RVNGBinaryData &data)
try to read sz bytes from input and store them in a librevenge::RVNGBinaryData
Definition: libwps_internal.cpp:331
WPSBorder::compare
int compare(WPSBorder const &orig) const
compare two cell
Definition: libwps_internal.cpp:423
WPSColor::getGreen
unsigned char getGreen() const
returns the green value
Definition: libwps_internal.h:308
Box2::resizeFromMax
void resizeFromMax(Vec2< T > const &sz)
resize the box keeping the maximum
Definition: libwps_internal.h:782
WPSColor::operator<=
bool operator<=(WPSColor const &c) const
operator<=
Definition: libwps_internal.h:338
libwps::readU16
uint16_t readU16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:63
libwps::readDataToEnd
bool readDataToEnd(RVNGInputStreamPtr &input, librevenge::RVNGBinaryData &data)
try to read the last bytes from input and store them in a librevenge::RVNGBinaryData ...
Definition: libwps_internal.cpp:345
Box2::scale
void scale(U factor)
scales all points of the box by factor
Definition: libwps_internal.h:795
libwps::numberingTypeToString
std::string numberingTypeToString(NumberingType type)
Definition: libwps_internal.cpp:356
WPSColor::operator>
bool operator>(WPSColor const &c) const
operator>
Definition: libwps_internal.h:343
Box2::setMax
void setMax(Vec2< T > const &y)
resets the maximum point
Definition: libwps_internal.h:771
Box2::getUnion
Box2< T > getUnion(Box2< T > const &box) const
returns the union between this and box
Definition: libwps_internal.h:808
WPSBorder::Style
Style
the line style
Definition: libwps_internal.h:365
WPSBorder::Single
Definition: libwps_internal.h:367
WPSBorder::operator==
bool operator==(WPSBorder const &orig) const
operator==
Definition: libwps_internal.h:384
Box2::setMin
void setMin(Vec2< T > const &x)
resets the minimum point
Definition: libwps_internal.h:766
WPSEmbeddedObject
small class use to define a embedded object
Definition: libwps_internal.h:421
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:75
Box2::Box2
Box2(Vec2< T > minPt=Vec2< T >(), Vec2< T > maxPt=Vec2< T >())
constructor
Definition: libwps_internal.h:708
libwps::FileException
Definition: libwps_internal.h:142
WPSBorder::LeftBit
Definition: libwps_internal.h:369
WPSColumnDefinition::WPSColumnDefinition
WPSColumnDefinition()
Definition: libwps_internal.h:238
WPSBorder::m_style
Style m_style
the border style
Definition: libwps_internal.h:402
libwps::JustificationLeft
Definition: libwps_internal.h:473
libwps::UPPERCASE_ROMAN
Definition: libwps_internal.h:470
WKSSubDocumentPtr
shared_ptr< WKSSubDocument > WKSSubDocumentPtr
shared pointer to WKSSubDocument
Definition: libwps_internal.h:115
libwps::readDouble8
bool readDouble8(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 8 bytes: mantisse 6.5 bytes, exponent 1.5 bytes
Definition: libwps_internal.cpp:172
libwps::JustificationCenter
Definition: libwps_internal.h:473
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:37
Vec2
small class which defines a vector with 2 elements
Definition: libwps_internal.h:520
Vec2::PosSizeLtX::operator()
bool operator()(Vec2< T > const &s1, Vec2< T > const &s2) const
comparaison function
Definition: libwps_internal.h:665
libwps::ARABIC
Definition: libwps_internal.h:470
WPSEmbeddedObject::addTo
bool addTo(librevenge::RVNGPropertyList &propList) const
add the link property to proplist
Definition: libwps_internal.cpp:580
Vec2::operator*
friend Vec2< T > operator*(U scale, Vec2< T > const &p1)
generic operator*
Definition: libwps_internal.h:612
WPSPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: WPSPosition.h:39
Box2::size
Vec2< T > size() const
the box size
Definition: libwps_internal.h:749
WPSEmbeddedObject::operator<<
friend std::ostream & operator<<(std::ostream &o, WPSEmbeddedObject const &pict)
operator<<
Definition: libwps_internal.cpp:610
WPSBorder::m_extra
std::string m_extra
extra data ( if needed)
Definition: libwps_internal.h:414
WPSCellPtr
shared_ptr< WPSCell > WPSCellPtr
shared pointer to WPSCell
Definition: libwps_internal.h:99
libwps::readDouble2Inv
bool readDouble2Inv(RVNGInputStreamPtr &input, double &res, bool &isNaN)
read a double store with 2 bytes: exponent 1.5 bytes, kind of mantisse 0.5 bytes
Definition: libwps_internal.cpp:272
Box2::getIntersection
Box2< T > getIntersection(Box2< T > const &box) const
returns the intersection between this and box
Definition: libwps_internal.h:818
WPSColor::WPSColor
WPSColor(uint32_t argb=0)
constructor
Definition: libwps_internal.h:259
Vec2::m_y
T m_y
second element
Definition: libwps_internal.h:691
WPS_shared_ptr_noop_deleter
a noop deleter used to transform a librevenge pointer in a false shared_ptr
Definition: libwps_internal.h:80
Box2::PosSizeLt::operator()
bool operator()(Box2< T > const &s1, Box2< T > const &s2) const
comparaison function
Definition: libwps_internal.h:867
WPSBorder::m_type
Type m_type
the border repetition
Definition: libwps_internal.h:404
WKSContentListener
Definition: WKSContentListener.h:50
Vec2::cmp
int cmp(Vec2< T > const &p) const
a comparison function: which first compares x then y
Definition: libwps_internal.h:634
WPSColor::str
std::string str() const
print the color in the form #rrggbb
Definition: libwps_internal.cpp:412
Vec2b
Vec2< bool > Vec2b
Vec2 of bool.
Definition: libwps_internal.h:695
WPSBorder::TopBit
Definition: libwps_internal.h:369
WPSColor::getAlpha
unsigned char getAlpha() const
returns the alpha value
Definition: libwps_internal.h:293
Box2::resizeFromCenter
void resizeFromCenter(Vec2< T > const &sz)
resize the box keeping the center
Definition: libwps_internal.h:787
Box2::min
Vec2< T > & min()
the minimum 2D point (in x and in y)
Definition: libwps_internal.h:730
Vec2::operator+
friend Vec2< T > operator+(Vec2< T > const &p1, Vec2< T > const &p2)
operator+
Definition: libwps_internal.h:599