libstaroffice_internal.hxx Source File documentation

libstaroffice_internal.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 LIBSTAROFFICE_INTERNAL_H
35#define LIBSTAROFFICE_INTERNAL_H
36
37#include <assert.h>
38#include <math.h>
39#ifdef DEBUG
40#include <stdio.h>
41#endif
42
43#include <cmath>
44#include <limits>
45#include <map>
46#include <memory>
47#include <ostream>
48#include <string>
49#include <vector>
50
51#ifndef M_PI
52#define M_PI 3.14159265358979323846
53#endif
54
55#include <librevenge-stream/librevenge-stream.h>
56#include <librevenge/librevenge.h>
57
58#if defined(_MSC_VER) || defined(__DJGPP__)
59
60typedef signed char int8_t;
61typedef unsigned char uint8_t;
62typedef signed short int16_t;
63typedef unsigned short uint16_t;
64typedef signed int int32_t;
65typedef unsigned int uint32_t;
66typedef unsigned __int64 uint64_t;
67typedef __int64 int64_t;
68
69#else /* !_MSC_VER && !__DJGPP__*/
70
71# ifdef HAVE_CONFIG_H
72
73# include <config.h>
74# ifdef HAVE_STDINT_H
75# include <stdint.h>
76# endif
77# ifdef HAVE_INTTYPES_H
78# include <inttypes.h>
79# endif
80
81# else
82
83// assume that the headers are there inside LibreOffice build when no HAVE_CONFIG_H is defined
84# include <stdint.h>
85# include <inttypes.h>
86
87# endif
88
89#endif /* _MSC_VER || __DJGPP__ */
90
91// define gmtime_r and localtime_r on Windows, so that can use
92// thread-safe functions on other environments
93#ifdef _WIN32
94# define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
95# define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
96#endif
97
99template <class T>
100 struct STOFF_shared_ptr_noop_deleter {
101 void operator()(T *) {}
102};
103
105#if defined(HAVE_CLANG_ATTRIBUTE_FALLTHROUGH)
106# define STOFF_FALLTHROUGH [[clang::fallthrough]]
107#elif defined(HAVE_GCC_ATTRIBUTE_FALLTHROUGH)
108# define STOFF_FALLTHROUGH __attribute__((fallthrough))
109#else
110# define STOFF_FALLTHROUGH ((void) 0)
111#endif
112
113#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
114# define LIBSTOFF_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
115#else
116# define LIBSTOFF_ATTRIBUTE_PRINTF(fmt, arg)
117#endif
118
119#define STOFF_N_ELEMENTS(m) sizeof(m)/sizeof(m[0])
120
121/* ---------- debug --------------- */
122#ifdef DEBUG
123namespace libstoff
124{
125void printDebugMsg(const char *format, ...) LIBSTOFF_ATTRIBUTE_PRINTF(1,2);
126}
127#define STOFF_DEBUG_MSG(M) libstoff::printDebugMsg M
128#else
129#define STOFF_DEBUG_MSG(M)
130#endif
131
132namespace libstoff
133{
134// Various exceptions:
135 class VersionException
136{
137};
138
139 class FileException
140{
141};
142
143 class ParseException
144{
145};
146
147 class GenericException
148{
149};
150
151 class WrongPasswordException
152{
153};
154}
155
156/* ---------- input ----------------- */
157namespace libstoff
158{
159uint8_t readU8(librevenge::RVNGInputStream *input);
161void appendUnicode(uint32_t val, librevenge::RVNGString &buffer);
163librevenge::RVNGString getString(std::vector<uint32_t> const &unicode);
164
166template<typename T>
167 bool checkAddOverflow(T x, T y)
168{
169 return (x < 0 && y < std::numeric_limits<T>::lowest() - x)
170 || (x > 0 && y > std::numeric_limits<T>::max() - x);
171}
172}
173
174/* ---------- small enum/class ------------- */
175namespace libstoff
176{
178 enum Position { Left = 0, Right = 1, Top = 2, Bottom = 3, HMiddle = 4, VMiddle = 5 };
180 enum { LeftBit = 0x01, RightBit = 0x02, TopBit=0x4, BottomBit = 0x08, HMiddleBit = 0x10, VMiddleBit = 0x20 };
181
182 enum NumberingType { NONE, BULLET, ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
183std::string numberingTypeToString(NumberingType type);
184std::string numberingValueToString(NumberingType type, int value);
185 enum SubDocumentType { DOC_NONE, DOC_CHART, DOC_CHART_ZONE, DOC_COMMENT_ANNOTATION, DOC_GRAPHIC_GROUP, DOC_HEADER_FOOTER_REGION, DOC_NOTE, DOC_SHEET, DOC_TABLE, DOC_TEXT_BOX };
186}
187
189 struct STOFFColor {
191 explicit STOFFColor(uint32_t argb=0) : m_value(argb)
192 {
193 }
194
195 STOFFColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) :
196 m_value(uint32_t((a<<24)+(r<<16)+(g<<8)+b))
197 {
198 }
199
200 STOFFColor &operator=(uint32_t argb)
201 {
202 m_value = argb;
203 return *this;
204 }
205
206 static STOFFColor colorFromCMYK(unsigned char c, unsigned char m, unsigned char y, unsigned char k)
207 {
208 double w=1.-double(k)/255.;
209 return STOFFColor
210 (static_cast<unsigned char>(255 * (1-double(c)/255) * w),
211 static_cast<unsigned char>(255 * (1-double(m)/255) * w),
212 static_cast<unsigned char>(255 * (1-double(y)/255) * w)
213 );
214 }
215
216 static STOFFColor colorFromHSL(unsigned char H, unsigned char S, unsigned char L)
217 {
218 double c=(1-((L>=128) ? (2*double(L)-255) : (255-2*double(L)))/255)*
219 double(S)/255;
220 double tmp=std::fmod((double(H)*6/255),2)-1;
221 double x=c*(1-(tmp>0 ? tmp : -tmp));
222 auto C=static_cast<unsigned char>(255*c);
223 auto M=static_cast<unsigned char>(double(L)-255*c/2);
224 auto X=static_cast<unsigned char>(255*x);
225 if (H<=42) return STOFFColor(static_cast<unsigned char>(M+C),static_cast<unsigned char>(M+X),static_cast<unsigned char>(M));
226 if (H<=85) return STOFFColor(static_cast<unsigned char>(M+X),static_cast<unsigned char>(M+C),static_cast<unsigned char>(M));
227 if (H<=127) return STOFFColor(static_cast<unsigned char>(M),static_cast<unsigned char>(M+C),static_cast<unsigned char>(M+X));
228 if (H<=170) return STOFFColor(static_cast<unsigned char>(M),static_cast<unsigned char>(M+X),static_cast<unsigned char>(M+C));
229 if (H<=212) return STOFFColor(static_cast<unsigned char>(M+X),static_cast<unsigned char>(M),static_cast<unsigned char>(M+C));
230 return STOFFColor(static_cast<unsigned char>(M+C),static_cast<unsigned char>(M),static_cast<unsigned char>(M+X));
231 }
232
233 static STOFFColor black()
234 {
235 return STOFFColor(0,0,0);
236 }
237
238 static STOFFColor white()
239 {
240 return STOFFColor(255,255,255);
241 }
242
244 static STOFFColor barycenter(float alpha, STOFFColor const &colA,
245 float beta, STOFFColor const &colB);
247 uint32_t value() const
248 {
249 return m_value;
250 }
251
252 unsigned char getAlpha() const
253 {
254 return static_cast<unsigned char>((m_value>>24)&0xFF);
255 }
256
257 void setAlpha(unsigned char alpha)
258 {
259 m_value=(m_value&0xFFFFFF)|uint32_t(alpha<<24);
260 }
261
262 unsigned char getBlue() const
263 {
264 return static_cast<unsigned char>(m_value&0xFF);
265 }
266
267 unsigned char getRed() const
268 {
269 return static_cast<unsigned char>((m_value>>16)&0xFF);
270 }
271
272 unsigned char getGreen() const
273 {
274 return static_cast<unsigned char>((m_value>>8)&0xFF);
275 }
276
277 bool isBlack() const
278 {
279 return (m_value&0xFFFFFF)==0;
280 }
281
282 bool isWhite() const
283 {
284 return (m_value&0xFFFFFF)==0xFFFFFF;
285 }
286
287 bool operator==(STOFFColor const &c) const
288 {
289 return (c.m_value&0xFFFFFF)==(m_value&0xFFFFFF);
290 }
291
292 bool operator!=(STOFFColor const &c) const
293 {
294 return !operator==(c);
295 }
296
297 bool operator<(STOFFColor const &c) const
298 {
299 return (c.m_value&0xFFFFFF)<(m_value&0xFFFFFF);
300 }
301
302 bool operator<=(STOFFColor const &c) const
303 {
304 return (c.m_value&0xFFFFFF)<=(m_value&0xFFFFFF);
305 }
306
307 bool operator>(STOFFColor const &c) const
308 {
309 return !operator<=(c);
310 }
311
312 bool operator>=(STOFFColor const &c) const
313 {
314 return !operator<(c);
315 }
316
317 friend std::ostream &operator<< (std::ostream &o, STOFFColor const &c);
319 std::string str() const;
320protected:
322 uint32_t m_value;
323};
324
326 struct STOFFBorderLine {
328 STOFFBorderLine() : m_outWidth(0), m_inWidth(0), m_color(STOFFColor::black()), m_distance(0) { }
332 bool addTo(librevenge::RVNGPropertyList &propList, std::string which="") const;
334 bool isEmpty() const
335 {
336 return m_outWidth==0 && m_inWidth==0;
337 }
338
339 bool operator==(STOFFBorderLine const &orig) const
340 {
341 return !operator!=(orig);
342 }
343
344 bool operator!=(STOFFBorderLine const &orig) const
345 {
346 return m_outWidth != orig.m_outWidth || m_inWidth != orig.m_inWidth ||
347 m_distance != orig.m_distance || m_color != orig.m_color;
348 }
349
351 friend std::ostream &operator<< (std::ostream &o, STOFFBorderLine const &border);
353 int m_outWidth;
355 int m_inWidth;
357 STOFFColor m_color;
359 int m_distance;
360};
361
363 struct STOFFField {
365 STOFFField() : m_propertyList()
366 {
367 }
368
369 void addTo(librevenge::RVNGPropertyList &propList) const;
371 librevenge::RVNGPropertyList m_propertyList;
372};
373
375 struct STOFFLink {
377 STOFFLink() : m_HRef("")
378 {
379 }
380
382 bool addTo(librevenge::RVNGPropertyList &propList) const;
383
385 std::string m_HRef;
386};
387
389 struct STOFFNote {
391 enum Type { FootNote, EndNote };
393 explicit STOFFNote(Type type) : m_type(type), m_label(""), m_number(-1)
394 {
395 }
396
397 Type m_type;
399 librevenge::RVNGString m_label;
401 int m_number;
402};
403
408 struct STOFFEmbeddedObject {
410 STOFFEmbeddedObject() : m_dataList(), m_typeList(), m_filenameLink("")
411 {
412 }
413
414 STOFFEmbeddedObject(librevenge::RVNGBinaryData const &binaryData,
415 std::string const &type="image/pict") : m_dataList(), m_typeList(), m_filenameLink("")
416 {
417 add(binaryData, type);
418 }
419 STOFFEmbeddedObject(STOFFEmbeddedObject const &)=default;
420 STOFFEmbeddedObject(STOFFEmbeddedObject &&)=default;
421 STOFFEmbeddedObject &operator=(STOFFEmbeddedObject const &)=default;
422 STOFFEmbeddedObject &operator=(STOFFEmbeddedObject &&)=default;
424 ~STOFFEmbeddedObject();
426 bool isEmpty() const
427 {
428 if (!m_filenameLink.empty())
429 return false;
430 for (const auto &i : m_dataList) {
431 if (!i.empty())
432 return false;
433 }
434 return true;
435 }
436
437 void add(librevenge::RVNGBinaryData const &binaryData, std::string const &type="image/pict")
438 {
439 size_t pos=m_dataList.size();
440 if (pos<m_typeList.size()) pos=m_typeList.size();
441 m_dataList.resize(pos+1);
442 m_dataList[pos]=binaryData;
443 m_typeList.resize(pos+1);
444 m_typeList[pos]=type;
445 }
446
447 bool addTo(librevenge::RVNGPropertyList &propList) const;
449 bool addAsFillImageTo(librevenge::RVNGPropertyList &propList) const;
451 friend std::ostream &operator<<(std::ostream &o, STOFFEmbeddedObject const &pict);
453 int cmp(STOFFEmbeddedObject const &pict) const;
454
456 std::vector<librevenge::RVNGBinaryData> m_dataList;
458 std::vector<std::string> m_typeList;
460 librevenge::RVNGString m_filenameLink;
461};
462
463// forward declarations of basic classes and smart pointers
464class STOFFFont;
465class STOFFFrameStyle;
466class STOFFGraphicShape;
467class STOFFGraphicStyle;
468class STOFFList;
469class STOFFParagraph;
470class STOFFSection;
471class STOFFPageSpan;
472
473class STOFFEntry;
474class STOFFHeader;
475class STOFFParser;
476class STOFFPosition;
477
478class STOFFGraphicListener;
479class STOFFInputStream;
480class STOFFListener;
481class STOFFListManager;
482class STOFFParserState;
483class STOFFSpreadsheetListener;
484class STOFFSubDocument;
485class STOFFTextListener;
487 typedef std::shared_ptr<STOFFGraphicListener> STOFFGraphicListenerPtr;
489 typedef std::shared_ptr<STOFFInputStream> STOFFInputStreamPtr;
491 typedef std::shared_ptr<STOFFListener> STOFFListenerPtr;
493 typedef std::shared_ptr<STOFFListManager> STOFFListManagerPtr;
495 typedef std::shared_ptr<STOFFParserState> STOFFParserStatePtr;
497 typedef std::shared_ptr<STOFFSpreadsheetListener> STOFFSpreadsheetListenerPtr;
499 typedef std::shared_ptr<STOFFSubDocument> STOFFSubDocumentPtr;
501 typedef std::shared_ptr<STOFFTextListener> STOFFTextListenerPtr;
502
509 template <class T> struct STOFFVariable {
511 STOFFVariable() : m_data(), m_set(false) {}
513 explicit STOFFVariable(T const &def) : m_data(def), m_set(false) {}
515 STOFFVariable(STOFFVariable const &orig) : m_data(orig.m_data), m_set(orig.m_set) {}
517 STOFFVariable &operator=(STOFFVariable const &orig)
518 {
519 if (this != &orig) {
520 m_data = orig.m_data;
521 m_set = orig.m_set;
522 }
523 return std::forward<STOFFVariable &>(*this);
524 }
525
526 STOFFVariable &operator=(T const &val)
527 {
528 m_data = val;
529 m_set = true;
530 return std::forward<STOFFVariable &>(*this);
531 }
532
533 void insert(STOFFVariable const &orig)
534 {
535 if (orig.m_set) {
536 m_data = orig.m_data;
537 m_set = orig.m_set;
538 }
539 }
540
541 T const *operator->() const
542 {
543 return &m_data;
544 }
545
546 T *operator->()
547 {
548 m_set = true;
549 return &m_data;
550 }
551
552 T const &operator*() const
553 {
554 return m_data;
555 }
556
557 T &operator*()
558 {
559 m_set = true;
560 return m_data;
561 }
562
563 T const &get() const
564 {
565 return m_data;
566 }
567
568 bool isSet() const
569 {
570 return m_set;
571 }
572
573 void setSet(bool newVal)
574 {
575 m_set=newVal;
576 }
577protected:
579 T m_data;
581 bool m_set;
582};
583
584/* ---------- vec2/box2f ------------- */
588 template <class T> class STOFFVec2
589{
590public:
592 STOFFVec2(T xx=0,T yy=0) : m_x(xx), m_y(yy) { }
594 template <class U> STOFFVec2(STOFFVec2<U> const &p) : m_x(T(p.x())), m_y(T(p.y())) {}
595
597 T x() const
598 {
599 return m_x;
600 }
601
602 T y() const
603 {
604 return m_y;
605 }
606
607 T operator[](int c) const
608 {
609 if (c<0 || c>1) throw libstoff::GenericException();
610 return (c==0) ? m_x : m_y;
611 }
612
613 T &operator[](int c)
614 {
615 if (c<0 || c>1) throw libstoff::GenericException();
616 return (c==0) ? m_x : m_y;
617 }
618
620 void set(T xx, T yy)
621 {
622 m_x = xx;
623 m_y = yy;
624 }
625
626 void setX(T xx)
627 {
628 m_x = xx;
629 }
630
631 void setY(T yy)
632 {
633 m_y = yy;
634 }
635
637 void add(T dx, T dy)
638 {
639 if (libstoff::checkAddOverflow(m_x, dx) || libstoff::checkAddOverflow(m_y, dy))
640 throw libstoff::GenericException();
641 m_x += dx;
642 m_y += dy;
643 }
644
646 STOFFVec2<T> &operator+=(STOFFVec2<T> const &p)
647 {
648 add(p.m_x, p.m_y);
649 return *this;
650 }
651
652 STOFFVec2<T> &operator-=(STOFFVec2<T> const &p)
653 {
654 // check if negation of either of the coords will cause overflow
655 const T diff = std::numeric_limits<T>::min() + std::numeric_limits<T>::max();
656 if (libstoff::checkAddOverflow(p.m_x, diff) || libstoff::checkAddOverflow(p.m_y, diff))
657 throw libstoff::GenericException();
658 add(-p.m_x, -p.m_y);
659 return *this;
660 }
661
662 template <class U>
663 STOFFVec2<T> &operator*=(U scale)
664 {
665 m_x = T(m_x*scale);
666 m_y = T(m_y*scale);
667 return *this;
668 }
669
671 friend STOFFVec2<T> operator+(STOFFVec2<T> const &p1, STOFFVec2<T> const &p2)
672 {
673 STOFFVec2<T> p(p1);
674 return p+=p2;
675 }
676
677 friend STOFFVec2<T> operator-(STOFFVec2<T> const &p1, STOFFVec2<T> const &p2)
678 {
679 STOFFVec2<T> p(p1);
680 return p-=p2;
681 }
682
683 template <class U>
684 friend STOFFVec2<T> operator*(U scale, STOFFVec2<T> const &p1)
685 {
686 STOFFVec2<T> p(p1);
687 return p *= scale;
688 }
689
691 bool operator==(STOFFVec2<T> const &p) const
692 {
693 return cmpY(p) == 0;
694 }
695
696 bool operator!=(STOFFVec2<T> const &p) const
697 {
698 return cmpY(p) != 0;
699 }
700
701 bool operator<(STOFFVec2<T> const &p) const
702 {
703 return cmpY(p) < 0;
704 }
705
706 int cmp(STOFFVec2<T> const &p) const
707 {
708 if (m_x < p.m_x) return -1;
709 if (m_x > p.m_x) return 1;
710 if (m_y < p.m_y) return -1;
711 if (m_y > p.m_y) return 1;
712 return 0;
713 }
714
715 int cmpY(STOFFVec2<T> const &p) const
716 {
717 if (m_y < p.m_y) return -1;
718 if (m_y > p.m_y) return 1;
719 if (m_x < p.m_x) return -1;
720 if (m_x > p.m_x) return 1;
721 return 0;
722 }
723
725 friend std::ostream &operator<< (std::ostream &o, STOFFVec2<T> const &f)
726 {
727 o << f.m_x << "x" << f.m_y;
728 return o;
729 }
730
734 struct PosSizeLtX {
736 bool operator()(STOFFVec2<T> const &s1, STOFFVec2<T> const &s2) const
737 {
738 return s1.cmp(s2) < 0;
739 }
740 };
741
744 typedef std::map<STOFFVec2<T>, T,struct PosSizeLtX> MapX;
745
749 struct PosSizeLtY {
751 bool operator()(STOFFVec2<T> const &s1, STOFFVec2<T> const &s2) const
752 {
753 return s1.cmpY(s2) < 0;
754 }
755 };
756
759 typedef std::map<STOFFVec2<T>, T,struct PosSizeLtY> MapY;
760protected:
761 T m_x, m_y;
762};
763
765 typedef STOFFVec2<bool> STOFFVec2b;
767 typedef STOFFVec2<int> STOFFVec2i;
769 typedef STOFFVec2<long> STOFFVec2l;
771 typedef STOFFVec2<float> STOFFVec2f;
772
776 template <class T> class STOFFVec3
777{
778public:
780 STOFFVec3(T xx=0,T yy=0,T zz=0)
781 {
782 m_val[0] = xx;
783 m_val[1] = yy;
784 m_val[2] = zz;
785 }
786
787 template <class U> STOFFVec3(STOFFVec3<U> const &p)
788 {
789 for (int c = 0; c < 3; c++) m_val[c] = T(p[c]);
790 }
791
793 T x() const
794 {
795 return m_val[0];
796 }
797
798 T y() const
799 {
800 return m_val[1];
801 }
802
803 T z() const
804 {
805 return m_val[2];
806 }
807
808 T operator[](int c) const
809 {
810 if (c<0 || c>2) throw libstoff::GenericException();
811 return m_val[c];
812 }
813
814 T &operator[](int c)
815 {
816 if (c<0 || c>2) throw libstoff::GenericException();
817 return m_val[c];
818 }
819
821 void set(T xx, T yy, T zz)
822 {
823 m_val[0] = xx;
824 m_val[1] = yy;
825 m_val[2] = zz;
826 }
827
828 void setX(T xx)
829 {
830 m_val[0] = xx;
831 }
832
833 void setY(T yy)
834 {
835 m_val[1] = yy;
836 }
837
838 void setZ(T zz)
839 {
840 m_val[2] = zz;
841 }
842
844 void add(T dx, T dy, T dz)
845 {
846 m_val[0] += dx;
847 m_val[1] += dy;
848 m_val[2] += dz;
849 }
850
852 STOFFVec3<T> &operator+=(STOFFVec3<T> const &p)
853 {
854 for (int c = 0; c < 3; c++) m_val[c] = T(m_val[c]+p.m_val[c]);
855 return *this;
856 }
857
858 STOFFVec3<T> &operator-=(STOFFVec3<T> const &p)
859 {
860 for (int c = 0; c < 3; c++) m_val[c] = T(m_val[c]-p.m_val[c]);
861 return *this;
862 }
863
864 template <class U>
865 STOFFVec3<T> &operator*=(U scale)
866 {
867 for (auto &c : m_val) c = T(c*scale);
868 return *this;
869 }
870
872 friend STOFFVec3<T> operator+(STOFFVec3<T> const &p1, STOFFVec3<T> const &p2)
873 {
874 STOFFVec3<T> p(p1);
875 return p+=p2;
876 }
877
878 friend STOFFVec3<T> operator-(STOFFVec3<T> const &p1, STOFFVec3<T> const &p2)
879 {
880 STOFFVec3<T> p(p1);
881 return p-=p2;
882 }
883
884 template <class U>
885 friend STOFFVec3<T> operator*(U scale, STOFFVec3<T> const &p1)
886 {
887 STOFFVec3<T> p(p1);
888 return p *= scale;
889 }
890
892 bool operator==(STOFFVec3<T> const &p) const
893 {
894 return cmp(p) == 0;
895 }
896
897 bool operator!=(STOFFVec3<T> const &p) const
898 {
899 return cmp(p) != 0;
900 }
901
902 bool operator<(STOFFVec3<T> const &p) const
903 {
904 return cmp(p) < 0;
905 }
906
907 int cmp(STOFFVec3<T> const &p) const
908 {
909 for (int c = 0; c < 3; c++) {
910 if (m_val[c]<p.m_val[c]) return -1;
911 if (m_val[c]>p.m_val[c]) return 1;
912 }
913 return 0;
914 }
915
917 friend std::ostream &operator<< (std::ostream &o, STOFFVec3<T> const &f)
918 {
919 o << f.m_val[0] << "x" << f.m_val[1] << "x" << f.m_val[2];
920 return o;
921 }
922
926 struct PosSizeLt {
928 bool operator()(STOFFVec3<T> const &s1, STOFFVec3<T> const &s2) const
929 {
930 return s1.cmp(s2) < 0;
931 }
932 };
933
936 typedef std::map<STOFFVec3<T>, T,struct PosSizeLt> Map;
937
938protected:
940 T m_val[3];
941};
942
944 typedef STOFFVec3<bool> STOFFVec3b;
946 typedef STOFFVec3<unsigned char> STOFFVec3uc;
948 typedef STOFFVec3<int> STOFFVec3i;
950 typedef STOFFVec3<float> STOFFVec3f;
951
955 template <class T> class STOFFBox2
956{
957public:
959 STOFFBox2(STOFFVec2<T> minPt=STOFFVec2<T>(), STOFFVec2<T> maxPt=STOFFVec2<T>())
960 {
961 m_pt[0] = minPt;
962 m_pt[1] = maxPt;
963 }
964
965 template <class U> STOFFBox2(STOFFBox2<U> const &p)
966 {
967 for (int c=0; c < 2; c++) m_pt[c] = p[c];
968 }
969
971 STOFFVec2<T> const &min() const
972 {
973 return m_pt[0];
974 }
975
976 STOFFVec2<T> const &max() const
977 {
978 return m_pt[1];
979 }
980
981 STOFFVec2<T> &min()
982 {
983 return m_pt[0];
984 }
985
986 STOFFVec2<T> &max()
987 {
988 return m_pt[1];
989 }
990
993 STOFFVec2<T> const &operator[](int c) const
994 {
995 if (c<0 || c>1) throw libstoff::GenericException();
996 return m_pt[c];
997 }
998
999 STOFFVec2<T> size() const
1000 {
1001 return m_pt[1]-m_pt[0];
1002 }
1003
1004 STOFFVec2<T> center() const
1005 {
1006 return STOFFVec2<T>((m_pt[0].x()+m_pt[1].x())/2,
1007 (m_pt[0].y()+m_pt[1].y())/2);
1008 }
1009
1011 void set(STOFFVec2<T> const &x, STOFFVec2<T> const &y)
1012 {
1013 m_pt[0] = x;
1014 m_pt[1] = y;
1015 }
1016
1017 void setMin(STOFFVec2<T> const &x)
1018 {
1019 m_pt[0] = x;
1020 }
1021
1022 void setMax(STOFFVec2<T> const &y)
1023 {
1024 m_pt[1] = y;
1025 }
1026
1028 void resizeFromMin(STOFFVec2<T> const &sz)
1029 {
1030 m_pt[1] = m_pt[0]+sz;
1031 }
1032
1033 void resizeFromMax(STOFFVec2<T> const &sz)
1034 {
1035 m_pt[0] = m_pt[1]-sz;
1036 }
1037
1038 void resizeFromCenter(STOFFVec2<T> const &sz)
1039 {
1040 STOFFVec2<T> centerPt = 0.5*(m_pt[0]+m_pt[1]);
1041 m_pt[0] = centerPt - 0.5*sz;
1042 m_pt[1] = centerPt + (sz - 0.5*sz);
1043 }
1044
1046 template <class U> void scale(U factor)
1047 {
1048 m_pt[0] *= factor;
1049 m_pt[1] *= factor;
1050 }
1051
1053 void extend(T val)
1054 {
1055 m_pt[0] -= STOFFVec2<T>(val/2,val/2);
1056 m_pt[1] += STOFFVec2<T>(val-(val/2),val-(val/2));
1057 }
1058
1060 STOFFBox2<T> getUnion(STOFFBox2<T> const &box) const
1061 {
1062 STOFFBox2<T> res;
1063 res.m_pt[0]=STOFFVec2<T>(m_pt[0][0]<box.m_pt[0][0]?m_pt[0][0] : box.m_pt[0][0],
1064 m_pt[0][1]<box.m_pt[0][1]?m_pt[0][1] : box.m_pt[0][1]);
1065 res.m_pt[1]=STOFFVec2<T>(m_pt[1][0]>box.m_pt[1][0]?m_pt[1][0] : box.m_pt[1][0],
1066 m_pt[1][1]>box.m_pt[1][1]?m_pt[1][1] : box.m_pt[1][1]);
1067 return res;
1068 }
1069
1070 STOFFBox2<T> getIntersection(STOFFBox2<T> const &box) const
1071 {
1072 STOFFBox2<T> res;
1073 res.m_pt[0]=STOFFVec2<T>(m_pt[0][0]>box.m_pt[0][0]?m_pt[0][0] : box.m_pt[0][0],
1074 m_pt[0][1]>box.m_pt[0][1]?m_pt[0][1] : box.m_pt[0][1]);
1075 res.m_pt[1]=STOFFVec2<T>(m_pt[1][0]<box.m_pt[1][0]?m_pt[1][0] : box.m_pt[1][0],
1076 m_pt[1][1]<box.m_pt[1][1]?m_pt[1][1] : box.m_pt[1][1]);
1077 return res;
1078 }
1079
1080 bool operator==(STOFFBox2<T> const &p) const
1081 {
1082 return cmp(p) == 0;
1083 }
1084
1085 bool operator!=(STOFFBox2<T> const &p) const
1086 {
1087 return cmp(p) != 0;
1088 }
1089
1090 bool operator<(STOFFBox2<T> const &p) const
1091 {
1092 return cmp(p) < 0;
1093 }
1094
1096 int cmp(STOFFBox2<T> const &p) const
1097 {
1098 int diff = m_pt[0].cmpY(p.m_pt[0]);
1099 if (diff) return diff;
1100 diff = m_pt[1].cmpY(p.m_pt[1]);
1101 if (diff) return diff;
1102 return 0;
1103 }
1104
1106 friend std::ostream &operator<< (std::ostream &o, STOFFBox2<T> const &f)
1107 {
1108 o << "(" << f.m_pt[0] << "<->" << f.m_pt[1] << ")";
1109 return o;
1110 }
1111
1115 struct PosSizeLt {
1117 bool operator()(STOFFBox2<T> const &s1, STOFFBox2<T> const &s2) const
1118 {
1119 return s1.cmp(s2) < 0;
1120 }
1121 };
1122
1125 typedef std::map<STOFFBox2<T>, T,struct PosSizeLt> Map;
1126
1127protected:
1129 STOFFVec2<T> m_pt[2];
1130};
1131
1133 typedef STOFFBox2<int> STOFFBox2i;
1135 typedef STOFFBox2<float> STOFFBox2f;
1137 typedef STOFFBox2<long> STOFFBox2l;
1138
1139namespace libstoff
1140{
1142bool convertToDateTime(uint32_t date, uint32_t time, std::string &dateTime);
1144void splitString(librevenge::RVNGString const &string, librevenge::RVNGString const &delim,
1145 librevenge::RVNGString &string1, librevenge::RVNGString &string2);
1149librevenge::RVNGString simplifyString(librevenge::RVNGString const &s);
1151std::string getCellName(STOFFVec2i const &cellPos, STOFFVec2b const &relative=STOFFVec2b(true,true));
1152// some geometrical function
1154float getScaleFactor(librevenge::RVNGUnit orig, librevenge::RVNGUnit dest);
1156 STOFFVec2f rotatePointAroundCenter(STOFFVec2f const &point, STOFFVec2f const &center, float angle);
1158 STOFFBox2f rotateBoxFromCenter(STOFFBox2f const &box, float angle);
1159}
1160#endif /* LIBSTAROFFICE_INTERNAL_H */
1161// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFBox2
small class which defines a 2D Box
Definition libstaroffice_internal.hxx:956
STOFFBox2::resizeFromMin
void resizeFromMin(STOFFVec2< T > const &sz)
resize the box keeping the minimum
Definition libstaroffice_internal.hxx:1028
STOFFBox2::extend
void extend(T val)
extends the bdbox by (val, val) keeping the center
Definition libstaroffice_internal.hxx:1053
STOFFBox2::getIntersection
STOFFBox2< T > getIntersection(STOFFBox2< T > const &box) const
returns the intersection between this and box
Definition libstaroffice_internal.hxx:1070
STOFFBox2::min
STOFFVec2< T > & min()
the minimum 2D point (in x and in y)
Definition libstaroffice_internal.hxx:981
STOFFBox2::STOFFBox2
STOFFBox2(STOFFBox2< U > const &p)
generic constructor
Definition libstaroffice_internal.hxx:965
STOFFBox2::operator[]
STOFFVec2< T > const & operator[](int c) const
the two extremum points which defined the box
Definition libstaroffice_internal.hxx:993
STOFFBox2::set
void set(STOFFVec2< T > const &x, STOFFVec2< T > const &y)
resets the data to minimum x and maximum y
Definition libstaroffice_internal.hxx:1011
STOFFBox2::operator<
bool operator<(STOFFBox2< T > const &p) const
comparison operator< : fist sorts min by Y,X values then max extremity
Definition libstaroffice_internal.hxx:1090
STOFFBox2::min
STOFFVec2< T > const & min() const
the minimum 2D point (in x and in y)
Definition libstaroffice_internal.hxx:971
STOFFBox2::setMin
void setMin(STOFFVec2< T > const &x)
resets the minimum point
Definition libstaroffice_internal.hxx:1017
STOFFBox2::setMax
void setMax(STOFFVec2< T > const &y)
resets the maximum point
Definition libstaroffice_internal.hxx:1022
STOFFBox2::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFBox2< T > const &f)
print data in form X0xY0<->X1xY1
Definition libstaroffice_internal.hxx:1106
STOFFBox2::size
STOFFVec2< T > size() const
the box size
Definition libstaroffice_internal.hxx:999
STOFFBox2::STOFFBox2
STOFFBox2(STOFFVec2< T > minPt=STOFFVec2< T >(), STOFFVec2< T > maxPt=STOFFVec2< T >())
constructor
Definition libstaroffice_internal.hxx:959
STOFFBox2< int >::m_pt
STOFFVec2< int > m_pt[2]
Definition libstaroffice_internal.hxx:1129
STOFFBox2::scale
void scale(U factor)
scales all points of the box by factor
Definition libstaroffice_internal.hxx:1046
STOFFBox2::cmp
int cmp(STOFFBox2< T > const &p) const
comparison function : fist sorts min by Y,X values then max extremity
Definition libstaroffice_internal.hxx:1096
STOFFBox2::resizeFromCenter
void resizeFromCenter(STOFFVec2< T > const &sz)
resize the box keeping the center
Definition libstaroffice_internal.hxx:1038
STOFFBox2::operator==
bool operator==(STOFFBox2< T > const &p) const
comparison operator==
Definition libstaroffice_internal.hxx:1080
STOFFBox2::resizeFromMax
void resizeFromMax(STOFFVec2< T > const &sz)
resize the box keeping the maximum
Definition libstaroffice_internal.hxx:1033
STOFFBox2::center
STOFFVec2< T > center() const
the box center
Definition libstaroffice_internal.hxx:1004
STOFFBox2::max
STOFFVec2< T > & max()
the maximum 2D point (in x and in y)
Definition libstaroffice_internal.hxx:986
STOFFBox2::operator!=
bool operator!=(STOFFBox2< T > const &p) const
comparison operator!=
Definition libstaroffice_internal.hxx:1085
STOFFBox2::max
STOFFVec2< T > const & max() const
the maximum 2D point (in x and in y)
Definition libstaroffice_internal.hxx:976
STOFFBox2::getUnion
STOFFBox2< T > getUnion(STOFFBox2< T > const &box) const
returns the union between this and box
Definition libstaroffice_internal.hxx:1060
STOFFBox2::Map
std::map< STOFFBox2< T >, T, struct PosSizeLt > Map
map of STOFFBox2
Definition libstaroffice_internal.hxx:1125
STOFFEntry
basic class to store an entry in a file This contained :
Definition STOFFEntry.hxx:47
STOFFFont
Class to store font.
Definition STOFFFont.hxx:44
STOFFFrameStyle
Class to store a frame style.
Definition STOFFFrameStyle.hxx:46
STOFFGraphicListener
This class contains the code needed to create Graphic document.
Definition STOFFGraphicListener.hxx:60
STOFFGraphicShape
a structure used to define a picture shape
Definition STOFFGraphicShape.hxx:46
STOFFGraphicStyle
Class to store a graphic style.
Definition STOFFGraphicStyle.hxx:45
STOFFHeader
a function used by STOFFDocument to store the version of document
Definition STOFFHeader.hxx:57
STOFFInputStream
Internal class used to read the file stream Internal class used to read the file stream,...
Definition STOFFInputStream.hxx:54
STOFFListManager
a manager which manages the lists, keeps the different kind of lists, to assure the unicity of each l...
Definition STOFFList.hxx:210
STOFFList
a small structure used to store the informations about a list
Definition STOFFList.hxx:110
STOFFListener
This class contains a virtual interface to all listener.
Definition STOFFListener.hxx:51
STOFFPageSpan
A class which defines the page properties.
Definition STOFFPageSpan.hxx:76
STOFFParagraph
class to store the paragraph properties
Definition STOFFParagraph.hxx:48
STOFFParserState
a class to define the parser state
Definition STOFFParser.hxx:50
STOFFParser
virtual class which defines the ancestor of all main zone parser
Definition STOFFParser.hxx:90
STOFFPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition STOFFPosition.hxx:48
STOFFSection
a class which stores section properties
Definition STOFFSection.hxx:46
STOFFSpreadsheetListener
This class contents the main functions needed to create a spreadsheet processing Document.
Definition STOFFSpreadsheetListener.hxx:65
STOFFSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition STOFFSubDocument.hxx:42
STOFFTextListener
This class contains the code needed to create Text document.
Definition STOFFTextListener.hxx:60
STOFFVec2
small class which defines a vector with 2 elements
Definition libstaroffice_internal.hxx:589
STOFFVec2::operator==
bool operator==(STOFFVec2< T > const &p) const
comparison==
Definition libstaroffice_internal.hxx:691
STOFFVec2::setX
void setX(T xx)
resets the first element
Definition libstaroffice_internal.hxx:626
STOFFVec2::operator*=
STOFFVec2< T > & operator*=(U scale)
generic operator*=
Definition libstaroffice_internal.hxx:663
STOFFVec2::operator*
friend STOFFVec2< T > operator*(U scale, STOFFVec2< T > const &p1)
generic operator*
Definition libstaroffice_internal.hxx:684
STOFFVec2::MapY
std::map< STOFFVec2< T >, T, struct PosSizeLtY > MapY
map of STOFFVec2
Definition libstaroffice_internal.hxx:759
STOFFVec2::STOFFVec2
STOFFVec2(STOFFVec2< U > const &p)
generic copy constructor
Definition libstaroffice_internal.hxx:594
STOFFVec2< bool >::m_y
bool m_y
Definition libstaroffice_internal.hxx:761
STOFFVec2::MapX
std::map< STOFFVec2< T >, T, struct PosSizeLtX > MapX
map of STOFFVec2
Definition libstaroffice_internal.hxx:744
STOFFVec2::operator+=
STOFFVec2< T > & operator+=(STOFFVec2< T > const &p)
operator+=
Definition libstaroffice_internal.hxx:646
STOFFVec2::setY
void setY(T yy)
resets the second element
Definition libstaroffice_internal.hxx:631
STOFFVec2< bool >::y
bool y() const
Definition libstaroffice_internal.hxx:602
STOFFVec2< bool >::m_x
bool m_x
Definition libstaroffice_internal.hxx:761
STOFFVec2::operator-=
STOFFVec2< T > & operator-=(STOFFVec2< T > const &p)
operator-=
Definition libstaroffice_internal.hxx:652
STOFFVec2::operator[]
T & operator[](int c)
operator[]
Definition libstaroffice_internal.hxx:613
STOFFVec2::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFVec2< T > const &f)
operator<<: prints data in form "XxY"
Definition libstaroffice_internal.hxx:725
STOFFVec2::cmpY
int cmpY(STOFFVec2< T > const &p) const
a comparison function: which first compares y then x
Definition libstaroffice_internal.hxx:715
STOFFVec2::cmp
int cmp(STOFFVec2< T > const &p) const
a comparison function: which first compares x then y
Definition libstaroffice_internal.hxx:706
STOFFVec2< bool >::x
bool x() const
Definition libstaroffice_internal.hxx:597
STOFFVec2::operator[]
T operator[](int c) const
operator[]
Definition libstaroffice_internal.hxx:607
STOFFVec2::STOFFVec2
STOFFVec2(T xx=0, T yy=0)
constructor
Definition libstaroffice_internal.hxx:592
STOFFVec2::set
void set(T xx, T yy)
resets the two elements
Definition libstaroffice_internal.hxx:620
STOFFVec2::add
void add(T dx, T dy)
increases the actuals values by dx and dy
Definition libstaroffice_internal.hxx:637
STOFFVec2::operator-
friend STOFFVec2< T > operator-(STOFFVec2< T > const &p1, STOFFVec2< T > const &p2)
operator-
Definition libstaroffice_internal.hxx:677
STOFFVec2::operator!=
bool operator!=(STOFFVec2< T > const &p) const
comparison!=
Definition libstaroffice_internal.hxx:696
STOFFVec2::operator<
bool operator<(STOFFVec2< T > const &p) const
comparison<: sort by y
Definition libstaroffice_internal.hxx:701
STOFFVec2::operator+
friend STOFFVec2< T > operator+(STOFFVec2< T > const &p1, STOFFVec2< T > const &p2)
operator+
Definition libstaroffice_internal.hxx:671
STOFFVec3
small class which defines a vector with 3 elements
Definition libstaroffice_internal.hxx:777
STOFFVec3< bool >::m_val
bool m_val[3]
Definition libstaroffice_internal.hxx:940
STOFFVec3::operator+
friend STOFFVec3< T > operator+(STOFFVec3< T > const &p1, STOFFVec3< T > const &p2)
operator+
Definition libstaroffice_internal.hxx:872
STOFFVec3::operator-
friend STOFFVec3< T > operator-(STOFFVec3< T > const &p1, STOFFVec3< T > const &p2)
operator-
Definition libstaroffice_internal.hxx:878
STOFFVec3::setX
void setX(T xx)
resets the first element
Definition libstaroffice_internal.hxx:828
STOFFVec3::z
T z() const
third element
Definition libstaroffice_internal.hxx:803
STOFFVec3::STOFFVec3
STOFFVec3(T xx=0, T yy=0, T zz=0)
constructor
Definition libstaroffice_internal.hxx:780
STOFFVec3::y
T y() const
second element
Definition libstaroffice_internal.hxx:798
STOFFVec3::x
T x() const
first element
Definition libstaroffice_internal.hxx:793
STOFFVec3::operator*=
STOFFVec3< T > & operator*=(U scale)
generic operator*=
Definition libstaroffice_internal.hxx:865
STOFFVec3::operator+=
STOFFVec3< T > & operator+=(STOFFVec3< T > const &p)
operator+=
Definition libstaroffice_internal.hxx:852
STOFFVec3::operator*
friend STOFFVec3< T > operator*(U scale, STOFFVec3< T > const &p1)
generic operator*
Definition libstaroffice_internal.hxx:885
STOFFVec3::set
void set(T xx, T yy, T zz)
resets the three elements
Definition libstaroffice_internal.hxx:821
STOFFVec3::STOFFVec3
STOFFVec3(STOFFVec3< U > const &p)
generic copy constructor
Definition libstaroffice_internal.hxx:787
STOFFVec3::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFVec3< T > const &f)
operator<<: prints data in form "XxYxZ"
Definition libstaroffice_internal.hxx:917
STOFFVec3::setZ
void setZ(T zz)
resets the third element
Definition libstaroffice_internal.hxx:838
STOFFVec3::operator[]
T & operator[](int c)
operator[]
Definition libstaroffice_internal.hxx:814
STOFFVec3::add
void add(T dx, T dy, T dz)
increases the actuals values by dx, dy, dz
Definition libstaroffice_internal.hxx:844
STOFFVec3::operator!=
bool operator!=(STOFFVec3< T > const &p) const
comparison!=
Definition libstaroffice_internal.hxx:897
STOFFVec3::operator<
bool operator<(STOFFVec3< T > const &p) const
comparison<: which first compares x values, then y values then z values.
Definition libstaroffice_internal.hxx:902
STOFFVec3::Map
std::map< STOFFVec3< T >, T, struct PosSizeLt > Map
map of STOFFVec3
Definition libstaroffice_internal.hxx:936
STOFFVec3::operator-=
STOFFVec3< T > & operator-=(STOFFVec3< T > const &p)
operator-=
Definition libstaroffice_internal.hxx:858
STOFFVec3::operator==
bool operator==(STOFFVec3< T > const &p) const
comparison==
Definition libstaroffice_internal.hxx:892
STOFFVec3::setY
void setY(T yy)
resets the second element
Definition libstaroffice_internal.hxx:833
STOFFVec3::cmp
int cmp(STOFFVec3< T > const &p) const
a comparison function: which first compares x values, then y values then z values.
Definition libstaroffice_internal.hxx:907
STOFFVec3::operator[]
T operator[](int c) const
operator[]
Definition libstaroffice_internal.hxx:808
libstoff::FileException
Definition libstaroffice_internal.hxx:140
libstoff::GenericException
Definition libstaroffice_internal.hxx:148
libstoff::ParseException
Definition libstaroffice_internal.hxx:144
libstoff::VersionException
Definition libstaroffice_internal.hxx:136
libstoff::WrongPasswordException
Definition libstaroffice_internal.hxx:152
STOFFVec2l
STOFFVec2< long > STOFFVec2l
STOFFVec2 of long.
Definition libstaroffice_internal.hxx:769
STOFFSubDocumentPtr
std::shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition libstaroffice_internal.hxx:499
STOFFGraphicListenerPtr
std::shared_ptr< STOFFGraphicListener > STOFFGraphicListenerPtr
a smart pointer of STOFFGraphicListener
Definition libstaroffice_internal.hxx:487
LIBSTOFF_ATTRIBUTE_PRINTF
#define LIBSTOFF_ATTRIBUTE_PRINTF(fmt, arg)
Definition libstaroffice_internal.hxx:116
STOFFSpreadsheetListenerPtr
std::shared_ptr< STOFFSpreadsheetListener > STOFFSpreadsheetListenerPtr
a smart pointer of STOFFSpreadsheetListener
Definition libstaroffice_internal.hxx:497
STOFFParserStatePtr
std::shared_ptr< STOFFParserState > STOFFParserStatePtr
a smart pointer of STOFFParserState
Definition libstaroffice_internal.hxx:495
STOFFBox2i
STOFFBox2< int > STOFFBox2i
STOFFBox2 of int.
Definition libstaroffice_internal.hxx:1133
STOFFListManagerPtr
std::shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition libstaroffice_internal.hxx:493
STOFFListenerPtr
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition libstaroffice_internal.hxx:491
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition libstaroffice_internal.hxx:767
STOFFVec3f
STOFFVec3< float > STOFFVec3f
STOFFVec3 of float.
Definition libstaroffice_internal.hxx:950
STOFFVec3b
STOFFVec3< bool > STOFFVec3b
STOFFVec3 of bool.
Definition libstaroffice_internal.hxx:944
STOFFBox2l
STOFFBox2< long > STOFFBox2l
STOFFBox2 of long.
Definition libstaroffice_internal.hxx:1137
STOFFVec3uc
STOFFVec3< unsigned char > STOFFVec3uc
STOFFVec3 of unsigned char.
Definition libstaroffice_internal.hxx:946
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition libstaroffice_internal.hxx:489
STOFFVec2b
STOFFVec2< bool > STOFFVec2b
STOFFVec2 of bool.
Definition libstaroffice_internal.hxx:765
STOFFVec2f
STOFFVec2< float > STOFFVec2f
STOFFVec2 of float.
Definition libstaroffice_internal.hxx:771
STOFFVec3i
STOFFVec3< int > STOFFVec3i
STOFFVec3 of int.
Definition libstaroffice_internal.hxx:948
STOFFBox2f
STOFFBox2< float > STOFFBox2f
STOFFBox2 of float.
Definition libstaroffice_internal.hxx:1135
STOFFTextListenerPtr
std::shared_ptr< STOFFTextListener > STOFFTextListenerPtr
a smart pointer of STOFFTextListener
Definition libstaroffice_internal.hxx:501
libstoff
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition libstaroffice_internal.cxx:51
libstoff::numberingTypeToString
std::string numberingTypeToString(NumberingType type)
Definition libstaroffice_internal.cxx:124
libstoff::NumberingType
NumberingType
Definition libstaroffice_internal.hxx:182
libstoff::UPPERCASE
@ UPPERCASE
Definition libstaroffice_internal.hxx:182
libstoff::ARABIC
@ ARABIC
Definition libstaroffice_internal.hxx:182
libstoff::LOWERCASE
@ LOWERCASE
Definition libstaroffice_internal.hxx:182
libstoff::LOWERCASE_ROMAN
@ LOWERCASE_ROMAN
Definition libstaroffice_internal.hxx:182
libstoff::UPPERCASE_ROMAN
@ UPPERCASE_ROMAN
Definition libstaroffice_internal.hxx:182
libstoff::NONE
@ NONE
Definition libstaroffice_internal.hxx:182
libstoff::BULLET
@ BULLET
Definition libstaroffice_internal.hxx:182
libstoff::HMiddleBit
@ HMiddleBit
Definition libstaroffice_internal.hxx:180
libstoff::TopBit
@ TopBit
Definition libstaroffice_internal.hxx:180
libstoff::BottomBit
@ BottomBit
Definition libstaroffice_internal.hxx:180
libstoff::RightBit
@ RightBit
Definition libstaroffice_internal.hxx:180
libstoff::VMiddleBit
@ VMiddleBit
Definition libstaroffice_internal.hxx:180
libstoff::LeftBit
@ LeftBit
Definition libstaroffice_internal.hxx:180
libstoff::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition libstaroffice_internal.cxx:81
libstoff::simplifyString
librevenge::RVNGString simplifyString(librevenge::RVNGString const &s)
returns a simplify version of a string.
Definition libstaroffice_internal.cxx:430
libstoff::getCellName
std::string getCellName(STOFFVec2i const &cellPos, STOFFVec2b const &relative)
returns the cell name corresponding to a cell's position
Definition libstaroffice_internal.cxx:455
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition libstaroffice_internal.cxx:63
libstoff::convertToDateTime
bool convertToDateTime(uint32_t date, uint32_t time, std::string &dateTime)
convert a date/time in a date time format
Definition libstaroffice_internal.cxx:389
libstoff::rotatePointAroundCenter
STOFFVec2f rotatePointAroundCenter(STOFFVec2f const &point, STOFFVec2f const &center, float angle)
rotate a point around center, angle is given in degree
Definition libstaroffice_internal.cxx:471
libstoff::Position
Position
basic position enum
Definition libstaroffice_internal.hxx:178
libstoff::Right
@ Right
Definition libstaroffice_internal.hxx:178
libstoff::Top
@ Top
Definition libstaroffice_internal.hxx:178
libstoff::VMiddle
@ VMiddle
Definition libstaroffice_internal.hxx:178
libstoff::HMiddle
@ HMiddle
Definition libstaroffice_internal.hxx:178
libstoff::Left
@ Left
Definition libstaroffice_internal.hxx:178
libstoff::Bottom
@ Bottom
Definition libstaroffice_internal.hxx:178
libstoff::numberingValueToString
std::string numberingValueToString(NumberingType type, int value)
Definition libstaroffice_internal.cxx:146
libstoff::checkAddOverflow
bool checkAddOverflow(T x, T y)
checks whether addition of x and y would overflow
Definition libstaroffice_internal.hxx:167
libstoff::getScaleFactor
float getScaleFactor(librevenge::RVNGUnit orig, librevenge::RVNGUnit dest)
factor to convert from one unit to other
Definition libstaroffice_internal.cxx:499
libstoff::SubDocumentType
SubDocumentType
Definition libstaroffice_internal.hxx:185
libstoff::DOC_SHEET
@ DOC_SHEET
Definition libstaroffice_internal.hxx:185
libstoff::DOC_TEXT_BOX
@ DOC_TEXT_BOX
Definition libstaroffice_internal.hxx:185
libstoff::DOC_GRAPHIC_GROUP
@ DOC_GRAPHIC_GROUP
Definition libstaroffice_internal.hxx:185
libstoff::DOC_NONE
@ DOC_NONE
Definition libstaroffice_internal.hxx:185
libstoff::DOC_HEADER_FOOTER_REGION
@ DOC_HEADER_FOOTER_REGION
Definition libstaroffice_internal.hxx:185
libstoff::DOC_CHART
@ DOC_CHART
Definition libstaroffice_internal.hxx:185
libstoff::DOC_COMMENT_ANNOTATION
@ DOC_COMMENT_ANNOTATION
Definition libstaroffice_internal.hxx:185
libstoff::DOC_CHART_ZONE
@ DOC_CHART_ZONE
Definition libstaroffice_internal.hxx:185
libstoff::DOC_TABLE
@ DOC_TABLE
Definition libstaroffice_internal.hxx:185
libstoff::DOC_NOTE
@ DOC_NOTE
Definition libstaroffice_internal.hxx:185
libstoff::rotateBoxFromCenter
STOFFBox2f rotateBoxFromCenter(STOFFBox2f const &box, float angle)
rotate a bdox and returns the final bdbox, angle is given in degree
Definition libstaroffice_internal.cxx:479
libstoff::splitString
void splitString(librevenge::RVNGString const &string, librevenge::RVNGString const &delim, librevenge::RVNGString &string1, librevenge::RVNGString &string2)
split a string in two. If the delimiter is not present, string1=string
Definition libstaroffice_internal.cxx:414
libstoff::readU8
uint8_t readU8(librevenge::RVNGInputStream *input)
Definition libstaroffice_internal.cxx:52
STOFFBorderLine
a border line
Definition libstaroffice_internal.hxx:326
STOFFBorderLine::m_color
STOFFColor m_color
the border color
Definition libstaroffice_internal.hxx:357
STOFFBorderLine::m_outWidth
int m_outWidth
the outline width in TWIP
Definition libstaroffice_internal.hxx:353
STOFFBorderLine::m_inWidth
int m_inWidth
the inline width in TWIP
Definition libstaroffice_internal.hxx:355
STOFFBorderLine::addTo
bool addTo(librevenge::RVNGPropertyList &propList, std::string which="") const
add the border property to proplist (if needed )
Definition libstaroffice_internal.cxx:256
STOFFBorderLine::operator==
bool operator==(STOFFBorderLine const &orig) const
operator==
Definition libstaroffice_internal.hxx:339
STOFFBorderLine::operator!=
bool operator!=(STOFFBorderLine const &orig) const
operator!=
Definition libstaroffice_internal.hxx:344
STOFFBorderLine::m_distance
int m_distance
the border distance
Definition libstaroffice_internal.hxx:359
STOFFBorderLine::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFBorderLine const &border)
operator<<
Definition libstaroffice_internal.cxx:282
STOFFBorderLine::STOFFBorderLine
STOFFBorderLine()
constructor
Definition libstaroffice_internal.hxx:328
STOFFBorderLine::isEmpty
bool isEmpty() const
returns true if the border is empty
Definition libstaroffice_internal.hxx:334
STOFFBox2::PosSizeLt
internal struct used to create sorted map, sorted first min then max
Definition libstaroffice_internal.hxx:1115
STOFFBox2::PosSizeLt::operator()
bool operator()(STOFFBox2< T > const &s1, STOFFBox2< T > const &s2) const
comparaison function
Definition libstaroffice_internal.hxx:1117
STOFFColor
the class to store a color
Definition libstaroffice_internal.hxx:189
STOFFColor::colorFromHSL
static STOFFColor colorFromHSL(unsigned char H, unsigned char S, unsigned char L)
return a color from a hsl color (basic)
Definition libstaroffice_internal.hxx:216
STOFFColor::getRed
unsigned char getRed() const
returns the red value
Definition libstaroffice_internal.hxx:267
STOFFColor::operator>=
bool operator>=(STOFFColor const &c) const
operator>=
Definition libstaroffice_internal.hxx:312
STOFFColor::operator=
STOFFColor & operator=(uint32_t argb)
operator=
Definition libstaroffice_internal.hxx:200
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
STOFFColor::getBlue
unsigned char getBlue() const
returns the green value
Definition libstaroffice_internal.hxx:262
STOFFColor::operator<
bool operator<(STOFFColor const &c) const
operator<
Definition libstaroffice_internal.hxx:297
STOFFColor::getGreen
unsigned char getGreen() const
returns the green value
Definition libstaroffice_internal.hxx:272
STOFFColor::colorFromCMYK
static STOFFColor colorFromCMYK(unsigned char c, unsigned char m, unsigned char y, unsigned char k)
return a color from a cmyk color ( basic)
Definition libstaroffice_internal.hxx:206
STOFFColor::black
static STOFFColor black()
return the back color
Definition libstaroffice_internal.hxx:233
STOFFColor::str
std::string str() const
print the color in the form #rrggbb
Definition libstaroffice_internal.cxx:226
STOFFColor::m_value
uint32_t m_value
the argb color
Definition libstaroffice_internal.hxx:322
STOFFColor::isBlack
bool isBlack() const
return true if the color is black
Definition libstaroffice_internal.hxx:277
STOFFColor::operator==
bool operator==(STOFFColor const &c) const
operator==
Definition libstaroffice_internal.hxx:287
STOFFColor::operator!=
bool operator!=(STOFFColor const &c) const
operator!=
Definition libstaroffice_internal.hxx:292
STOFFColor::setAlpha
void setAlpha(unsigned char alpha)
reset the alpha value
Definition libstaroffice_internal.hxx:257
STOFFColor::isWhite
bool isWhite() const
return true if the color is white
Definition libstaroffice_internal.hxx:282
STOFFColor::STOFFColor
STOFFColor(uint32_t argb=0)
constructor
Definition libstaroffice_internal.hxx:191
STOFFColor::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFColor const &c)
operator<< in the form #rrggbb
Definition libstaroffice_internal.cxx:214
STOFFColor::operator<=
bool operator<=(STOFFColor const &c) const
operator<=
Definition libstaroffice_internal.hxx:302
STOFFColor::getAlpha
unsigned char getAlpha() const
returns the alpha value
Definition libstaroffice_internal.hxx:252
STOFFColor::STOFFColor
STOFFColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
constructor from color
Definition libstaroffice_internal.hxx:195
STOFFColor::value
uint32_t value() const
return the rgba value
Definition libstaroffice_internal.hxx:247
STOFFColor::operator>
bool operator>(STOFFColor const &c) const
operator>
Definition libstaroffice_internal.hxx:307
STOFFColor::white
static STOFFColor white()
return the white color
Definition libstaroffice_internal.hxx:238
STOFFEmbeddedObject
small class use to define a embedded object
Definition libstaroffice_internal.hxx:408
STOFFEmbeddedObject::addAsFillImageTo
bool addAsFillImageTo(librevenge::RVNGPropertyList &propList) const
add the link property to a graph style as bitmap
Definition libstaroffice_internal.cxx:297
STOFFEmbeddedObject::STOFFEmbeddedObject
STOFFEmbeddedObject(STOFFEmbeddedObject &&)=default
STOFFEmbeddedObject::addTo
bool addTo(librevenge::RVNGPropertyList &propList) const
add the link property to proplist
Definition libstaroffice_internal.cxx:309
STOFFEmbeddedObject::STOFFEmbeddedObject
STOFFEmbeddedObject(librevenge::RVNGBinaryData const &binaryData, std::string const &type="image/pict")
constructor
Definition libstaroffice_internal.hxx:414
STOFFEmbeddedObject::m_typeList
std::vector< std::string > m_typeList
the picture type: one type by representation
Definition libstaroffice_internal.hxx:458
STOFFEmbeddedObject::STOFFEmbeddedObject
STOFFEmbeddedObject(STOFFEmbeddedObject const &)=default
STOFFEmbeddedObject::operator=
STOFFEmbeddedObject & operator=(STOFFEmbeddedObject const &)=default
STOFFEmbeddedObject::add
void add(librevenge::RVNGBinaryData const &binaryData, std::string const &type="image/pict")
add a picture
Definition libstaroffice_internal.hxx:437
STOFFEmbeddedObject::m_filenameLink
librevenge::RVNGString m_filenameLink
a picture link
Definition libstaroffice_internal.hxx:460
STOFFEmbeddedObject::operator=
STOFFEmbeddedObject & operator=(STOFFEmbeddedObject &&)=default
STOFFEmbeddedObject::m_dataList
std::vector< librevenge::RVNGBinaryData > m_dataList
the picture content: one data by representation
Definition libstaroffice_internal.hxx:456
STOFFEmbeddedObject::cmp
int cmp(STOFFEmbeddedObject const &pict) const
a comparison function
Definition libstaroffice_internal.cxx:347
STOFFEmbeddedObject::~STOFFEmbeddedObject
~STOFFEmbeddedObject()
destructor
Definition libstaroffice_internal.cxx:293
STOFFEmbeddedObject::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFEmbeddedObject const &pict)
operator<<
Definition libstaroffice_internal.cxx:372
STOFFEmbeddedObject::isEmpty
bool isEmpty() const
return true if the picture contains no data
Definition libstaroffice_internal.hxx:426
STOFFEmbeddedObject::STOFFEmbeddedObject
STOFFEmbeddedObject()
empty constructor
Definition libstaroffice_internal.hxx:410
STOFFField::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the property list
Definition libstaroffice_internal.hxx:371
STOFFField::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add the link property to proplist (if possible)
Definition libstaroffice_internal.cxx:234
STOFFField::STOFFField
STOFFField()
basic constructor
Definition libstaroffice_internal.hxx:365
STOFFLink::m_HRef
std::string m_HRef
the href field
Definition libstaroffice_internal.hxx:385
STOFFLink::addTo
bool addTo(librevenge::RVNGPropertyList &propList) const
add the link property to proplist (if needed )
Definition libstaroffice_internal.cxx:247
STOFFLink::STOFFLink
STOFFLink()
basic constructor
Definition libstaroffice_internal.hxx:377
STOFFNote::STOFFNote
STOFFNote(Type type)
constructor
Definition libstaroffice_internal.hxx:393
STOFFNote::m_label
librevenge::RVNGString m_label
the note label
Definition libstaroffice_internal.hxx:399
STOFFNote::m_number
int m_number
the note number if defined
Definition libstaroffice_internal.hxx:401
STOFFNote::Type
Type
enum to define note type
Definition libstaroffice_internal.hxx:391
STOFFNote::FootNote
@ FootNote
Definition libstaroffice_internal.hxx:391
STOFFNote::EndNote
@ EndNote
Definition libstaroffice_internal.hxx:391
STOFFNote::m_type
Type m_type
the note type
Definition libstaroffice_internal.hxx:397
STOFFVariable::insert
void insert(STOFFVariable const &orig)
update the current value if orig is set
Definition libstaroffice_internal.hxx:533
STOFFVariable::m_data
T m_data
the value
Definition libstaroffice_internal.hxx:579
STOFFVariable::STOFFVariable
STOFFVariable()
constructor
Definition libstaroffice_internal.hxx:511
STOFFVariable::STOFFVariable
STOFFVariable(T const &def)
constructor with a default value
Definition libstaroffice_internal.hxx:513
STOFFVariable::STOFFVariable
STOFFVariable(STOFFVariable const &orig)
copy constructor
Definition libstaroffice_internal.hxx:515
STOFFVariable::operator=
STOFFVariable & operator=(STOFFVariable const &orig)
copy operator
Definition libstaroffice_internal.hxx:517
STOFFVariable::setSet
void setSet(bool newVal)
define if the variable is set
Definition libstaroffice_internal.hxx:573
STOFFVariable::operator=
STOFFVariable & operator=(T const &val)
set a value
Definition libstaroffice_internal.hxx:526
STOFFVariable::operator*
T & operator*()
operator*
Definition libstaroffice_internal.hxx:557
STOFFVariable::operator->
T const * operator->() const
operator*
Definition libstaroffice_internal.hxx:541
STOFFVariable::isSet
bool isSet() const
return true if the variable is set
Definition libstaroffice_internal.hxx:568
STOFFVariable::get
T const & get() const
return the current value
Definition libstaroffice_internal.hxx:563
STOFFVariable::operator*
T const & operator*() const
operator*
Definition libstaroffice_internal.hxx:552
STOFFVariable::operator->
T * operator->()
operator*
Definition libstaroffice_internal.hxx:546
STOFFVariable::m_set
bool m_set
a flag to know if the variable is set or not
Definition libstaroffice_internal.hxx:581
STOFFVec2::PosSizeLtX
internal struct used to create sorted map, sorted by X
Definition libstaroffice_internal.hxx:734
STOFFVec2::PosSizeLtX::operator()
bool operator()(STOFFVec2< T > const &s1, STOFFVec2< T > const &s2) const
comparaison function
Definition libstaroffice_internal.hxx:736
STOFFVec2::PosSizeLtY
internal struct used to create sorted map, sorted by Y
Definition libstaroffice_internal.hxx:749
STOFFVec2::PosSizeLtY::operator()
bool operator()(STOFFVec2< T > const &s1, STOFFVec2< T > const &s2) const
comparaison function
Definition libstaroffice_internal.hxx:751
STOFFVec3::PosSizeLt
internal struct used to create sorted map, sorted by X, Y, Z
Definition libstaroffice_internal.hxx:926
STOFFVec3::PosSizeLt::operator()
bool operator()(STOFFVec3< T > const &s1, STOFFVec3< T > const &s2) const
comparaison function
Definition libstaroffice_internal.hxx:928
STOFF_shared_ptr_noop_deleter
an noop deleter used to transform a libwpd pointer in a false std::shared_ptr
Definition libstaroffice_internal.hxx:100
STOFF_shared_ptr_noop_deleter::operator()
void operator()(T *)
Definition libstaroffice_internal.hxx:101