Browse Source

Merge latest version of KBarCode with the TDE sources

This relates to Bug 2095
Note that a handful of translation strings did not merge properly
tags/r14.0.0
Timothy Pearson 6 years ago
parent
commit
d265f2381c
42 changed files with 4752 additions and 6286 deletions
  1. +6
    -0
      ChangeLog
  2. +1
    -1
      configure.in
  3. +1
    -1
      configure.in.in
  4. +1
    -1
      fileplugin/Makefile.am
  5. +2
    -2
      kbarcode.spec
  6. +27
    -29
      kbarcode/Makefile.am
  7. +1
    -1
      kbarcode/barcodecombo.h
  8. +1
    -5
      kbarcode/barcodedialogs.cpp
  9. +1
    -1
      kbarcode/barkode.h
  10. +10
    -19
      kbarcode/dsmainwindow.cpp
  11. +2
    -2
      kbarcode/dsmainwindow.h
  12. +0
    -427
      kbarcode/dsrichtext.cpp
  13. +0
    -193
      kbarcode/dsrichtext.h
  14. +1
    -1
      kbarcode/dstextedit.cpp
  15. +6
    -6
      kbarcode/dstextedit.h
  16. +42
    -54
      kbarcode/labelutils.cpp
  17. +0
    -1
      kbarcode/labelutils.h
  18. +3
    -1
      kbarcode/main.cpp
  19. +1
    -4
      kbarcode/multilineeditdlg.cpp
  20. +0
    -620
      kbarcode/mybarcode.cpp
  21. +0
    -304
      kbarcode/mybarcode.h
  22. +0
    -23
      kbarcode/referencecounted.cpp
  23. +0
    -39
      kbarcode/semantic.cache
  24. +0
    -4
      kbarcode/sqltables.h
  25. +0
    -188
      kbarcode/tdeactionmap.cpp
  26. +0
    -102
      kbarcode/tdeactionmap.h
  27. +4
    -56
      kbarcode/textitem.cpp
  28. +1
    -5
      kbarcode/textitem.h
  29. +6
    -6
      kbarcode/textlineedit.cpp
  30. +3
    -47
      kbarcode/textlineitem.cpp
  31. +1
    -5
      kbarcode/textlineitem.h
  32. +9
    -9
      kbarcode/tokenprovider.cpp
  33. +445
    -419
      po/de.po
  34. +438
    -407
      po/el.po
  35. +472
    -418
      po/es.po
  36. +472
    -417
      po/fi.po
  37. +444
    -410
      po/fr.po
  38. +471
    -417
      po/hu.po
  39. +472
    -418
      po/it.po
  40. +460
    -405
      po/pl.po
  41. +430
    -402
      po/sv.po
  42. +518
    -416
      po/tr.po

+ 6
- 0
ChangeLog View File

@@ -1,6 +1,12 @@
Changelog since Version 1.3.2:
==============================

Version 2.0.7
Fixed building on systems with Automake 1.10 or later
Fixed text rendering on systems with TQt 3.3.8b
Dropped support for TQt 3.3.2 and earlier
Cleaned up Help menu

Version 2.0.6
Dag Nygren contributed a patch which fixes printing from a CSV file
Check if files passed for batchprinting from the commandline do exist


+ 1
- 1
configure.in View File

@@ -40,7 +40,7 @@ dnl Perform program name transformation
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(kbarcode, 2.0.6) dnl searches for some needed programs
AM_INIT_AUTOMAKE(kbarcode, 2.0.7) dnl searches for some needed programs

KDE_SET_PREFIX



+ 1
- 1
configure.in.in View File

@@ -1,7 +1,7 @@
#MIN_CONFIG(3.0.0)
KDE_ENABLE_HIDDEN_VISIBILITY

AM_INIT_AUTOMAKE(kbarcode, 2.0.6)
AM_INIT_AUTOMAKE(kbarcode, 2.0.7)
AC_C_BIGENDIAN
AC_CHECK_KDEMAXPATHLEN


+ 1
- 1
fileplugin/Makefile.am View File

@@ -5,7 +5,7 @@ kde_module_LTLIBRARIES = tdefile_kbarcode.la

tdefile_kbarcode_la_SOURCES = tdefile_kbarcode.cpp
tdefile_kbarcode_la_LDFLAGS = -module $(KDE_PLUGIN) $(LIB_QT) $(all_libraries)
tdefile_kbarcode_la_LIBADD = $(LIB_TDESYCOCA) $(LIB_TDECORE)
tdefile_kbarcode_la_LIBADD = $(LIB_TDESYCOCA) $(LIB_TDECORE) $(LIB_QT)

# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO


+ 2
- 2
kbarcode.spec View File

@@ -1,5 +1,5 @@
%define name kbarcode
%define version 2.0.6
%define version 2.0.7
Summary: A barcode and label printing application for KDE
Name: %{name}
Version: %{version}
@@ -30,7 +30,7 @@ fi
make -j$numprocs

%install
make install DESTDIR=$RPM_BUILD_ROOT
make install-strip DESTDIR=$RPM_BUILD_ROOT

cd $RPM_BUILD_ROOT
find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/file.list.kbarcode


+ 27
- 29
kbarcode/Makefile.am View File

@@ -13,7 +13,7 @@ METASOURCES = AUTO
KDE_ICON = AUTO

messages: rc.cpp
$(XGETTEXT) *.cpp -o $(podir)/kdedcoptest.pot
$(XGETTEXT) *.cpp -o $(podir)/kbarcode.pot

# this is the program that gets installed. it's name is used for all
# of the other Makefile.am variables
@@ -25,34 +25,32 @@ kbarcode_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE)
kbarcode_LDADD = $(LIB_TDEABC) $(LIB_TDESPELL) $(LIB_TDEPRINT) \
$(LIB_TDEUI) -lkjs -lpcre

noinst_HEADERS = barcodecombo.h barcodedialog.h barcodedialogs.h \
commands.h configdialog.h confwizard.h csvimportdlg.h databasebrowser.h \
definition.h definitiondialog.h dsmainwindow.h dsrichtext.h kbarcode.h label.h \
labeleditor.h labelutils.h mimesources.h multilineeditdlg.h \
mycanvasitem.h mycanvasview.h mydatatable.h newlabel.h previewdialog.h \
printersettings.h printlabeldlg.h rectsettingsdlg.h smalldialogs.h sqltables.h \
tokenprovider.h xmlutils.h zplutils.h measurements.h editoriface.h kbarcodeiface.h \
batchiface.h kbarcodesettings.h batchprinter.h barcodeitem.h documentitem.h \
lineitem.h rectitem.h tcanvasitem.h textitem.h imageitem.h documentitemdlg.h \
propertywidget.h tec.h barcodeprinterdlg.h textlineitem.h textlineedit.h tokendialog.h \
barkode.h gnubarcode.h barkodeengine.h pixmapbarcode.h batchwizard.h csvfile.h \
referencecounted.h dstextedit.h encodingcombo.h purepostscript.h tbarcode2.h \
tdeactionmap.h

kbarcode_SOURCES = barcodecombo.cpp barcodedialog.cpp \
barcodedialogs.cpp commands.cpp configdialog.cpp confwizard.cpp csvimportdlg.cpp \
databasebrowser.cpp definition.cpp definitiondialog.cpp dsmainwindow.cpp dsrichtext.cpp \
kbarcode.cpp label.cpp labeleditor.cpp labelutils.cpp main.cpp \
mimesources.cpp multilineeditdlg.cpp mycanvasitem.cpp mycanvasview.cpp mydatatable.cpp \
newlabel.cpp previewdialog.cpp printersettings.cpp printlabeldlg.cpp \
rectsettingsdlg.cpp smalldialogs.cpp sqltables.cpp tokenprovider.cpp xmlutils.cpp \
zplutils.cpp measurements.cpp editoriface.skel kbarcodeiface.skel batchiface.skel \
kbarcodesettings.cpp batchprinter.cpp barcodeitem.cpp documentitem.cpp lineitem.cpp \
rectitem.cpp tcanvasitem.cpp textitem.cpp imageitem.cpp documentitemdlg.cpp \
propertywidget.cpp tec.cpp barcodeprinterdlg.cpp textlineitem.cpp textlineedit.cpp \
tokendialog.cpp barkode.cpp gnubarcode.cpp barkodeengine.cpp pixmapbarcode.cpp batchwizard.cpp \
csvfile.cpp referencecounted.cpp dstextedit.cpp encodingcombo.cpp purepostscript.cpp tbarcode2.cpp \
tdeactionmap.cpp
noinst_HEADERS = barcodecombo.h barcodedialog.h barcodedialogs.h commands.h \
configdialog.h confwizard.h csvimportdlg.h databasebrowser.h definition.h \
definitiondialog.h dsmainwindow.h kbarcode.h label.h labeleditor.h labelutils.h \
mimesources.h multilineeditdlg.h mycanvasitem.h mycanvasview.h mydatatable.h \
newlabel.h previewdialog.h printersettings.h printlabeldlg.h rectsettingsdlg.h \
smalldialogs.h sqltables.h tokenprovider.h xmlutils.h zplutils.h measurements.h \
editoriface.h kbarcodeiface.h batchiface.h kbarcodesettings.h batchprinter.h \
barcodeitem.h documentitem.h lineitem.h rectitem.h tcanvasitem.h textitem.h \
imageitem.h documentitemdlg.h propertywidget.h tec.h barcodeprinterdlg.h \
textlineitem.h textlineedit.h tokendialog.h barkode.h gnubarcode.h barkodeengine.h \
pixmapbarcode.h batchwizard.h csvfile.h referencecounted.h dstextedit.h encodingcombo.h \
purepostscript.h tbarcode2.h

