Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportUtils.h
Show All 31 Lines | |||||
32 | class QFont; | 32 | class QFont; | ||
33 | class QPointF; | 33 | class QPointF; | ||
34 | class KProperty; | 34 | class KProperty; | ||
35 | class KReportTextStyleData; | 35 | class KReportTextStyleData; | ||
36 | class KReportLineStyle; | 36 | class KReportLineStyle; | ||
37 | 37 | | |||
38 | namespace KReportUtils | 38 | namespace KReportUtils | ||
39 | { | 39 | { | ||
40 | KREPORT_EXPORT QString attr(const QDomElement &el, const char *attrName, | 40 | KREPORT_EXPORT QString attr(const QDomElement &el, const QString &attrName, | ||
41 | const QString &defaultValue = QString()); | 41 | const QString &defaultValue = QString()); | ||
42 | 42 | | |||
43 | KREPORT_EXPORT QByteArray attr(const QDomElement &el, const char *attrName, | 43 | KREPORT_EXPORT QByteArray attr(const QDomElement &el, const QString &attrName, | ||
44 | const QByteArray &defaultValue = QByteArray()); | 44 | const QByteArray &defaultValue = QByteArray()); | ||
45 | 45 | | |||
46 | KREPORT_EXPORT bool attr(const QDomElement &el, const char *attrName, bool defaultValue = false); | 46 | KREPORT_EXPORT bool attr(const QDomElement &el, const QString &attrName, bool defaultValue = false); | ||
47 | 47 | | |||
48 | KREPORT_EXPORT int attr(const QDomElement &el, const char *attrName, int defaultValue = 0); | 48 | KREPORT_EXPORT int attr(const QDomElement &el, const QString &attrName, int defaultValue = 0); | ||
49 | 49 | | |||
50 | KREPORT_EXPORT qreal attr(const QDomElement &el, const char *attrName, qreal defaultValue = 0.0); | 50 | KREPORT_EXPORT qreal attr(const QDomElement &el, const QString &attrName, qreal defaultValue = 0.0); | ||
51 | 51 | | |||
52 | KREPORT_EXPORT QColor attr(const QDomElement &el, const char *attrName, const QColor &defaultValue = QColor()); | 52 | KREPORT_EXPORT QColor attr(const QDomElement &el, const QString &attrName, const QColor &defaultValue = QColor()); | ||
53 | 53 | | |||
54 | //! @return percent value converted to qreal, e.g. 1.0 for "100%", 0.505 for "50.5%". | 54 | //! @return percent value converted to qreal, e.g. 1.0 for "100%", 0.505 for "50.5%". | ||
55 | //! @a defaultValue is returned if there is not "%" suffix or no proper number. | 55 | //! @a defaultValue is returned if there is not "%" suffix or no proper number. | ||
56 | KREPORT_EXPORT qreal attrPercent(const QDomElement& el, const char* attrName, qreal defaultValue = 0.0); | 56 | KREPORT_EXPORT qreal attrPercent(const QDomElement& el, const QString &attrName, qreal defaultValue = 0.0); | ||
57 | 57 | | |||
58 | //! @return pen style from @a str or @a defaultValue | 58 | //! @return pen style from @a str or @a defaultValue | ||
59 | //! Values from ODF 1.2 19.493 style:line-style are also recognized. | 59 | //! Values from ODF 1.2 19.493 style:line-style are also recognized. | ||
60 | KREPORT_EXPORT Qt::PenStyle penStyle(const QString &str, Qt::PenStyle defaultValue); | 60 | KREPORT_EXPORT Qt::PenStyle penStyle(const QString &str, Qt::PenStyle defaultValue); | ||
61 | 61 | | |||
62 | //! @return vertical alignment flag from @a str or @a defaultValue | 62 | //! @return vertical alignment flag from @a str or @a defaultValue | ||
63 | KREPORT_EXPORT Qt::Alignment verticalAlignment(const QString &str, Qt::Alignment defaultValue); | 63 | KREPORT_EXPORT Qt::Alignment verticalAlignment(const QString &str, Qt::Alignment defaultValue); | ||
64 | 64 | | |||
65 | //! @return horizontal alignment flag from @a str or @a defaultValue | 65 | //! @return horizontal alignment flag from @a str or @a defaultValue | ||
66 | KREPORT_EXPORT Qt::Alignment horizontalAlignment(const QString &str, Qt::Alignment defaultValue); | 66 | KREPORT_EXPORT Qt::Alignment horizontalAlignment(const QString &str, Qt::Alignment defaultValue); | ||
67 | 67 | | |||
68 | //! @return vertical alignment flag name from @a alignment | 68 | //! @return vertical alignment flag name from @a alignment | ||
69 | KREPORT_EXPORT QString verticalToString(Qt::Alignment alignment); | 69 | KREPORT_EXPORT QString verticalToString(Qt::Alignment alignment); | ||
70 | 70 | | |||
71 | //! @return horizontal alignment flag from @a alignment | 71 | //! @return horizontal alignment flag from @a alignment | ||
72 | KREPORT_EXPORT QString horizontalToString(Qt::Alignment alignment); | 72 | KREPORT_EXPORT QString horizontalToString(Qt::Alignment alignment); | ||
73 | 73 | | |||
74 | //! @return name value read from report:name attribute of @a el. | ||||
75 | //! If the attribute is missing, @a defaultValue is returned. | ||||
76 | KREPORT_EXPORT QString readNameAttribute( | ||||
77 | const QDomElement &el, const QString &defaultValue = QString()); | ||||
78 | | ||||
79 | //! @return size value read from svg:width and svg:height attributes of @a el. | ||||
80 | //! If any of the attributes are missing, @a defaultValue is returned. | ||||
81 | //! @a defaultValue should be specified in Points. | ||||
82 | KREPORT_EXPORT QSizeF readSizeAttributes( | ||||
83 | const QDomElement &el, const QSizeF &defaultValue = QSizeF()); | ||||
84 | | ||||
74 | //! @return rectangle value read from svg:x, svg:y, svg:width, svg:height attributes of @a el. | 85 | //! @return rectangle value read from svg:x, svg:y, svg:width, svg:height attributes of @a el. | ||
75 | //! If any of the arguments are missing, @a defaultValue is returned. | 86 | //! If any of the attributes are missing, @a defaultValue is returned. | ||
76 | KREPORT_EXPORT QRectF readRectAttributes(const QDomElement &el, const QRectF &defaultValue = QRectF()); | 87 | //! @a defaultValue should be specified in Points. | ||
88 | KREPORT_EXPORT QRectF readRectAttributes( | ||||
89 | const QDomElement &el, const QRectF &defaultValue = QRectF()); | ||||
90 | | ||||
91 | //! @return Z index value read from report:z-index attribute of @a el. | ||||
92 | //! If the attribute is missing @a defaultValue is returned. | ||||
93 | //! @a defaultValue should be specified in Points. | ||||
94 | KREPORT_EXPORT qreal readZAttribute(const QDomElement &el, qreal defaultValue = 0.0); | ||||
95 | | ||||
96 | //! @return name of section type read from report:section-type attribute of @a el. | ||||
97 | //! If the attribute is missing, @a defaultValue is returned. | ||||
98 | KREPORT_EXPORT QString readSectionTypeNameAttribute( | ||||
staniek: Do we need this specialized function in the public API? | |||||
99 | const QDomElement &el, const QString &defaultValue = QString()); | ||||
77 | 100 | | |||
78 | //! @return percent value for element @a name. If the element is missing, returns @a defaultPercentValue. | 101 | //! @return percent value for element @a name. If the element is missing, returns @a defaultPercentValue. | ||
79 | //! If @a ok is not 0, *ok is set to the result. | 102 | //! If @a ok is not 0, *ok is set to the result. | ||
80 | KREPORT_EXPORT int readPercent(const QDomElement & el, const char* name, int defaultPercentValue, bool *ok); | 103 | KREPORT_EXPORT int readPercent(const QDomElement &el, const QString &attrName, | ||
104 | int defaultPercentValue, bool *ok); | ||||
81 | 105 | | |||
82 | //! Reads all font attributes for element @a el into @a font. | 106 | //! Reads all font attributes for element @a el into @a font. | ||
83 | //! @todo add unit tests | 107 | //! @todo add unit tests | ||
84 | KREPORT_EXPORT void readFontAttributes(const QDomElement& el, QFont* font); | 108 | KREPORT_EXPORT void readFontAttributes(const QDomElement& el, QFont* font); | ||
85 | 109 | | |||
86 | //! Writes all attributes of font @a font into element @a el. | 110 | //! Writes all attributes of font @a font into element @a el. | ||
87 | //! @todo add unit tests | 111 | //! @todo add unit tests | ||
88 | KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); | 112 | KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); | ||
Show All 38 Lines |
Do we need this specialized function in the public API?