Commit f4f92ccf authored by Adam Pigg's avatar Adam Pigg

Add 'Value' property to report items which can contain static data if not bound to a field

Added a new property to the following report items:
check
field
text
barcode
Renamed image property 'Static Image' to Value but left saving/loading the same for compatibility.

Added a method to KoReportDesignerItemRectBase to store a string used for rendering data in the report designer.
Report designer shows the static data if used

Includes a bug fix in KRSize which meant recursion was possible
Includes a small fix to Text item which caused an infinite loop.

RVIEW: 120935
parent 2948fabd
......@@ -31,7 +31,7 @@ KRSize::~KRSize()
{
}
void KRSize::setSceneSize(const QSizeF& s, bool update)
void KRSize::setSceneSize(const QSizeF& s, UpdatePropertyFlag update)
{
qreal w, h;
......@@ -40,11 +40,11 @@ void KRSize::setSceneSize(const QSizeF& s, bool update)
m_pointSize.setWidth(w);
m_pointSize.setHeight(h);
if (update)
if (update == UpdateProperty)
m_property->setValue(toUnit());
}
void KRSize::setUnitSize(const QSizeF& s, bool update)
void KRSize::setUnitSize(const QSizeF& s, UpdatePropertyFlag update)
{
qreal w, h;
w = m_unit.fromUserValue(s.width());
......@@ -52,16 +52,16 @@ void KRSize::setUnitSize(const QSizeF& s, bool update)
m_pointSize.setWidth(w);
m_pointSize.setHeight(h);
if (update)
if (update == UpdateProperty)
m_property->setValue(toUnit());
}
void KRSize::setPointSize(const QSizeF& s, bool update)
void KRSize::setPointSize(const QSizeF& s, UpdatePropertyFlag update)
{
m_pointSize.setWidth(s.width());
m_pointSize.setHeight(s.height());
if (update)
if (update == UpdateProperty)
m_property->setValue(toUnit());
}
......
......@@ -28,15 +28,19 @@
class KOREPORT_EXPORT KRSize
{
public:
enum UpdatePropertyFlag {
UpdateProperty,
DontUpdateProperty
};
explicit KRSize(const KoUnit& unit = KoUnit(KoUnit::Centimeter));
~KRSize();
QSizeF toUnit() const;
QSizeF toPoint() const;
QSizeF toScene() const;
void setSceneSize(const QSizeF&, bool update= true);
void setUnitSize(const QSizeF&, bool update = true);
void setPointSize(const QSizeF&, bool update = true);
void setSceneSize(const QSizeF&, UpdatePropertyFlag update = UpdateProperty);
void setUnitSize(const QSizeF&, UpdatePropertyFlag update = UpdateProperty);
void setPointSize(const QSizeF&, UpdatePropertyFlag update = UpdateProperty);
void setUnit(KoUnit);
KoProperty::Property* property() const {
......
......@@ -152,6 +152,7 @@ void KoReportDesignerItemCheck::buildXML(QDomDocument & doc, QDomElement & paren
addPropertyAsAttribute(&entity, m_controlSource);
entity.setAttribute("fo:foreground-color", m_foregroundColor->value().toString());
addPropertyAsAttribute(&entity, m_checkStyle);
addPropertyAsAttribute(&entity, m_staticValue);
// bounding rect
buildXMLRect(doc, entity, &m_pos, &m_size);
......
......@@ -30,7 +30,7 @@ KoReportItemCheck::KoReportItemCheck()
createProperties();
}
KoReportItemCheck::KoReportItemCheck(QDomNode &element) : m_value(false)
KoReportItemCheck::KoReportItemCheck(QDomNode &element)
{
createProperties();
QDomNodeList nl = element.childNodes();
......@@ -40,8 +40,9 @@ KoReportItemCheck::KoReportItemCheck(QDomNode &element) : m_value(false)
m_name->setValue(element.toElement().attribute("report:name"));
m_controlSource->setValue(element.toElement().attribute("report:item-data-source"));
Z = element.toElement().attribute("report:z-index").toDouble();
m_foregroundColor->setValue(element.toElement().attribute("fo:foreground-color"));
m_foregroundColor->setValue(QColor(element.toElement().attribute("fo:foreground-color")));
m_checkStyle->setValue(element.toElement().attribute("report:check-style"));
m_staticValue->setValue(QVariant(element.toElement().attribute("report:value")).toBool());
parseReportRect(element.toElement(), &m_pos, &m_size);
......@@ -86,9 +87,11 @@ void KoReportItemCheck::createProperties()
m_lineWeight = new KoProperty::Property("line-weight", 1, i18n("Line Weight"));
m_lineColor = new KoProperty::Property("line-color", Qt::black, i18n("Line Color"));
m_lineStyle = new KoProperty::Property("line-style", Qt::SolidLine, i18n("Line Style"), i18n("Line Style"), KoProperty::LineStyle);
m_staticValue = new KoProperty::Property("value", QVariant(false), i18n("Value"), i18n("Value used if not bound to a field"));
addDefaultProperties();
m_set->addProperty(m_controlSource);
m_set->addProperty(m_staticValue);
m_set->addProperty(m_checkStyle);
m_set->addProperty(m_foregroundColor);
m_set->addProperty(m_lineWeight);
......@@ -143,7 +146,7 @@ int KoReportItemCheck::renderSimpleData(OROPage *page, OROSection *section, cons
str = str.toLower();
//kDebug() << "Check Value:" << str;
if (str == "t" || str == "true" || str == "1")
if (str == "t" || str == "y" || str == "true" || str == "1")
v = true;
} else {
......@@ -171,10 +174,10 @@ int KoReportItemCheck::renderSimpleData(OROPage *page, OROSection *section, cons
bool KoReportItemCheck::value()
{
return m_value;
return m_staticValue->value().toBool();
}
void KoReportItemCheck::setValue(bool v)
{
m_value = v;
m_staticValue->setValue(v);
}
......@@ -51,6 +51,7 @@ protected:
KoProperty::Property* m_lineColor;
KoProperty::Property* m_lineWeight;
KoProperty::Property* m_lineStyle;
KoProperty::Property* m_staticValue;
bool value();
void setValue(bool);
......@@ -58,7 +59,6 @@ protected:
private:
virtual void createProperties();
bool m_value;
friend class Scripting::Check;
};
......
......@@ -44,6 +44,8 @@ void KoReportDesignerItemField::init(QGraphicsScene * scene, KoReportDesigner *
this, SLOT(slotPropertyChanged(KoProperty::Set&,KoProperty::Property&)));
setZValue(Z);
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), "field");
}
// methods (constructors)
......@@ -79,7 +81,7 @@ KoReportDesignerItemField::~KoReportDesignerItemField()
QRect KoReportDesignerItemField::getTextRect() const
{
return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), dataSourceAndObjectTypeName(itemDataSource(), "field"));
return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), m_renderText);
}
......@@ -92,6 +94,7 @@ void KoReportDesignerItemField::paint(QPainter* painter, const QStyleOptionGraph
// store any values we plan on changing so we can restore them
QFont f = painter->font();
QPen p = painter->pen();
painter->setFont(font());
painter->setBackgroundMode(Qt::TransparentMode);
......@@ -102,7 +105,7 @@ void KoReportDesignerItemField::paint(QPainter* painter, const QStyleOptionGraph
painter->setPen(m_foregroundColor->value().value<QColor>());
painter->fillRect(QGraphicsRectItem::rect(), bg);
painter->drawText(rect(), textFlags(), dataSourceAndObjectTypeName(itemDataSource(), "field"));
painter->drawText(rect(), textFlags(), m_renderText);
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
......@@ -132,6 +135,8 @@ void KoReportDesignerItemField::buildXML(QDomDocument & doc, QDomElement & paren
addPropertyAsAttribute(&entity, m_horizontalAlignment);
addPropertyAsAttribute(&entity, m_wordWrap);
addPropertyAsAttribute(&entity, m_canGrow);
addPropertyAsAttribute(&entity, m_itemValue);
entity.setAttribute("report:z-index", zValue());
// bounding rect
......@@ -170,7 +175,9 @@ void KoReportDesignerItemField::slotPropertyChanged(KoProperty::Set &s, KoProper
} else {
m_oldName = p.value().toString();
}
}
}
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), "field");
KoReportDesignerItemRectBase::propertyChanged(s, p);
if (m_reportDesigner)m_reportDesigner->setModified(true);
......@@ -181,3 +188,5 @@ void KoReportDesignerItemField::mousePressEvent(QGraphicsSceneMouseEvent * event
m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames());
KoReportDesignerItemRectBase::mousePressEvent(event);
}
......@@ -39,6 +39,7 @@ KoReportItemField::KoReportItemField(QDomNode & element)
m_name->setValue(element.toElement().attribute("report:name"));
m_controlSource->setValue(element.toElement().attribute("report:item-data-source"));
m_itemValue->setValue(element.toElement().attribute("report:value"));
Z = element.toElement().attribute("report:z-index").toDouble();
m_horizontalAlignment->setValue(element.toElement().attribute("report:horizontal-align"));
m_verticalAlignment->setValue(element.toElement().attribute("report:vertical-align"));
......@@ -86,8 +87,9 @@ void KoReportItemField::createProperties()
QStringList keys, strings;
m_controlSource = new KoProperty::Property("item-data-source", QStringList(), QStringList(), QString(), i18n("Data Source"));
m_controlSource->setOption("extraValueAllowed", "true");
m_itemValue = new KoProperty::Property("value", QString(), i18n("Value"), i18n("Value used if not bound to a field"));
keys << "left" << "center" << "right";
strings << i18n("Left") << i18n("Center") << i18n("Right");
......@@ -127,6 +129,7 @@ void KoReportItemField::createProperties()
addDefaultProperties();
m_set->addProperty(m_controlSource);
m_set->addProperty(m_itemValue);
m_set->addProperty(m_horizontalAlignment);
m_set->addProperty(m_verticalAlignment);
m_set->addProperty(m_font);
......@@ -225,18 +228,22 @@ int KoReportItemField::renderSimpleData(OROPage *page, OROSection *section, cons
QString str;
QString ids = itemDataSource();
if (ids.left(1) == "=" && script) { //Everything after = is treated as code
if (!ids.contains("PageTotal()")) {
QVariant v = script->evaluate(ids.mid(1));
str = v.toString();
} else {
if (!ids.isEmpty()) {
if (ids.left(1) == "=" && script) { //Everything after = is treated as code
if (!ids.contains("PageTotal()")) {
QVariant v = script->evaluate(ids.mid(1));
str = v.toString();
} else {
str = ids.mid(1);
tb->setRequiresPostProcessing();
}
} else if (ids.left(1) == "$") { //Everything past $ is treated as a string
str = ids.mid(1);
tb->setRequiresPostProcessing();
} else {
str = data.toString();
}
} else if (ids.left(1) == "$") { //Everything past $ is treated as a string
str = ids.mid(1);
} else {
str = data.toString();
str = m_itemValue->value().toString();
}
tb->setText(str);
......
......@@ -63,6 +63,7 @@ protected:
KoProperty::Property* m_lineStyle;
KoProperty::Property* m_wordWrap;
KoProperty::Property* m_canGrow;
KoProperty::Property* m_itemValue;
//bool builtinFormat;
//QString format;
......
......@@ -49,7 +49,7 @@ void KoReportDesignerItemImage::init(QGraphicsScene *scene, KoReportDesigner *d)
connect(m_set, SIGNAL(propertyChanged(KoProperty::Set&,KoProperty::Property&)),
this, SLOT(slotPropertyChanged(KoProperty::Set&,KoProperty::Property&)));
m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames());
setZValue(Z);
}
......
......@@ -123,7 +123,7 @@ void KoReportItemImage::createProperties()
strings << i18n("Clip") << i18n("Stretch");
m_resizeMode = new KoProperty::Property("resize-mode", keys, strings, "clip", i18n("Resize Mode"));
m_staticImage = new KoProperty::Property("static-image", QPixmap(), i18nc("Static Image", "Static"));
m_staticImage = new KoProperty::Property("static-image", QPixmap(), i18n("Value"), i18n("Value used if not bound to a field"));
addDefaultProperties();
m_set->addProperty(m_controlSource);
......
......@@ -49,6 +49,8 @@ void KoReportDesignerItemText::init(QGraphicsScene *scene, KoReportDesigner *d)
m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames());
setZValue(Z);
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), "textarea");
}
KoReportDesignerItemText::KoReportDesignerItemText(KoReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos)
......@@ -84,7 +86,7 @@ KoReportDesignerItemText::~KoReportDesignerItemText
QRect KoReportDesignerItemText::getTextRect() const
{
return QFontMetrics(font()).boundingRect(int (x()), int (y()), 0, 0, textFlags(), dataSourceAndObjectTypeName(itemDataSource(), "textarea"));
return QFontMetrics(font()).boundingRect(int (x()), int (y()), 0, 0, textFlags(), m_renderText);
}
void KoReportDesignerItemText::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
......@@ -105,7 +107,7 @@ void KoReportDesignerItemText::paint(QPainter* painter, const QStyleOptionGraphi
painter->setPen(m_foregroundColor->value().value<QColor>());
painter->fillRect(rect(), bg);
painter->drawText(rect(), textFlags(), dataSourceAndObjectTypeName(itemDataSource(), "textarea"));
painter->drawText(rect(), textFlags(), m_renderText);
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
painter->setPen(QPen(Qt::lightGray));
......@@ -135,6 +137,7 @@ void KoReportDesignerItemText::buildXML(QDomDocument & doc, QDomElement & parent
addPropertyAsAttribute(&entity, m_horizontalAlignment);
entity.setAttribute("report:bottom-padding", m_bottomPadding);
entity.setAttribute("report:z-index", zValue());
addPropertyAsAttribute(&entity, m_itemValue);
// bounding rect
buildXMLRect(doc, entity, &m_pos, &m_size);
......@@ -162,7 +165,7 @@ void KoReportDesignerItemText::slotPropertyChanged(KoProperty::Set &s, KoPropert
if (p.name() == "Position") {
m_pos.setUnitPos(p.value().toPointF(), KRPos::DontUpdateProperty);
} else if (p.name() == "Size") {
m_size.setUnitSize(p.value().toSizeF(), KRPos::DontUpdateProperty);
m_size.setUnitSize(p.value().toSizeF(), KRSize::DontUpdateProperty);
} else if (p.name() == "Name") {
//For some reason p.oldValue returns an empty string
if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) {
......@@ -177,4 +180,6 @@ void KoReportDesignerItemText::slotPropertyChanged(KoProperty::Set &s, KoPropert
m_reportDesigner->setModified(true);
if (scene())
scene()->update();
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), "textarea");
}
......@@ -48,7 +48,7 @@ protected:
private:
QRect getTextRect() const;
void init(QGraphicsScene*, KoReportDesigner*);
private slots:
void slotPropertyChanged(KoProperty::Set &, KoProperty::Property &);
};
......
......@@ -40,6 +40,7 @@ KoReportItemText::KoReportItemText(QDomNode & element) : m_bottomPadding(0.0)
createProperties();
m_name->setValue(element.toElement().attribute("report:name"));
m_controlSource->setValue(element.toElement().attribute("report:item-data-source"));
m_itemValue->setValue(element.toElement().attribute("report:value"));
Z = element.toElement().attribute("report:z-index").toDouble();
m_horizontalAlignment->setValue(element.toElement().attribute("report:horizontal-align"));
m_verticalAlignment->setValue(element.toElement().attribute("report:vertical-align"));
......@@ -112,6 +113,8 @@ void KoReportItemText::createProperties()
//_query = new KoProperty::Property ( "Query", QStringList(), QStringList(), "Data Source", "Query" );
m_controlSource = new KoProperty::Property("item-data-source", QStringList(), QStringList(), QString(), i18n("Data Source"));
m_itemValue = new KoProperty::Property("value", QString(), i18n("Value"), i18n("Value used if not bound to a field"));
keys << "left" << "center" << "right";
strings << i18n("Left") << i18n("Center") << i18n("Right");
......@@ -138,6 +141,7 @@ void KoReportItemText::createProperties()
addDefaultProperties();
m_set->addProperty(m_controlSource);
m_set->addProperty(m_itemValue);
m_set->addProperty(m_horizontalAlignment);
m_set->addProperty(m_verticalAlignment);
m_set->addProperty(m_font);
......@@ -202,10 +206,14 @@ int KoReportItemText::renderSimpleData(OROPage *page, OROSection *section, const
QString cs = itemDataSource();
if (cs.left(1) == "$") { //Everything past $ is treated as a string
qstrValue = cs.mid(1);
if (!cs.isEmpty()) {
if (cs.left(1) == "$") { //Everything past $ is treated as a string
qstrValue = cs.mid(1);
} else {
qstrValue = data.toString();
}
} else {
qstrValue = data.toString();
qstrValue = m_itemValue->value().toString();
}
QPointF pos = m_pos.toScene();
......@@ -215,7 +223,6 @@ int KoReportItemText::renderSimpleData(OROPage *page, OROSection *section, const
QRectF trf(pos, size);
qreal intStretch = trf.top() - offset.y();
//kDebug() << qstrValue;
if (qstrValue.length()) {
QRectF rect = trf;
......@@ -243,7 +250,9 @@ int KoReportItemText::renderSimpleData(OROPage *page, OROSection *section, const
pos = idx + 1;
if (separator == '\n') {
QString line = qstrValue.left(idx);
qstrValue.remove(0, idx + 1);
pos = 0;
rect.setTop(intBaseTop + (intLineCounter * intRectHeight));
......
......@@ -57,6 +57,8 @@ protected:
KoProperty::Property* m_lineColor;
KoProperty::Property* m_lineWeight;
KoProperty::Property* m_lineStyle;
KoProperty::Property* m_itemValue;
qreal m_bottomPadding;
......
......@@ -79,6 +79,20 @@ protected:
KoReportDesignerItemBase(KoReportDesigner*);
KoReportDesigner* m_reportDesigner;
QString dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName) const;
/**
* @brief Updates the text that is shown for the item in the report designer
* If itemDataSource is set then it is preferred over itemStaticValue
* itemType is appended to the end of the text
*
* @param itemDataSource source field property
* @param itemStaticValue value property
* @param itemType type of item
* @return void
*/
void updateRenderText(const QString &itemDataSource, const QString &itemStaticValue, const QString &itemType);
QString m_renderText;
private:
static bool m_readDefaultFont;
static QFont m_defaultFont;
......
......@@ -313,7 +313,7 @@ void KoReportDesignerItemRectBase::propertyChanged(const KoProperty::Set &s, con
if (p.name() == "Position") {
m_ppos->setUnitPos(p.value().toPointF(), KRPos::DontUpdateProperty);
} else if (p.name() == "Size") {
m_psize->setUnitSize(p.value().toSizeF(), KRPos::DontUpdateProperty);
m_psize->setUnitSize(p.value().toSizeF(), KRSize::DontUpdateProperty);
}
setSceneRect(m_ppos->toScene(), m_psize->toScene(), DontUpdateProperty);
......@@ -369,3 +369,20 @@ void KoReportDesignerItemRectBase::enterInlineEditingMode()
void KoReportDesignerItemRectBase::exitInlineEditingMode()
{
}
void KoReportDesignerItemBase::updateRenderText(const QString &itemDataSource, const QString &itemStaticValue, const QString &itemType)
{
if (itemDataSource.isEmpty()) {
if (itemType.isEmpty()) {
m_renderText = itemStaticValue;
} else {
m_renderText = dataSourceAndObjectTypeName(itemStaticValue, itemType);
}
} else {
if (itemType.isEmpty()) {
m_renderText = itemDataSource;
} else {
m_renderText = dataSourceAndObjectTypeName(itemDataSource, itemType);
}
}
}
\ No newline at end of file
......@@ -48,6 +48,9 @@ void KoReportDesignerItemBarcode::init(QGraphicsScene *scene, KoReportDesigner *
KoReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d);
setMaxLength(5);
setZValue(Z);
updateRenderText(m_itemValue->value().toString().isEmpty() ? m_format->value().toString() : QString(), m_itemValue->value().toString(), QString());
}
// methods (constructors)
KoReportDesignerItemBarcode::KoReportDesignerItemBarcode(KoReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos)
......@@ -96,7 +99,6 @@ void KoReportDesignerItemBarcode::paint(QPainter* painter, const QStyleOptionGra
painter->setBackground(Qt::white);
//Draw a border so user knows the object edge
painter->setPen(QPen(QColor(224, 224, 224)));
painter->drawRect(rect());
......@@ -104,21 +106,21 @@ void KoReportDesignerItemBarcode::paint(QPainter* painter, const QStyleOptionGra
drawHandles(painter);
if (m_format->value().toString() == "i2of5")
renderI2of5(rect().toRect(), "i2of5", alignment(), painter);
renderI2of5(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "3of9")
render3of9(rect().toRect(), "3of9", alignment(), painter);
render3of9(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "3of9+")
renderExtended3of9(rect().toRect(), "3of9+", alignment(), painter);
renderExtended3of9(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "128")
renderCode128(rect().toRect(), "128", alignment(), painter);
renderCode128(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "upc-a")
renderCodeUPCA(rect().toRect(), "123456789012", alignment(), painter);
renderCodeUPCA(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "upc-e")
renderCodeUPCE(rect().toRect(), "12345678", alignment(), painter);
renderCodeUPCE(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "ean13")
renderCodeEAN13(rect().toRect(), "123456789012", alignment(), painter);
renderCodeEAN13(rect().toRect(), m_renderText, alignment(), painter);
else if (m_format->value().toString() == "ean8")
renderCodeEAN8(rect().toRect(), "1234567", alignment(), painter);
renderCodeEAN8(rect().toRect(), m_renderText, alignment(), painter);
painter->setPen(Qt::black);
painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), "barcode"));
......@@ -139,6 +141,7 @@ void KoReportDesignerItemBarcode::buildXML(QDomDocument & doc, QDomElement & par
addPropertyAsAttribute(&entity, m_format);
addPropertyAsAttribute(&entity, m_maxLength);
entity.setAttribute("report:z-index", zValue());
addPropertyAsAttribute(&entity, m_itemValue);
// bounding rect
buildXMLRect(doc, entity, &m_pos, &m_size);
......@@ -156,6 +159,8 @@ void KoReportDesignerItemBarcode::slotPropertyChanged(KoProperty::Set &s, KoProp
m_oldName = p.value().toString();
}
}
updateRenderText(m_itemValue->value().toString().isEmpty() ? m_format->value().toString() : QString(), m_itemValue->value().toString(), QString());
KoReportDesignerItemRectBase::propertyChanged(s, p);
if (m_reportDesigner) m_reportDesigner->setModified(true);
......
......@@ -38,6 +38,7 @@ KoReportItemBarcode::KoReportItemBarcode(QDomNode & element)
m_name->setValue(element.toElement().attribute("report:name"));
m_controlSource->setValue(element.toElement().attribute("report:item-data-source"));
m_itemValue->setValue(element.toElement().attribute("report:value"));
Z = element.toElement().attribute("report:z-index").toDouble();
m_horizontalAlignment->setValue(element.toElement().attribute("report:horizontal-align"));
m_maxLength->setValue(element.toElement().attribute("report:barcode-max-length"));
......@@ -117,6 +118,8 @@ void KoReportItemBarcode::createProperties()
m_controlSource = new KoProperty::Property("item-data-source", QStringList(), QStringList(), QString(), i18n("Data Source"));
m_itemValue = new KoProperty::Property("value", QString(), i18n("Value"), i18n("Value used if not bound to a field"));
keys << "left" << "center" << "right";
strings << i18n("Left") << i18n("Center") << i18n("Right");
m_horizontalAlignment = new KoProperty::Property("horizontal-align", keys, strings, "left", i18n("Horizontal Alignment"));
......@@ -131,6 +134,7 @@ void KoReportItemBarcode::createProperties()
addDefaultProperties();
m_set->addProperty(m_controlSource);
m_set->addProperty(m_itemValue);
m_set->addProperty(m_format);
m_set->addProperty(m_horizontalAlignment);
m_set->addProperty(m_maxLength);
......@@ -198,8 +202,14 @@ int KoReportItemBarcode::renderSimpleData(OROPage *page, OROSection *section, co
QRectF rect = QRectF(pos, size);
QString val = data.toString();
QString val;
if (m_controlSource->value().toString().isEmpty()) {
val = m_itemValue->value().toString();
} else {
val = data.toString();
}
if (page) {
QString fmt = m_format->value().toString();
int align = alignment();
......
......@@ -49,6 +49,8 @@ protected:
KoProperty::Property * m_horizontalAlignment;
KoProperty::Property * m_format;
KoProperty::Property * m_maxLength;
KoProperty::Property* m_itemValue;
int alignment();
void setAli