kbarcode_SOURCES = barcodecombo.cpp barcodedialog.cpp barcodedialogs.cpp \
commands.cpp configdialog.cpp confwizard.cpp csvimportdlg.cpp databasebrowser.cpp \
definition.cpp definitiondialog.cpp dsmainwindow.cpp kbarcode.cpp label.cpp \
labeleditor.cpp labelutils.cpp main.cpp mimesources.cpp multilineeditdlg.cpp \
mycanvasitem.cpp mycanvasview.cpp mydatatable.cpp newlabel.cpp previewdialog.cpp \
printersettings.cpp printlabeldlg.cpp rectsettingsdlg.cpp smalldialogs.cpp sqltables.cpp \
tokenprovider.cpp xmlutils.cpp zplutils.cpp measurements.cpp editoriface.skel \
kbarcodeiface.skel batchiface.skel kbarcodesettings.cpp batchprinter.cpp barcodeitem.cpp \
documentitem.cpp lineitem.cpp rectitem.cpp tcanvasitem.cpp textitem.cpp imageitem.cpp \
documentitemdlg.cpp propertywidget.cpp tec.cpp barcodeprinterdlg.cpp textlineitem.cpp \
textlineedit.cpp tokendialog.cpp barkode.cpp gnubarcode.cpp barkodeengine.cpp \
pixmapbarcode.cpp batchwizard.cpp csvfile.cpp dstextedit.cpp encodingcombo.cpp \
purepostscript.cpp tbarcode2.cpp

xdg_apps_DATA = kbarcode.desktop kbarcode-batch.desktop kbarcode-editor.desktop kbarcode-single.desktop



+ 1
- 1
kbarcode/barcodecombo.h View File

@@ -25,7 +25,7 @@
#include "barkode.h"

