LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: eqychan on February 15, 2016, 10:59:56 PM

Title: QRCode Barcode item cannot handle CJK character
Post by: eqychan on February 15, 2016, 10:59:56 PM
LimeReport is perfect! thanks.
QRCode Barcode item cannot handle CJK character, and there is no barcode item in LimeReport::ReportDesignWindow(). would you plan to add it in the next version?
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: Arin Alex on February 16, 2016, 12:00:04 PM
LimeReport use zint library to support barcodes. You have to turn on zint support in the limereport.pro. Remove comment before CONFIG +=zint and configure zint library.
What about CJK character. According to the documentation zint can use UTF-8 but maybe something wrong between zint and barcode item.
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: eqychan on February 16, 2016, 04:49:03 PM
LimeReport use zint library to support barcodes. You have to turn on zint support in the limereport.pro. Remove comment before CONFIG +=zint and configure zint library.
What about CJK character. According to the documentation zint can use UTF-8 but maybe something wrong between zint and barcode item.
thanks for your reply! following your instructions, I resolved the barcode problem. :)
I changed source code in your lrbarcodeitem.cpp to resolve the CJK problem by adding a function to find whether the input string contains CJK character, if true, change barcode input mode to 0, otherwise do nothing. now it works fine!:D
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: Arin Alex on February 16, 2016, 04:56:20 PM
Could you send you changes to us?
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: eqychan on February 16, 2016, 05:03:05 PM
// My Code start ----------------------------------------------------
bool hasCJK(QString qs)
{
    int qslen = qs.length();
    if (qslen == 0)
        return false;
    else if (qslen == qs.toLocal8Bit().length())
        return false;
    return true;
}
// My code end ------------------------------------------------------


void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    ppainter->save();
    Zint::QZint bc;
// Original code Start -----------------------------------------------------------------------
//    if (itemMode() & DesignMode) bc.setText(m_designTestValue);
//    else bc.setText(m_content);
// Original code end -------------------------------------------------------------------------
// My Code Start -----------------------------------------------------------------------------
    QString qs;
    if (itemMode() & DesignMode) qs = m_designTestValue;
    else qs = m_content;
    if (hasCJK(qs))
        bc.setInputMode(0);
    bc.setText(qs);
// My code end --------------------------------------------------------------------------------
    bc.setSymbol(m_barcodeType);
    bc.setWhitespace(m_whitespace);
    bc.setFgColor(m_foregroundColor);
...
...
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: Arin Alex on February 16, 2016, 05:04:36 PM
Thanks!
Title: Re: QRCode Barcode item cannot handle CJK character
Post by: eqychan on February 16, 2016, 05:05:49 PM
I am not professional in coding... sorry ;)