Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportUtils.h
Show All 33 Lines | |||||
34 | class KProperty; | 34 | class KProperty; | ||
35 | class KReportPosition; | 35 | class KReportPosition; | ||
36 | class KReportSize; | 36 | class KReportSize; | ||
37 | class KReportTextStyleData; | 37 | class KReportTextStyleData; | ||
38 | class KReportLineStyle; | 38 | class KReportLineStyle; | ||
39 | 39 | | |||
40 | namespace KReportUtils | 40 | namespace KReportUtils | ||
41 | { | 41 | { | ||
42 | KREPORT_EXPORT QString attr(const QDomElement &el, const char *attrName, | 42 | KREPORT_EXPORT QString attr(const QDomElement &el, const QString &attrName, | ||
43 | const QString &defaultValue = QString()); | 43 | const QString &defaultValue = QString()); | ||
44 | 44 | | |||
45 | KREPORT_EXPORT QByteArray attr(const QDomElement &el, const char *attrName, | 45 | KREPORT_EXPORT QByteArray attr(const QDomElement &el, const QString &attrName, | ||
46 | const QByteArray &defaultValue = QByteArray()); | 46 | const QByteArray &defaultValue = QByteArray()); | ||
47 | 47 | | |||
48 | KREPORT_EXPORT bool attr(const QDomElement &el, const char *attrName, bool defaultValue = false); | 48 | KREPORT_EXPORT bool attr(const QDomElement &el, const QString &attrName, bool defaultValue = false); | ||
49 | 49 | | |||
50 | KREPORT_EXPORT int attr(const QDomElement &el, const char *attrName, int defaultValue = 0); | 50 | KREPORT_EXPORT int attr(const QDomElement &el, const QString &attrName, int defaultValue = 0); | ||
51 | 51 | | |||
52 | KREPORT_EXPORT qreal attr(const QDomElement &el, const char *attrName, qreal defaultValue = 0.0); | 52 | KREPORT_EXPORT qreal attr(const QDomElement &el, const QString &attrName, qreal defaultValue = 0.0); | ||
53 | 53 | | |||
54 | KREPORT_EXPORT QColor attr(const QDomElement &el, const char *attrName, const QColor &defaultValue = QColor()); | 54 | KREPORT_EXPORT QColor attr(const QDomElement &el, const QString &attrName, const QColor &defaultValue = QColor()); | ||
55 | 55 | | |||
56 | //! @return percent value converted to qreal, e.g. 1.0 for "100%", 0.505 for "50.5%". | 56 | //! @return percent value converted to qreal, e.g. 1.0 for "100%", 0.505 for "50.5%". | ||
57 | //! @a defaultValue is returned if there is not "%" suffix or no proper number. | 57 | //! @a defaultValue is returned if there is not "%" suffix or no proper number. | ||
58 | KREPORT_EXPORT qreal attrPercent(const QDomElement& el, const char* attrName, qreal defaultValue = 0.0); | 58 | KREPORT_EXPORT qreal attrPercent(const QDomElement& el, const QString &attrName, qreal defaultValue = 0.0); | ||
59 | 59 | | |||
60 | //! @return pen style from @a str or @a defaultValue | 60 | //! @return pen style from @a str or @a defaultValue | ||
61 | //! Values from ODF 1.2 19.493 style:line-style are also recognized. | 61 | //! Values from ODF 1.2 19.493 style:line-style are also recognized. | ||
62 | KREPORT_EXPORT Qt::PenStyle penStyle(const QString &str, Qt::PenStyle defaultValue); | 62 | KREPORT_EXPORT Qt::PenStyle penStyle(const QString &str, Qt::PenStyle defaultValue); | ||
63 | 63 | | |||
64 | //! @return vertical alignment flag from @a str or @a defaultValue | 64 | //! @return vertical alignment flag from @a str or @a defaultValue | ||
65 | KREPORT_EXPORT Qt::Alignment verticalAlignment(const QString &str, Qt::Alignment defaultValue); | 65 | KREPORT_EXPORT Qt::Alignment verticalAlignment(const QString &str, Qt::Alignment defaultValue); | ||
66 | 66 | | |||
67 | //! @return horizontal alignment flag from @a str or @a defaultValue | 67 | //! @return horizontal alignment flag from @a str or @a defaultValue | ||
68 | KREPORT_EXPORT Qt::Alignment horizontalAlignment(const QString &str, Qt::Alignment defaultValue); | 68 | KREPORT_EXPORT Qt::Alignment horizontalAlignment(const QString &str, Qt::Alignment defaultValue); | ||
69 | 69 | | |||
70 | //! @return vertical alignment flag name from @a alignment | 70 | //! @return vertical alignment flag name from @a alignment | ||
71 | KREPORT_EXPORT QString verticalToString(Qt::Alignment alignment); | 71 | KREPORT_EXPORT QString verticalToString(Qt::Alignment alignment); | ||
72 | 72 | | |||
73 | //! @return horizontal alignment flag from @a alignment | 73 | //! @return horizontal alignment flag from @a alignment | ||
74 | KREPORT_EXPORT QString horizontalToString(Qt::Alignment alignment); | 74 | KREPORT_EXPORT QString horizontalToString(Qt::Alignment alignment); | ||
75 | 75 | | |||
76 | //! @return name value read from report:name attribute of @a el. | ||||
77 | //! If the attribute is missing, @a defaultValue is returned. | ||||
78 | KREPORT_EXPORT QString readNameAttribute( | ||||
79 | const QDomElement &el, const QString &defaultValue = QString()); | ||||
80 | | ||||
81 | //! @return size value read from svg:width and svg:height attributes of @a el. | ||||
82 | //! If any of the attributes are missing, @a defaultValue is returned. | ||||
83 | //! @a defaultValue should be specified in Points. | ||||
84 | KREPORT_EXPORT QSizeF readSizeAttributes( | ||||
85 | const QDomElement &el, const QSizeF &defaultValue = QSizeF()); | ||||
86 | | ||||
76 | //! @return rectangle value read from svg:x, svg:y, svg:width, svg:height attributes of @a el. | 87 | //! @return rectangle value read from svg:x, svg:y, svg:width, svg:height attributes of @a el. | ||
77 | //! If any of the arguments are missing, @a defaultValue is returned. | 88 | //! If any of the attributes are missing, @a defaultValue is returned. | ||
78 | KREPORT_EXPORT QRectF readRectAttributes(const QDomElement &el, const QRectF &defaultValue = QRectF()); | 89 | //! @a defaultValue should be specified in Points. | ||
90 | KREPORT_EXPORT QRectF readRectAttributes( | ||||
91 | const QDomElement &el, const QRectF &defaultValue = QRectF()); | ||||
92 | | ||||
93 | //! @return Z index value read from report:z-index attribute of @a el. | ||||
94 | //! If the attribute is missing @a defaultValue is returned. | ||||
95 | //! @a defaultValue should be specified in Points. | ||||
96 | KREPORT_EXPORT qreal readZAttribute(const QDomElement &el, qreal defaultValue = 0.0); | ||||
97 | | ||||
98 | //! @return name of section type read from report:section-type attribute of @a el. | ||||
99 | //! If the attribute is missing, @a defaultValue is returned. | ||||
100 | KREPORT_EXPORT QString readSectionTypeNameAttribute( | ||||
staniek: Do we need this specialized function in the public API? | |||||
101 | const QDomElement &el, const QString &defaultValue = QString()); | ||||
79 | 102 | | |||
80 | //! @return percent value for element @a name. If the element is missing, returns @a defaultPercentValue. | 103 | //! @return percent value for element @a name. If the element is missing, returns @a defaultPercentValue. | ||
81 | //! If @a ok is not 0, *ok is set to the result. | 104 | //! If @a ok is not 0, *ok is set to the result. | ||
82 | KREPORT_EXPORT int readPercent(const QDomElement & el, const char* name, int defaultPercentValue, bool *ok); | 105 | KREPORT_EXPORT int readPercent(const QDomElement &el, const QString &attrName, | ||
106 | int defaultPercentValue, bool *ok); | ||||
83 | 107 | | |||
84 | //! Reads all font attributes for element @a el into @a font. | 108 | //! Reads all font attributes for element @a el into @a font. | ||
85 | //! @todo add unit tests | 109 | //! @todo add unit tests | ||
86 | KREPORT_EXPORT void readFontAttributes(const QDomElement& el, QFont* font); | 110 | KREPORT_EXPORT void readFontAttributes(const QDomElement& el, QFont* font); | ||
87 | 111 | | |||
88 | //! Writes all attributes of font @a font into element @a el. | 112 | //! Writes all attributes of font @a font into element @a el. | ||
89 | //! @todo add unit tests | 113 | //! @todo add unit tests | ||
90 | KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); | 114 | KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); | ||
Show All 20 Lines | |||||
111 | KREPORT_EXPORT void setAttribute(QDomElement *e, const QSizeF &value); | 135 | KREPORT_EXPORT void setAttribute(QDomElement *e, const QSizeF &value); | ||
112 | 136 | | |||
113 | //! Reads attributes from @p elemSource into text style @p ts | 137 | //! Reads attributes from @p elemSource into text style @p ts | ||
114 | KREPORT_EXPORT bool parseReportTextStyleData(const QDomElement & elemSource, KReportTextStyleData *ts); | 138 | KREPORT_EXPORT bool parseReportTextStyleData(const QDomElement & elemSource, KReportTextStyleData *ts); | ||
115 | 139 | | |||
116 | //! Reads attributes from @p elemSource into line style @p ls | 140 | //! Reads attributes from @p elemSource into line style @p ls | ||
117 | KREPORT_EXPORT bool parseReportLineStyleData(const QDomElement & elemSource, KReportLineStyle *ls); | 141 | KREPORT_EXPORT bool parseReportLineStyleData(const QDomElement & elemSource, KReportLineStyle *ls); | ||
118 | 142 | | |||
119 | //! Reads attributes from @p elemSource into rect @p pos, @p siz | | |||
120 | KREPORT_EXPORT bool parseReportRect(const QDomElement & elemSource, KReportPosition *pos, KReportSize *size); | | |||
121 | | ||||
122 | //! @return page size ID for page key (the PPD standard mediaOption keyword, e.g. "A4") | 143 | //! @return page size ID for page key (the PPD standard mediaOption keyword, e.g. "A4") | ||
123 | //! @note It's an efficient workaround because QPageSize misses this function. | 144 | //! @note It's an efficient workaround because QPageSize misses this function. | ||
124 | KREPORT_EXPORT QPageSize::PageSizeId pageSizeId(const QString &key); | 145 | KREPORT_EXPORT QPageSize::PageSizeId pageSizeId(const QString &key); | ||
125 | 146 | | |||
126 | //! Like QPageSize::PageSizeId pageSizeId(const QString &key) but returns entire QPageSize object. | 147 | //! Like QPageSize::PageSizeId pageSizeId(const QString &key) but returns entire QPageSize object. | ||
127 | KREPORT_EXPORT QPageSize pageSize(const QString &key); | 148 | KREPORT_EXPORT QPageSize pageSize(const QString &key); | ||
128 | 149 | | |||
129 | } // KReportUtils | 150 | } // KReportUtils | ||
130 | 151 | | |||
131 | #endif | 152 | #endif |
Do we need this specialized function in the public API?