/** A validator that takes to TQRegExp's to check
* wether a barcode is valid or not.
* whether a barcode is valid or not.
*/
class BarcodeValidator : public TQValidator {
public:


+ 1
- 5
kbarcode/barcodedialogs.cpp View File

@@ -224,11 +224,7 @@ void TBarcodeDlg::setData( Barkode* b )
TQMap<TQString,int>::Iterator it;
for ( it = map.begin(); it != map.end(); ++it ) {
if( it.data() == options->checksum() ) {
for( int i = 0; i < comboCheckSum->count(); i++ )
if( comboCheckSum->text( i ) == it.key() ) {
comboCheckSum->setCurrentItem( i );
break;
}
comboCheckSum->setCurrentItem(it.key());
break;
}
}


+ 1
- 1
kbarcode/barkode.h View File

@@ -202,7 +202,7 @@ class Barkode {
*/
void drawInvalid( TQPainter & painter, int x = 0, int y = 0 );
/** returns wether barcode functionallity
/** returns whether barcode functionallity
* is available
*/
static bool haveBarcode() {


+ 10
- 19
kbarcode/dsmainwindow.cpp View File

@@ -20,7 +20,6 @@
#include "confwizard.h"
#include "printersettings.h"
#include "kbarcodesettings.h"
#include "tdeactionmap.h"
#include "barkode.h"

// TQt includes
@@ -71,6 +70,7 @@ void DSMainWindow::setupActions()
TDEAction* configureAct = KStdAction::preferences( KBarcodeSettings::getInstance(), TQT_SLOT(configure()), actionCollection() );
TDEAction* wizardAct = new TDEAction( i18n("&Start Configuration Wizard..."), BarIcon("wizard"), 0, TQT_TQOBJECT(this),
TQT_SLOT(wizard()), actionCollection(), "wizard" );

connectAct = new TDEAction(i18n("&Connect to Database"), BarIcon("connect_no"), 0, TQT_TQOBJECT(this), TQT_SLOT(connectMySQL()),
actionCollection(),"connect" );

@@ -91,13 +91,11 @@ void DSMainWindow::setupActions()
hlpMenu->removeItem( helpid );
hlpMenu->insertItem( SmallIconSet("contents"), i18n("&Help"),
this, TQT_SLOT(appHelpActivated()), Key_F1, -1, 0 );
hlpMenu->insertSeparator(-1);
hlpMenu->insertItem( i18n("&Action Map..."), TQT_TQOBJECT(this), TQT_SLOT( slotFunctionMap() ), 0, -1, 0 );
hlpMenu->insertSeparator(-2);
hlpMenu->insertItem( SmallIconSet("system"), i18n("&System Check..."), TQT_TQOBJECT(this), TQT_SLOT(showCheck() ), 0, -1, 0 );
hlpMenu->insertItem( SmallIconSet("barcode"), i18n("&Barcode Help..."), TQT_TQOBJECT(this), TQT_SLOT( startInfo() ), 0, -1, 0 );
hlpMenu->insertItem( i18n("&Donate..."), TQT_TQOBJECT(this), TQT_SLOT( donations() ), 0, -1, 0 );

hlpMenu->insertItem( SmallIconSet("barcode"), i18n("&Barcode Help..."), this, TQT_SLOT( startInfo() ), 0, -1, 1 );
hlpMenu->insertSeparator(3);
hlpMenu->insertItem( i18n("&Donate..."), this, TQT_SLOT( donations() ), 0, -1, 4 );
hlpMenu->insertSeparator(5);
hlpMenu->insertItem( SmallIconSet("system"), i18n("&System Check..."), this, TQT_SLOT(showCheck() ), 0, -1, 6 );
menuBar()->insertItem( i18n("&File"), file );
menuBar()->insertItem( i18n("&Settings"), settings );
menuBar()->insertItem( i18n("&Help"), hlpMenu );
@@ -207,13 +205,11 @@ bool DSMainWindow::newTables()

void DSMainWindow::donations()
{
// orig =https://www.paypal.com/xclick/business=domseichter%40web.de&item_name=Support+KBarcode+Development&item_number=0&image_url=http%3A//www.kbarcode.net/themes/DeepBlue/images/logo.gif&no_shipping=1&return=http%3A//www.kbarcode.net&cancel_return=http%3A//www.kbarcode.net&cn=Suggestions%2C+Comments%3F&tax=0&currency_code=EUR
TQString url = "https://www.paypal.com/xclick/business=domseichter@web.de&item_name=Support+KBarcode+Development&item_number=0&image_url=www.kbarcode.net/themes/DeepBlue/images/logo.gif&no_shipping=1&return=www.kbarcode.net&cancel_return=www.kbarcode.net&cn=Suggestions,+Comments,&tax=0&currency_code=EUR";
TQString url = "https://trinitydesktop.org/donate.php";

KMessageBox::information( this, i18n(
"<qt>It is possible to support the further development of KBarcode through donations. "
"PayPal will be used for processing the donation.<br><br>" ) +
"<a href=\"" + url + "\">" +
"<qt>It is possible to support the further development of KBarcode through donations.<br><br>" ) +
"<a href=\"" + url + "\">" +
i18n("Donate Now") + "</a></qt>", TQString(), TQString(), KMessageBox::AllowLink );
}

@@ -260,9 +256,4 @@ TQString DSMainWindow::systemCheck()
return text;
}

void DSMainWindow::slotFunctionMap()
{
new TDEActionMapDlg( actionCollection(), this );
}

#include "dsmainwindow.moc"

+ 2
- 2
kbarcode/dsmainwindow.h View File

@@ -27,7 +27,7 @@ class TDEPopupMenu;
* for database connections, preferences, help, the first start wizard and donations.
* It checks also if this is the first start of KBarcode and if the configuration wizard
* should be started.
*
*MessageBox
* @author Dominik Seichter
*/
class DSMainWindow : public TDEMainWindow {
@@ -66,7 +66,6 @@ class DSMainWindow : public TDEMainWindow {
bool newTables();
void donations();
void showCheck();
void slotFunctionMap();

protected slots:
void loadConfig();
@@ -77,6 +76,7 @@ class DSMainWindow : public TDEMainWindow {

static bool autoconnect;
static bool startwizard;
void slotFunctionMap();

bool first;


+ 0
- 427
kbarcode/dsrichtext.cpp View File

@@ -1,427 +0,0 @@
/***************************************************************************
dsrichtext.cpp - description
-------------------
begin : Fre Okt 17 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "dsrichtext.h"

#ifdef TQT_TEXT_BUG

// TQt includes
#include <tqfontmetrics.h>
#include <tqpainter.h>
#include <tqregexp.h>

// for DSREPLACE
#include "sqltables.h"

/*
EXAMPLE TEXT:
"<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:10pt;font-family:Nimbus Sans l\">"
"<p>A little bit <span style=\"font-style:italic;font-weight:600\">formated</span><span style=\"color:#4400ff\"> "
"richtext</span> which should be printed to a <span style=\"font-weight:600\">TQPrinter</span> with <span style=\"text-decoration:underline\">TQSimpleRichText</span>. </p>"
"<p><span style=\"font-family:Times New Roman;font-size:16pt\">Printing should work in ScreenResolution as well as in HighResolution, but as you can see it will only work in ScreenResolution.</span></p>"
"</body></html>";

Another example
<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Nimbus Sans l">
<p align="center"><span style="font-size:12pt;font-weight:600;text-decoration:underline">Text test </span><span style="font-size:12pt;font-weight:600;text-decoration:underline;color:#ff0000">label</span></p>
<p>Resolution <span style="font-weight:600">formated</span> 108dpi. This text &amp; text should now overlap with the first line. 4 &lt; 6a</p>
<p><span style="font-family:Nimbus Sans L;font-weight:600">A</span><span style="font-family:Nimbus Sans L"> longer paragraph with some text, so that I can test wether wordwrap is working. Another &quot;line&quot; to test line spacing without a bigger font (like the one found in the next sentence) messing up the spacing.</span><span style="font-family:Courier [Adobe];font-size:16pt"> Some text &quot;in&quot; a bigger courier font.</span><span style="font-family:Nimbus Sans L"> Also this paragraph should be justified as blockquote.</span><span style="font-family:Nimbus Sans L;color:#ff0004"> I hope it works</span><span style="font-family:Nimbus Sans L"> and KBarcodes text redering will be better than the one found in TQt.</span></p>
</body></html>

*/

DSRichText::DSRichText( const TQString & t )
: text( t )
{
if( text.find("<html>") == -1 )
text = "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:10pt;font-family:Nimbus Sans l\"><p>"
+ t + "</p></body></html>";

//tqDebug( text );

start = end = pos = 0;
x = y = 0;
sx = sy = 1.0;
m_base = TQFont();

TQString tmp = parse( text, "<body ", ">", 0 );
if( !tmp.isNull() ) {
pos += tmp.length();
tmp = tmp.left( tmp.length() - 1 );
tmp = tmp.mid( 5, tmp.length() - 5 );
m_base = parseStyle( parse( tmp, "style=\"", "\"", pos ), &m_color );
}

pos = text.find( "<p", 0 ); // initalize pos correctly
while( parseParagraph() ); // empty while loop
}

DSRichText::~DSRichText()
{
}

void DSRichText::initFormat( formated_word* f, int alignment )
{
f->text = TQString();
f->line = false;
f->alignment = alignment;
f->font = m_base;
f->color = m_color;
}

void DSRichText::initLine( TQValueList<formated_line>* l )
{
formated_line li;
li.width = 0;
li.ascent = 0;
li.leading = 0;
li.lineSpacing = 0;
li.line = false;
l->append( li );
}

void DSRichText::updateSpacing( TQValueList<formated_line>* l, TQFontMetrics* fm )
{
l->last().lineSpacing = (l->last().lineSpacing < fm->lineSpacing()) ? fm->lineSpacing() : l->last().lineSpacing;
l->last().ascent = (l->last().ascent < fm->ascent()) ? fm->ascent() : l->last().ascent;
l->last().leading = (l->last().leading < fm->leading()) ? fm->leading() : l->last().leading;
}

void DSRichText::fillLines()
{
for( unsigned int z = 0; z < word_p.count(); z++ ) {
WordList words = word_p[z];
LineList lines;
initLine( &lines );
for( unsigned int i = 0; i < words.count(); i++ ) {
formated_word word = words[i];
lines.last().line = lines.last().line | word.line;

TQFontMetrics fm( word.font );
updateSpacing( &lines, &fm );

int tw = fm.width( word.text );
// word does not fit in the current line, create a new one
if( lines.last().width + tw >= w )
initLine( &lines );

// TODO: check here for words longer than one line
lines.last().formats.append( word );
lines.last().width += tw;
}
line_p.append( lines );
}
}

void DSRichText::draw( TQPainter* p )
{
/* don't try to draw if there is no space to draw */
if( !w || !h )
return;
fillLines();

painter = p;
painter->save();
painter->setClipRect( xpos, ypos, int(w*sx), int(h*sy), TQPainter::CoordPainter );

for( unsigned int z = 0; z < line_p.count(); z++ ) {
LineList lines = line_p[z];
if( lines.count() && z )
y += int( lines[0].lineSpacing * 0.5);

for( unsigned int i = 0; i < lines.count(); i++ ) {
formated_line l = lines[i];
if( l.formats.count() && l.formats[0].alignment == TQt::AlignJustify && i != lines.count() - 1 ) {
// last line in a paragraph is not justified (in blocksatz mode)!
drawJustified( &l );
} else {
for( unsigned int z = 0; z < l.formats.count(); z++ ) {
formated_word f = l.formats[z];
painter->setFont( f.font );
painter->setPen( TQPen( f.color ) );

int a = f.alignment;
if( a == TQt::AlignRight ) {
a = TQt::AlignLeft;
if( !x )
x = w - l.width;
} else if( a == TQt::AlignHCenter ) {
a = TQt::AlignLeft;
if( !x )
x = ( w - l.width ) / 2;
}

int ya = yDeviation( &l );
painter->drawText( xpos + int(x*sx), ypos + int((y+ya)*sy), int(l.width*sx), int(l.lineSpacing * sy), a, f.text );
x += painter->fontMetrics().width( f.text );
}
}

x = 0;
y += l.lineSpacing;
}
}

painter->restore();
}

void DSRichText::drawJustified( formated_line* line )
{
int all = 0;
for( unsigned int z = 0; z < line->formats.count(); z++ ) {
line->formats[z].text = line->formats[z].text.stripWhiteSpace();
TQFontMetrics fm( line->formats[z].font );
all += fm.width( line->formats[z].text );
}

int x = 0;
int space = (w - all) / (line->formats.count() - 1);
for( unsigned int z = 0; z < line->formats.count(); z++ ) {
painter->setFont( line->formats[z].font );
painter->setPen( TQPen( line->formats[z].color ) );

int ya = yDeviation( line );
int tw = painter->fontMetrics().width(line->formats[z].text);
painter->drawText( int(x*sx), int((y+ya)*sy), int(tw*sx), int(line->lineSpacing * sy), TQt::AlignAuto, line->formats[z].text );
x += tw;
x += space;
}

}

bool DSRichText::parseParagraph()
{
int alignment = 0;
formated_word f;
TQString d = parse( text, "<p", "</p>", pos );
//tqDebug("D=" + d );
//tqDebug("POS=%i", pos );

pos += d.length();
if( d.isNull() )
return false;

d = parseParagraphTag( d, &alignment );

WordList words;
TQString data;
initFormat( &f, alignment );

if( d.isEmpty() ) {
// found empty paragraph
words.append( f );
word_p.append( words );
return true;
}

for( unsigned int i = 0; i < d.length(); ) {
if( d[i] == '<' || i == (d.length() - 1) ) {
if( i == (d.length() - 1) )
data.append( d[i] );

parseWords( data, &f, &words );
initFormat( &f, alignment );
data = TQString();

// bail out now, otherwise there is
// and endless loop for e.g. <p>a</p>
if( i == (d.length() - 1) )
break;

if( d[i] == '<' ) {
TQString span = d.mid( i, d.find( ">", i ) - i + 1 );
i += span.length();

if( span.startsWith( "<span " ) ) {
initFormat( &f, alignment );
f.font = parseStyle( parse( span, "style=\"", "\"", 0 ), &f.color );
}
}
} else {
data.append( d[i] );
i++;
}
}

word_p.append( words );
return true;
}

TQFont DSRichText::parseStyle( const TQString & s, TQColor* color )
{
TQString style = TQString( s );

style = style.left( style.length() - 1 );
if( style.startsWith("style=\"" ) )
style = style.mid( 7, style.length() - 7 );

TQFont f = m_base;
*color = m_color;
for ( int i = 0; i < style.contains(';')+1; i++ ) {
TQString s = style.section( ';', i, i );
if( s.isEmpty() )
continue;
if ( s.startsWith("font-size:" ) ) {
f.setPointSize( s.mid(10, s.length() - 12).toInt() );
} else if ( s.startsWith("font-family:" ) ) {
f.setFamily( s.right( s.length() - 12 ) );
} else if( s.startsWith( "color:" ) ) {
color->setNamedColor( s.right( s.length() - 6 ) );
} else if( s.startsWith("text-decoration:") ) {
if( s.endsWith( "underline" ) )
f.setUnderline( true );
/*#if [[[TQT_VERSION IS DEPRECATED]]] >= 0x030200
else if( s.endsWith( "overline" ) )
f.setOverline( true );
#endif */
else if( s.endsWith( "line-through" ) )
f.setStrikeOut( true );
} else if( s.startsWith( "font-style:") ) {
if( s.endsWith( "italic" ) || s.endsWith( "oblique" ) )
f.setItalic( true );
} else if( s.startsWith( "font-weight:" ) ) {
bool ok = false;
int n = s.right( s.length() - 12 ).toInt( &ok );
if( s.endsWith( "bold" ) )
f.setBold( true );
else if( ok )
f.setWeight( n / 8 ); // convert CSS values to TQt values
}
}

return f;
}

TQString DSRichText::parse( const TQString & t, const TQString & find, const TQString & find2, int start )
{
int s = t.find( find, start );
if( s == -1 || s < start )
return TQString();

int pend = t.find( find2, s + find.length() );
if( pend == -1 || pend < (signed int)(s + find.length()) )
return TQString();

TQString text = t.mid( s, pend - s + find2.length() );
return text;
}

void DSRichText::setX( int x )
{
xpos = x;
}

void DSRichText::setY( int y )
{
ypos = y;
}

void DSRichText::setWidth( int width )
{
w = width;
}

void DSRichText::setHeight( int height )
{
h = height;
}

int DSRichText::parseAlignment( const TQString & align )
{
TQString a = TQString( align );
if( a.endsWith("\"") )
a = a.left( a.length() - 1 );

if( a.startsWith("align=\"") )
a = a.mid( 7, a.length() - 7 );

if( a == "left" )
return TQt::AlignLeft;
else if( a == "center" )
return TQt::AlignHCenter;
else if( a == "right" )
return TQt::AlignRight;
else if( a == "justify" )
return TQt::AlignJustify;

return 0;
}

void DSRichText::parseWords( const TQString & t, formated_word* w, WordList* words )
{
unsigned int p = 0;
for( unsigned int i = 0; i < t.length(); i++ ) {
if( (t[i].isSpace() && p != i) || i == t.length() - 1 ) {
formated_word word = *w;

word.text = replaceEscapeSequences( t.mid( p, i + 1 - p ) );

p = i + 1;
words->append( word );
}
}
}

inline int DSRichText::yDeviation( const formated_line* line )
{
// leading = 1 (almost ever)
// linespacing = leading + height
// height = ascent + descent + 1
if( line->lineSpacing != painter->fontMetrics().lineSpacing() ) {
return line->ascent + line->leading - painter->fontMetrics().ascent() - painter->fontMetrics().leading();
} else {
return 0;
}
}

TQString DSRichText::replaceEscapeSequences( const TQString & t )
{
TQString tmp = TQString( t );
tmp = tmp.replace( DSREPLACE( "&lt;" ), "<" );
tmp = tmp.replace( DSREPLACE( "&gt;" ), ">" );
tmp = tmp.replace( DSREPLACE( "&amp;" ), "&" );
tmp = tmp.replace( DSREPLACE( "&quot;" ), "\"" );
return tmp;
}

TQString DSRichText::parseParagraphTag( const TQString &t, int* alignment )
{
TQString d = TQString( t );
if( d.startsWith("<p>") ) {
d = d.mid( 3, d.length() - 3 );
} else if( d.startsWith("<p ") ) {
*alignment = parseAlignment( parse( d, "align=\"", "\"", 0 ) );
if( d.contains( ">" ) ) {
int x = d.find(">" ) + 1;
d = d.mid( x, d.length() - x );
}
}

if( d.endsWith("</p>") )
d = d.left( d.length() - 4 ); // strlen("</p>");

return d;
}

#endif // TQT_TEXT_BUG



+ 0
- 193
kbarcode/dsrichtext.h View File

@@ -1,193 +0,0 @@
/***************************************************************************
dsrichtext.h - description
-------------------
begin : Fre Okt 17 2003
copyright : (C) 2003 by Dominik Seichter
email : domseichter@web.de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef DSRICHTEXT_H
#define DSRICHTEXT_H

#define TQT_TEXT_BUG
/*#undef TQT_TEXT_BUG*/
#ifdef TQT_TEXT_BUG

#include <tqcolor.h>
#include <tqfont.h>
#include <tqstring.h>
#include <tqvaluelist.h>

class DSRichText;

/** This class represents one word,
* formated with a font, a color and an
* alignment.
*/
struct formated_word {
TQString text;
TQFont font;
TQColor color;
int alignment;
bool line;
};

typedef TQValueList<formated_word> WordList;

/** This structure represents a single line.
* Every line contains a list of formated_words.
* Wordwrapping has been applied before the line
* was created.
* lineSpacing, ascent and leading come from the
* biggest font in the line.
*/
struct formated_line {
int width;
int lineSpacing;
int ascent;
int leading;
bool line;

WordList formats;
};
typedef TQValueList<formated_line> LineList;

class TQColor;
class TQPainter;

/** A richtext rendering class, which draws a piece
* of HTML formated richtext on any TQPainter.
* This class works with all printer resolutions compared
* to the buggy TQSimpleRichText
*
* rendering the richtext happens in 3 steps:
* <ul>
* <li> the HTML data is parsed into text_format structures. Each
* of these text_format structures may represend multiple lines, but
* also single words. This depends on how long a formated text is.
* this step happens in the constructor and in parseParagraph()</li>
* <li> the text_format structures are parsed into line structures.
* In this step the wordwrapping is calculated. Each line structure
* has again text_format structures. This is necessary because a line
* of text may of course contain different formattings. A line struct is always
* a single line of drawn text, not more and not less.
* happens in draw() and fillLines()</li>
* <li> the line structure is drawn line by line using TQPainter.
* happens in draw()</li>
* </ul>
*
* Printing to the screen is easy and the usage does not differ from
* TQSimpleRichText. Drawing on TQPrinter is a little bit more complicated.
* The most important thing is that you may not use TQPainter::scale().
* A small example on how to print on a TQPrinter:
* <pre>
* TQPrinter printer( TQPrinter::HighResolution );
* TQPainter painter( &printer );
* TQPaintDeviceMetrics metrics( &printer );
* double scalex = (double)metrics.logicalDpiX() / (double)TQPaintDevice::x11AppDpiX();
* double scaley = (double)metrics.logicalDpiY() / (double)TQPaintDevice::x11AppDpiY();
*
* DSRichText dsr( "&lt;html&gt;&lt;p&gt;Hallo World&lt;/p&gt;&lt;/html&gt;" );
* dsr.setWidth( 200 ); // in screenresolution coordinates
* dsr.setHeight( 80 ); // in screenresolution coordinates
* painter.translate( 10 * scalex, 10 * scaley ); // draw at 10, 10 instead of 0, 0
* dsr.scale( scalex, scaley );
* dsr.draw( &painter );
* </pre>
*
*@author Dominik Seichter
*/
class DSRichText {
public:
/** construct a DSRichText object. @p t is formated text as produces by TQTextEdit.
*/
DSRichText( const TQString & t );
~DSRichText();

void setX( int x );
void setY( int y );
/** draw the formated text on the TQPainter* @p p
*/
void draw( TQPainter* p );
/** set the width of the clipping rectangle
*/
void setWidth( int width );
/** set the height of the clipping rectangle
*/
void setHeight( int height );
/** scale everything. This is necessary to print on devices
* with another resolution than the screen. TQPainter::scale() won't work.
*/
void setScale( double x, double y ) {
sx = x; sy = y;
};

private:
/** parse a single pare of <p></p> elements
*/
bool parseParagraph();
/** remove <p> and </p> from the TQString @p t and return it.
* This function is also responsible for getting the
* correct alignment of the paragraph.
*/
TQString parseParagraphTag( const TQString & t, int* alignment );
/** parse the align attribute of a <p> tag and return the corresponding TQt alignment value.
*/
int parseAlignment( const TQString & align );
/** parse the css style attribute of a <span> tag and return a matching TQFont for these
* style. The font color is saved in the TQColor* @p color.
*/
TQFont parseStyle( const TQString & s, TQColor* color );
TQString parse( const TQString & t, const TQString & find, const TQString & end, int start );
void parseWords( const TQString & t, formated_word* w, WordList* words );
void initFormat( formated_word* f, int alignment );
void initLine( TQValueList<formated_line>* l );
void updateSpacing( TQValueList<formated_line>* l, TQFontMetrics* fm );
/** draw the line @p line justified as blockquote
*/
void drawJustified( formated_line* line );
/** calculate the y-deviation needed, because of different font sizes in this line
*/
inline int yDeviation( const formated_line* line );
/** replace HTML escape sequences such as &lt; to their real character meaning (i.e. < )
*/
TQString replaceEscapeSequences( const TQString & t );

/** fill the line structures with data
*/
void fillLines();

int pos; // current position in text
int start; // start of a tag
int end; // end of a tag
int x; // x position
int y; // y position
int w; // width of the text element
int h; // height of the text element
int xpos; // x position at the beginning
int ypos; // y position at the beginning
double sx;
double sy;
TQString text;
TQFont m_base;
TQColor m_color;
TQPainter* painter;

TQValueList<LineList> line_p;
TQValueList<WordList> word_p;
};

#endif // TQT_TEXT_BUG
#endif

+ 1
- 1
kbarcode/dstextedit.cpp View File

@@ -20,7 +20,7 @@
#include <tqregexp.h>

DSTextEdit::DSTextEdit( TQWidget* parent, const char* name )
: TextEditBase( parent, name )
: KTextEdit( parent, name )
{
connect( this, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( fixParagraphs() ) );
}


+ 6
- 6
kbarcode/dstextedit.h View File

@@ -18,26 +18,26 @@
#ifndef _DS_TEXT_EDIT_H_
#define _DS_TEXT_EDIT_H_

#include <tqnamespace.h>
#include <tqnamespace.h>

#include <ktextedit.h>

// Otherwise moc will complain
#define TextEditBase KTextEdit

class DSTextEdit : public TextEditBase {
class DSTextEdit : public KTextEdit {
Q_OBJECT
public:
DSTextEdit( TQWidget* parent, const char* name = 0 );

//virtual void moveCursor( CursorAction action, bool select );
private slots:
void fixParagraphs();
private:
/**
/**
* returns true if the cursor is currently inside
* of a token of the form [value].
*/


+ 42
- 54
kbarcode/labelutils.cpp View File

@@ -16,7 +16,6 @@
***************************************************************************/

#include "labelutils.h"
#include "dsrichtext.h"

// TQt includes
#include <tqbitmap.h>
@@ -108,81 +107,70 @@ TQSize LabelUtils::stringSize( const TQString & t )
return s;
}

void LabelUtils::renderString( TQPainter* painter, const TQString & t, const TQRect & rect, double scalex, double scaley )
TQPixmap* LabelUtils::drawString(const TQString & t, int w, int h, double rot)
{
// DSRichText cannot calculate the width on its own
TQSimpleRichText srt( t, TDEApplication::font() );
int width = (rect.width() > 0) ? rect.width() : srt.widthUsed();
int height = (rect.height() > 0) ? rect.height() : srt.height();
DSRichText r( t );
r.setX( rect.x() );
r.setY( rect.y() );
r.setWidth( width );
r.setHeight( height );
r.setScale( scalex, scaley );
r.draw( painter );
}

TQPixmap* LabelUtils::drawString( const TQString & t, int w, int h, double rot )
{
TQSimpleRichText srt( t, TDEApplication::font() );
TQSimpleRichText srt(t, TDEApplication::font());

int width = (w > 0) ? w : srt.widthUsed();
int height = (h > 0) ? h : srt.height();
srt.setWidth( width );

TQPixmap* pix;
TQPainter painter;
if( rot == 0.0 ) {
TQBitmap bm( width, height );
bm.fill( TQt::color0 ); //transparent
painter.begin( &bm );
painter.save();
painter.setPen( TQt::color1 );
TQColorGroup cg;
cg.setColor( TQColorGroup::Foreground, TQt::color1 );
cg.setColor( TQColorGroup::Text, TQt::color1 );
cg.setColor( TQColorGroup::Base, TQt::color0 );
srt.draw( &painter, 0, 0, bm.rect(), cg );
painter.restore();

if (rot == 0.0)
{
TQBitmap bm(width, height);
bm.fill(TQt::color0); //transtqparent
painter.begin(&bm);

painter.save();
painter.setPen(TQt::color1);
TQColorGroup cg;
cg.setColor(TQColorGroup::Foreground, TQt::color1);
cg.setColor(TQColorGroup::Text, TQt::color1);
cg.setColor(TQColorGroup::Base, TQt::color0);

srt.draw(&painter, 0, 0, bm.rect(), cg);
painter.restore();
painter.end();
pix = new TQPixmap( width, height );
pix->fill( TQt::white );
pix->setMask( bm );
if( !pix->isNull() ) {
painter.begin( pix );
painter.setPen( TQt::black );

pix = new TQPixmap(width, height);
pix->fill(TQt::white);
pix->setMask(bm);

if (!pix->isNull())
{
painter.begin(pix);
painter.setPen(TQt::black);
TQColorGroup cg;
srt.draw( &painter, 0, 0, pix->rect(), cg );
srt.draw(&painter, 0, 0, pix->rect(), cg);
painter.end();
}
} else {
}
}
else
{
int w2 = (w > 0) ? w : srt.widthUsed();
int h2 = (h > 0) ? h : srt.height();

TQWMatrix wm;
wm.rotate( rot );
wm.rotate(rot);

TQSize s = LabelUtils::stringSize( t );
TQPixmap* tmp = LabelUtils::drawString( t, s.width(), s.height() );
TQSize s = LabelUtils::stringSize(t);
TQPixmap* tmp = LabelUtils::drawString(t, s.width(), s.height());

TQPixmap* p = new TQPixmap( w2, h2 );
p->fill( TQt::white );
painter.begin( p );
painter.drawPixmap( 0, 0, tmp->xForm( wm ) );
TQPixmap* p = new TQPixmap(w2, h2);
p->fill(TQt::white);
painter.begin(p);
painter.drawPixmap(0, 0, tmp->xForm(wm));
painter.end();

p->setMask( p->createHeuristicMask() );
p->setMask(p->createHeuristicMask());

pix = p;
delete tmp;
}
return pix;
}


+ 0
- 1
kbarcode/labelutils.h View File

@@ -52,7 +52,6 @@ class LabelUtils {
static TQPixmap* drawString( const TQString & t ) {
return LabelUtils::drawString( t, 0, 0, 0 );
}
static void renderString( TQPainter* painter, const TQString & t, const TQRect & r, double scalex, double scaley );

const TQString getTypeFromCaption( const TQString & cap );
const TQString getModeFromCaption( const TQString & cap );


+ 3
- 1
kbarcode/main.cpp View File

@@ -108,6 +108,8 @@ int main(int argc, char *argv[])
aboutData.addCredit("John Volpe", I18N_NOOP("Added lot's of useful data fields to kbarcode"), "jtvolpe@cape.com" );
aboutData.addCredit("Nyssa s.r.l.", I18N_NOOP("Added TEC barcode printer support"), "imorrison@nyssa.com.ar", "http://www.nyssa.com.ar" );
aboutData.addCredit("Brian Glass", I18N_NOOP("Added EPCL barcode printer support"), "brian@glassbrian.com", "http://www.glassbrian.com" );
aboutData.addCredit("Váradi Zsolt Gyula", I18N_NOOP("Wrote bugfixes."), "vzsolt@users.sf.net");
aboutData.addCredit("Timothy Pearson", I18N_NOOP("Maintainer (TDE project)"), "kb9vqf@pearsoncomputing.net");
TDECmdLineArgs::init( argc, argv, &aboutData );
TDECmdLineArgs::addCmdLineOptions( options );

@@ -119,7 +121,7 @@ int main(int argc, char *argv[])
a.connect( &a, TQT_SIGNAL(lastWindowClosed()), &a, TQT_SLOT(quit()));

KBarcode* kbc = new KBarcode( 0, "KBarcodeMainWindow" );
if( kbc->parseCmdLine() )
return 0;
else


+ 1
- 4
kbarcode/multilineeditdlg.cpp View File

@@ -20,7 +20,6 @@

// KDE includes
#include <tdeaction.h>
#include <tdeversion.h>
#include <kcolordialog.h>
#include <tdefiledialog.h>
#include <tdelocale.h>
@@ -149,9 +148,6 @@ void MultiLineEditor::setupActions()
action_italic->plug( toolBar );
action_underline->plug( toolBar );
toolBar->insertSeparator();
//#if KDE_IS_VERSION( 3, 1, 90 )
// action_spell->plug( toolBar );
//#endif
action_font->plug( tool2Bar );
action_font_size->plug( tool2Bar );
@@ -271,6 +267,7 @@ void MultiLineEditor::insertNewField()

void MultiLineEditor::checkSpelling()
{
// FIXME: check and clean up spellchecking (Zsolt, 2008-04-07)
/*
#if KDE_IS_VERSION( 3, 1, 90 )
TQString s;


+ 0
- 620
kbarcode/mybarcode.cpp View File

@@ -1,620 +0,0 @@
f/***************************************************************************
barcode.cpp - description
-------------------
begin : Die Apr 23 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "sqltables.h"
#include "barcodecache.h"

#include "mybarcode.h"
#include <stdio.h>

// TQt includes
#include <tqdir.h>
#include <tqpainter.h>
#include <tqpaintdevicemetrics.h>
#include <tqsqlquery.h>

// KDE includes
#include <tdeapplication.h>
#include <tdeconfig.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kprocess.h>
#include <kstandarddirs.h>
#include <tdetempfile.h>

#define BARCODE_MARGIN 10 /* Margin added by GNU Barcode to the barcodes */

TQValueList<barcodeFormat> codes;

void init() {
BarCode::setHaveBarcode();
}

bool barcodeData::operator==( const struct barcodeData d ) const {
bool b = ( value == d.value && type == d.type &&
scale == d.scale && text == d.text );

if( BarCode::hasFeature( type, TBARCODEADV ) )
b = ( b && tbarcode == d.tbarcode );

if( BarCode::hasFeature( type, DATAMATRIX ) )
b = ( b && datamatrix == d.datamatrix );

if( BarCode::hasFeature( type, PDF417BARCODE ) )
b = ( b && pdf417 == d.pdf417 );

return b;
};

BarCode::BarCode( const barcodeData* data )
{
barcode = *data;
m_index = 0;
}

BarCode::BarCode()
{
fillDefault( &barcode );
m_index = 0;
}

BarCode::~BarCode()
{
}

const TQPixmap BarCode::pixmap()
{
if( p.isNull() )
createBarcode( &p, TDEApplication::desktop() );

if( p.isNull() ) {
KMessageBox::error( 0, "<qt>" + i18n("Barcode not valid!") + "<br>" + barcode.value + "</qt>" );
barcode.valid = false;
}
return p;
}

bool BarCode::createPixmap( TQPixmap* target, int resx, int resy )
{
KTempFile* output = new KTempFile( TQString(), ".ps" );;
output->file()->close();
KTempFile* input = new KTempFile( TQString(), ".pbm" );
input->file()->close();

m_value = createSequence( barcode.value );

if( BarCode::hasFeature( barcode.type, PDF417 ) ) {
if(!createPdf417( output )) {
cleanUp( output, input, target );
return false;
}
} else if( BarCode::hasFeature( barcode.type, TBARCODE ) ) {
if(!createTBarcode( output )) {
cleanUp( output, input, target );
return false;
}
} else { // if( BarCode::hasFeature( barcode.type, GNU_BARCODE ) ) {
TQString flag = barcode.text ? "" : "-n";

KShellProcess proc;
proc << "barcode" << "-E"
<< "-b" << KShellProcess::quote( m_value ) << flag
<< "-e" << barcode.type << "-o" << output->name();

proc.start( TDEProcess::Block, TDEProcess::NoCommunication );
proc.resume();

if( proc.exitStatus() ) {
cleanUp( output, input, target );
return false;
}
}

TQFileInfo fi( output->name() );
// if file size = 0, error in generation
if( !fi.size() ) {
cleanUp( output, input, target );
return false;
}

TQSize s = getBoundingBox( output->name() );
double sw = (double)s.width()/72 * resx;
double sh = (double)s.height()/72 * resy;
KShellProcess proc2;
proc2 << "gs" << TQString("-g%1x%2").arg(int(sw*(double)barcode.scale)).arg(int(sh*(double)barcode.scale))
<< "-r" + TQString::number( resx*(double)barcode.scale ) + "x" + TQString::number( resy*(double)barcode.scale )
<< "-sDEVICE=pbmraw" << "-sOutputFile=" + input->name() << "-sNOPAUSE"
<< "-q " + output->name() << "-c showpage" << "-c quit";
proc2.start( TDEProcess::Block, TDEProcess::NoCommunication );
proc2.resume();

if( proc2.exitStatus() ) {
cleanUp( output, input, target );
return false;
}

target->load( input->name(), "PBM" );
// BarcodeCache::instance()->write( barcode, resx, resy, target, m_value );

input->unlink();
output->unlink();

delete output;
delete input;

return true;
}

void BarCode::createBarcode( TQPixmap* target, TQPaintDevice* device )
{
TQPaintDeviceMetrics pdm( device );
int resx = pdm.logicalDpiX();
int resy = pdm.logicalDpiY();

TQString value = createSequence( barcode.value );
TQPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value );

// no matching barcode found in cache
if( !cached ) {
if( !createPixmap( target, resx, resy ) )
return;
} else {
*target = *cached;
delete cached;
}
if( BarCode::hasFeature( barcode.type, PDF417 ) ) {
// we have to scale to the correct resolution.
// we scale already here and not at the end,
// so that the addMargin function does not get a scaled margin.
TQPaintDeviceMetrics pdm( TDEApplication::desktop() );
int screenresx = pdm.logicalDpiX();
int screenresy = pdm.logicalDpiY();
TQWMatrix m;
double scalex = (resx/screenresx)*barcode.scale;
double scaley = (resy/screenresy)*barcode.scale;
m.scale( scalex, scaley );
*target = target->xForm( m );
}
*target = cut( target, barcode.cut );
*target = addMargin( target, barcode.margin );

// Rotate
TQWMatrix m;
m.rotate( (double)barcode.rotation );
*target = target->xForm( m );

barcode.valid = true;
}

bool BarCode::createPdf417( KTempFile* output )
{
KTempFile text( TQString(), ".txt" );
TQTextStream t( text.file() );
t << m_value;
text.file()->close();

// ps does not work use pbm!
KShellProcess proc;
proc << "pdf417_enc" << "-tps" << text.name() << output->name()
<< barcode.pdf417.row
<< barcode.pdf417.col
<< barcode.pdf417.err;
proc.start( TDEProcess::Block, TDEProcess::NoCommunication );
proc.resume();

if( proc.exitStatus() ) {
text.unlink();
return false;
}

text.unlink();
return true;
}

bool BarCode::createTBarcode( KTempFile* output )
{
// print text
TQString flag = barcode.text ? "" : "n";
// escape text
flag.append( barcode.tbarcode.escape ? " son" : " soff" );
// autocorrection
flag.append( barcode.tbarcode.autocorrect ? " Aon" : " Aoff" );
// text above
flag.append( barcode.tbarcode.above ? " a" : "" );
KShellProcess proc;
proc << "tbarcodeclient" << "-f" + output->name();
if( !BarCode::hasFeature( barcode.type, BARCODE2D ) )
proc << TQString( "m%1" ).arg( barcode.tbarcode.modulewidth * 1000 );

if( BarCode::hasFeature( barcode.type, DATAMATRIX ) )
proc << TQString( "Ds%1" ).arg( barcode.datamatrix.size );

if( BarCode::hasFeature( barcode.type, PDF417BARCODE ) )
proc << TQString( "Pr%1 Pc%2 Pe%3" ).arg( barcode.pdf417.row )
.arg( barcode.pdf417.col )
.arg( barcode.pdf417.err );
proc << barcode.type << "tPS" << TQString("c%1").arg( barcode.tbarcode.checksum ) << flag << "d" + KShellProcess::quote( m_value );
proc.start( TDEProcess::Block, TDEProcess::NoCommunication );
proc.resume();

if( proc.exitStatus() )
return false;

return true;
}

const TQPixmap BarCode::printerPixmap( TQPaintDevice* device )
{
if( pp.isNull() )
createBarcode( &pp, device );
return pp;
}

void BarCode::fillDefault( barcodeData* data )
{
data->margin = 10;
data->text = true;
data->value = "1234567890";
data->type = "code39";
data->scale = 1.0;
data->cut = 1.0;
data->rotation = 0;
data->valid = false;

data->pdf417.row = 24;
data->pdf417.col = 8;
data->pdf417.err = 5;

data->datamatrix.size = 0;

data->tbarcode.modulewidth = 0.353;
data->tbarcode.escape = false;
data->tbarcode.above = false;
data->tbarcode.autocorrect = false;
data->tbarcode.checksum = 0;
data->xml.caption = "Static";
data->xml.x = 0;
data->xml.y = 0;

data->sequence.enabled = false;
data->sequence.mode = NUM;
data->sequence.step = 1;
data->sequence.start = 1;
}

void BarCode::redrawBarcode()
{
p.resize( 0, 0 );
pp.resize( 0, 0 );
}

TQPixmap BarCode::cut( TQPixmap* pic, double cut)
{
if( cut == 1.0 )
return (*pic);

TQPixmap pcut( pic->width(), int((double)pic->height() * cut) );
pcut.fill( TQt::white ); // barcode.bg

TQWMatrix m;
/*
* if text is above the barcode cut from
* below the barcode.
*/

// TODO: put this into one if, I am to stupid today.....
if( BarCode::hasFeature( barcode.type, TBARCODEADV ) ) {
if( !barcode.tbarcode.above )
m.rotate( 180 );
} else
m.rotate( 180 );

TQPainter painter( &pcut );
painter.drawPixmap( 0, 0, pic->xForm( m ) );

return pcut.xForm( m );
}

TQPixmap BarCode::addMargin( TQPixmap* pic, int margin )
{
TQPixmap p;

/* We have to handle UPC special because of the checksum character
* which is printed on the right margin.
* The samve goes for ISBN codes.
* Any other formats??
*/

bool gnubarcode = BarCode::hasFeature( barcode.type, GNU_BARCODE );
double barm = gnubarcode ? BARCODE_MARGIN * barcode.scale : 0;

// Add margin
double sx = barm;
double sy = barm;
double sw = pic->width() - barm * 2;
double sh = pic->height() - barm * 2;

if( gnubarcode && (barcode.type == "upc" || barcode.type == "isbn") ) {
sw = pic->width() - barm;

p.resize( pic->width() + int(margin*2 - barm), pic->height() + int(margin * 2 - barm * 2) );
} else
p.resize( pic->width() + int(margin*2 - barm * 2), pic->height() + int(margin * 2 - barm * 2) );

p.fill( TQt::white ); // barcode.bg
TQPainter painter( &p );
painter.drawPixmap( margin, margin, *pic, (int)sx, (int)sy, (int)sw, (int)sh );
painter.end();

return p;
}

const TQString BarCode::getMaxLength( const TQString & name )
{
TQSqlQuery query("select uid, (length(barcode_no)) as LEN from " TABLE_BASIC
" where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" );

while( query.next() ) {
TQSqlQuery queryuid("select barcode_no from barcode_basic where uid = '"
+ query.value( 0 ).toString() + "'" );
while( queryuid.next() )
if(!queryuid.value( 0 ).toString().isEmpty())
return queryuid.value( 0 ).toString();
}

TQSqlQuery query1("select uid, (length(barcode_no)) as LEN from " TABLE_CUSTOMER_TEXT
" where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" );

while( query1.next() ) {
TQSqlQuery queryuid("select barcode_no from customer_text where uid = '"
+ query1.value( 0 ).toString() + "'" );
while( queryuid.next() )
if(!queryuid.value( 0 ).toString().isEmpty())
return queryuid.value( 0 ).toString();
}

return "1234567";
}

void BarCode::cleanUp( KTempFile* file, KTempFile* file2, TQPixmap* target )
{
target->resize( 0, 0 );

file->unlink();
file2->unlink();
delete file;
delete file2;
}

TQString BarCode::createSequence( const TQString & value )
{
if( !barcode.sequence.enabled )
return value;
if( value.contains( '#' ) <= 0 )
return value;

TQString text = value;
int pos = 0, counter = 1;

pos = text.find("#", pos);
pos++;
while( text[pos] == '#' ) {
text.remove(pos, 1);
counter++;
}

pos = text.find("#", 0);
TQString temp;

if( barcode.sequence.mode == NUM ) {
int v = barcode.sequence.start + m_index*barcode.sequence.step;
temp.sprintf("%0*i", counter, v );
} else {
for( int i = 0; i < counter; i++ )
temp.append( "A" );

unsigned int z = 0;
for( int p = temp.length(); p >= 0; p--, z++ ) {
if( barcode.sequence.mode == ALPHA ) {
int v = 'A' + m_index*barcode.sequence.step;
v -= z*('Z'-'A');
if( v <= 'Z' ) {
temp[p] = TQChar(v);
break;
} else if( v > 'Z' )
v = 'Z';
temp[p] = TQChar(v);
} else if( barcode.sequence.mode == ALPHANUM ) {
tqDebug("NOT IMPLEMENTED");
/* char array[36];
for( unsigned int i = 'A'; i <= 'Z'; i++ )
array[i-'A'] = i;
for( unsigned int i = '0'; i <= '9'; i++ )
array['Z'-'A'+i-'0'] = i;

int z = m_index*barcode.sequence.step;
if( z < sizeof(array) )
temp[]
int v = array[ ]*/
}
}
}
text.replace( pos, 1, temp);

return text;
}

TQString BarCode::sequenceValue()
{
return createSequence( barcode.value );
}

bool BarCode::hasFeature( const TQString & type, unsigned int feature )
{
for( unsigned int i = 0; i < codes.count(); i++ )
if( codes[i].name == type )
return (codes[i].features & feature) == feature;
return false;
}

TQSize BarCode::getBoundingBox( const TQString & filename )
{
TQSize s(0,0);
TQFile f( filename );
if( !f.open( IO_ReadOnly ) )
return s;
TQString t;
while( f.readLine( t, 1000 ) != -1 )
{
if( t.startsWith( "%%BoundingBox:") )
{
int x = 0;
int y = 0;
int w = 0;
int h = 0;
t = t.right( t.length() - 14 );
sscanf( (const char*)t, "%d %d %d %d", &x, &y, &w, &h );
s = TQSize( w, h );
break;
}
}

f.close();
return s;
}

bool BarCode::m_haveGnuBarcode = false;
bool BarCode::m_havePdfEncode = false;
bool BarCode::m_haveTBarcode = false;

barcodeFormat BarCode::fillStruct( const TQString & name, const TQString & text, const int feature )
{
barcodeFormat t;
t.name = name;
t.text = text;
t.features = feature;
return t;
}

void BarCode::setHaveBarcode()
{
m_haveGnuBarcode = !TDEStandardDirs::findExe( "barcode" ).isNull();
m_havePdfEncode = !TDEStandardDirs::findExe( "pdf417_enc" ).isNull();
m_haveTBarcode = !TDEStandardDirs::findExe( "tbarcodeclient" ).isNull();

if( codes.count() == 0 ) {
if( m_haveGnuBarcode ) {
codes.append( fillStruct( "ean", i18n("EAN (EAN 8 or EAN 13)"), GNU_BARCODE ) );
codes.append( fillStruct( "upc", i18n("UPC (12-digit EAN; UPCA and UPCB)"), GNU_BARCODE ) );
codes.append( fillStruct( "isbn", i18n("ISBN (still EAN13)"), GNU_BARCODE | NOCUT ) );
codes.append( fillStruct( "code39", i18n("Code 39"), GNU_BARCODE ) );
codes.append( fillStruct( "code39 -c", i18n("Code 39 (no checksum)"), GNU_BARCODE ) );
codes.append( fillStruct( "code128", i18n("Code 128 (a,b,c: autoselection)"), GNU_BARCODE ) );
codes.append( fillStruct( "code128c", i18n("Code 128C (compact form digits)"), GNU_BARCODE ) );
codes.append( fillStruct( "code128b", i18n("Code 128B, full printable ascii"), GNU_BARCODE ) );
codes.append( fillStruct( "i25", i18n("interleaved 2 of 5 (only digits)"), GNU_BARCODE ) );
codes.append( fillStruct( "i25 -c", i18n("interleaved 2 of 5 (only digits, no checksum)"), GNU_BARCODE ) );
codes.append( fillStruct( "128raw", i18n("Raw code 128"), GNU_BARCODE ) );
codes.append( fillStruct( "cbr", i18n("Codabar"), GNU_BARCODE ) );
codes.append( fillStruct( "cbr -c", i18n("Codabar (no checksum)"), GNU_BARCODE ) );
codes.append( fillStruct( "msi", i18n("MSI"), GNU_BARCODE ) );
codes.append( fillStruct( "pls", i18n("Plessey"), GNU_BARCODE ) );
codes.append( fillStruct( "code93", i18n("Code 93"), GNU_BARCODE ) );
}

if( m_havePdfEncode ) {
codes.append( fillStruct( "pdf417", i18n("pdf 417 2D Barcode"), BARCODE2D | PDF417 | PDF417BARCODE ) );
}
if( m_haveTBarcode ) {
codes.append( fillStruct( "b1", "Code 11", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b2", "Code 2 of 5 (Standard)", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b3", "Interleaved 2 of 5 Standard", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b4", "Code 2 of 5 IATA", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b5", "Code 2 of 5 Matrix", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b6", "Code 2 of 5 Data Logic", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b7", "Code 2 of 5 Industrial", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b8", "Code 3 of 9 (Code 39)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b9", "Code 3 of 9 (Code 39) ASCII", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b10", "EAN8", TBARCODE | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b11", "EAN8 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b12", "EAN8 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b13", "EAN13", TBARCODE | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b14", "EAN13 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b15", "EAN13 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
codes.append( fillStruct( "b16", "EAN128 (supports AIS)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b17", "UPC 12 Digits", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b18", "CodaBar (2 width)", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b19", "CodaBar (18 widths)", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b20", "Code128", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b21", "Deutsche Post Leitcode", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b22", "Deutsche Post Identcode", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b25", "Code 93", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b26", "Identical to eBC_UPCA", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b33", "UCC128 (= EAN128)", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b34", "UPC A", TBARCODE | TBARCODEADV | TBARCODEADV | UPCACHECK ) );
codes.append( fillStruct( "b35", "UPC A - 2 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) );
codes.append( fillStruct( "b36", "UPC A - 5 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) );
codes.append( fillStruct( "b37", "UPC E", TBARCODE | TBARCODEADV | UPCECHECK ) );
codes.append( fillStruct( "b38", "UPC E - 2 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) );
codes.append( fillStruct( "b39", "UPC E - 5 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) );
codes.append( fillStruct( "b40", "PostNet ZIP (5d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b41", "PostNet ZIP (5d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b42", "PostNet ZIP (8d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b43", "PostNet ZIP+4 (5d.+4d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b44", "PostNet DPBC (5d.+4d.+2d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b45", "PostNet DPBC (5d.+4d.+2d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
codes.append( fillStruct( "b46", "Plessey Code", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b47", "MSI Code", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
codes.append( fillStruct( "b50", "LOGMARS", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b55", "PDF417 - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) );
codes.append( fillStruct( "b56", "PDF417 Truncated - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) );
codes.append( fillStruct( "b57", "MaxiCode - 2D-bar code (Postscript only)", TBARCODE | BARCODE2D ) );
codes.append( fillStruct( "b58", "QR-Code", TBARCODE | BARCODE2D ) );
codes.append( fillStruct( "b59", "Code128 (CharSet A)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
codes.append( fillStruct( "b60", "Code128 (CharSet B)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
codes.append( fillStruct( "b61", "Code128 (CharSet C)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
codes.append( fillStruct( "b62", "Code 93 Ascii", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
codes.append( fillStruct( "b63", "Australian Post Standard Customer", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b64", "Australian Post Customer 2", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b65", "Australian Post Customer 3", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b66", "Australian Post Reply Paid", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b67", "Australian Post Routing", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b68", "Australian Post Redirection", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b69", "ISBN Code (=EAN13P5)", TBARCODE | TBARCODEADV ) );
codes.append( fillStruct( "b70", "Royal Mail 4 State (RM4SCC)", TBARCODE | NOCUT | TBARCODEADV ) );
codes.append( fillStruct( "b71", "Data Matrix", DATAMATRIX | TBARCODE | BARCODE2D | NOSCALE ) );
}
}
}


+ 0
- 304
kbarcode/mybarcode.h View File

@@ -1,304 +0,0 @@
/***************************************************************************
mybarcode.h - description
-------------------
begin : Die Apr 23 2002
copyright : (C) 2002 by Dominik Seichter
email : domseichter@web.de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef MY_BARCODE_H
#define MY_BARCODE_H

#include <tqpixmap.h>
#include <tqobject.h>

#include <tqvaluelist.h>
#include "barkode.h"
void init();

typedef union u_settings {
struct {
int row;
int col;
int err;
} pdf417;

struct {
int size;
} datamatrix;

struct {
double modulewidth;
bool escape;
} tbarcode;
};

class TQColor;
class TQString;
typedef struct barcodeData {
TQString value;
TQString type;
int margin;
int rotation;
double scale;
double cut;
bool text;
bool valid;

struct _pdf417 {
int row;
int col;
int err;

bool operator==( const struct _pdf417 p ) const {
return row == p.row && col == p.col && err == p.err;
};
} pdf417;

struct _datamatrix {
int size;

bool operator==( const struct _datamatrix d ) const {
return size == d.size;
};
} datamatrix;

struct _tbarcode {
double modulewidth;
bool escape;
bool above;
bool autocorrect;
int checksum;

bool operator==( const struct _tbarcode t ) const {
return modulewidth == t.modulewidth && escape == t.escape && above == t.above && checksum == t.checksum && autocorrect == t.autocorrect;
};
} tbarcode;

struct {
// only important
// when this struct
// is read from XML
TQString caption;
int x;
int y;
} xml;

/**
* Compare to barcodeData structs,
* but only the fields which are used
* as commandline parameters for
* the genaration backends.
* E.g. margin is not compared, because
* the margin is created by KBarcode internally.
*/
bool operator==( const struct barcodeData d ) const;

struct {
bool enabled;
int mode;
int step;
int start;
} sequence;
};

#if 0
enum { NOCUT = 0x00001, MULTILINE = 0x00002, NOTEXT = 0x00004, NOSCALE = 0x00008,
/**
* The different Generator Backends
*/
GNU_BARCODE = 0x00010, PDF417 = 0x00020, TBARCODE = 0x00040,
/**
* Different advanced option modes.
*/
DATAMATRIX = 0x00080, PDF417BARCODE = 0x00100, TBARCODEADV = 0x00200,
/**
* Checksum ID's
*/
POSTNETCHECK = 0x01000, CODE128CHECK = 0x02000, EAN8CHECK = 0x04000, EAN13CHECK = 0x08000,
UPCACHECK = 0x10000, UPCECHECK = 0x20000, MODULOALLCHECK = 0x40000, MODULO10CHECK = 0x80000,
/**
* Short cut's
*/
BARCODE2D = NOCUT | MULTILINE | NOTEXT };
#endif

typedef struct barcodeFormat {
TQString name;
TQString text;
unsigned int features;
};

class TDEProcess;
class KTempFile;
class TQPaintDevice;
/**
* This class creates a TQPixmap from a barcodeData struct.
* Several backends are supported to generate the pixmap.
* GNU Barcode
* pdf417_enc
* TBarcode (http://www.tec-it.com)
*
* This tools generate a postscript file. The ps file is
* transformed to a PBM file scaled to the requested resolution
* or screen resolution using ghostscript.
*
* The generated barcodes are cached using BarcodeCache.
* To fill a barcodeData struct with data from the user, you
* might want to use BarcodeWidget.
*
* A small example, of how to generate a valid Barcode in your application
* without the use of BarcodeWidget:
* <pre>
* barcodeData data;
* BarCode::fillDefault( &data ); // setup a barcode object with valid data
* data.value = "KBARCODE";
* data.type = "code39";
* BarCode b( &data ); // create a barcode object
* TQPixmap p = b.pixmap(); // get a pixmap of the barcode
* </pre>
*
* @see BarcodeCache @see BarcodeWidget
* @author Dominik Seichter
*/
class BarCode {
public:
/** Create a BarCode object from the data const barcodeData* @p data.
* You may delete @p data afterwards. Be sure to call at least once
* BarCode::fillDefault() on @p data. Otherwise you rsik invalid barcode data.
*/
BarCode( const barcodeData* data );
/** Create a BarCode object filled with default data.
*/
BarCode();
~BarCode();

/** Get a TQPixmap of the current barcodeData in
* screen resolution-
*/
const TQPixmap pixmap();
/** Get a TQPixmap of the barcode in the same resolution as the
* TQPaintDevice* @p device. This is necessary if you want to print
* your barcodes, as they won't be scanable in screen resolution.
*/
const TQPixmap printerPixmap( TQPaintDevice* device );

/** Set the index of the barcodes for barcode sequences.
*/
void setIndex( int i ) { m_index = i; }
/** Change the barcodeData to @p d, call redraw() afterwards.
*/
void setData( barcodeData* d ) { barcode = *d; }
bool validBarcode() {return !p.isNull();}

barcodeData data() const { return barcode; }

TQString sequenceValue();

/** Fill @p barcodeData* data with its default parameters.
* Always call this function, after you have created a new
* barcodeData struct.
*/
static void fillDefault( barcodeData* data );

/** Test if the encodingType @p type has a certain
* @p feature, as defined in the codes TQValueList.
*/
static bool hasFeature( const TQString & type, unsigned int feature );

/** get the meximum length of value for the encoding type @p name
* from the SQL databases.
*/
static const TQString getMaxLength( const TQString & name );

/** This function has to be called befor barcode support is avaible.
* It searches for the barcode generation backends
* (gnu barcode, tbarcode and pdf417) and fills the TQValueList codes
* with data and information about the avaible barcode encoding types.
* You only have to call this function once.
* The results can be retrieved with the following functions:
* @see haveBarcode()
* @see haveTBarcode()
* @see havePDFBarcode()
*/
static void setHaveBarcode();
static bool haveBarcode() {
return ( m_haveGnuBarcode || m_havePdfEncode || m_haveTBarcode );
}
static bool haveGNUBarcode() {
return m_haveGnuBarcode;
}
static bool haveTBarcode() {
return m_haveTBarcode;
}
static bool havePDFBarcode() {
return m_havePdfEncode;
}

/** call this, always after you changed the barcodeData using setData,
* so that the pixmaps are recreated.
*/
void redrawBarcode();
private:
bool createPixmap( TQPixmap* target, int resx, int resy );
void createBarcode( TQPixmap* target, TQPaintDevice* device );
bool createPdf417( KTempFile* output );
bool crea