diff --git a/glabels/BarcodeBackends.cpp b/glabels/BarcodeBackends.cpp index aef97b0..7c615c0 100644 --- a/glabels/BarcodeBackends.cpp +++ b/glabels/BarcodeBackends.cpp @@ -75,7 +75,7 @@ namespace glabels #if HAVE_GNU_BARCODE // - // Libqrencode backend + // GNU Barcode backend // registerBackend( "gnu-barcode", "GNU Barcode" ); @@ -86,6 +86,24 @@ namespace glabels glbarcode::Factory::registerType( "gnu-barcode::ean-13", GnuBarcode::Ean13::create ); glbarcode::Factory::registerType( "gnu-barcode::ean-13+2", GnuBarcode::Ean13_2::create ); glbarcode::Factory::registerType( "gnu-barcode::ean-13+5", GnuBarcode::Ean13_5::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc", GnuBarcode::Upc::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-a", GnuBarcode::UpcA::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-a+2", GnuBarcode::UpcA_2::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-a+5", GnuBarcode::UpcA_5::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-e", GnuBarcode::UpcE::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-e+2", GnuBarcode::UpcE_2::create ); + glbarcode::Factory::registerType( "gnu-barcode::upc-e+5", GnuBarcode::UpcE_5::create ); + glbarcode::Factory::registerType( "gnu-barcode::isbn", GnuBarcode::Isbn::create ); + glbarcode::Factory::registerType( "gnu-barcode::isbn+5", GnuBarcode::Isbn_5::create ); + glbarcode::Factory::registerType( "gnu-barcode::code39", GnuBarcode::Code39::create ); + glbarcode::Factory::registerType( "gnu-barcode::code128", GnuBarcode::Code128::create ); + glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create ); + glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create ); + glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create ); + glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create ); + glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create ); + glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create ); + glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::create ); registerStyle( "ean", "gnu-barcode", tr("EAN (any)"), true, true, true, false, "000000000000 00000", false, 17 ); @@ -101,6 +119,42 @@ namespace glabels true, true, true, false, "000000000000 00", false, 14 ); registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"), true, true, true, false, "000000000000 00000", false, 17 ); + registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"), + true, true, true, false, "00000000000 00000", false, 16 ); + registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"), + true, true, true, false, "00000000000", false, 11 ); + registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"), + true, true, true, false, "00000000000 00", false, 13 ); + registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"), + true, true, true, false, "00000000000 00000", false, 16 ); + registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"), + true, true, true, false, "000000", false, 6 ); + registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"), + true, true, true, false, "000000 00", false, 8 ); + registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"), + true, true, true, false, "000000 00000", false, 11 ); + registerStyle( "isbn", "gnu-barcode", tr("ISBN"), + true, true, true, true, "0-00000-000-0", false, 10 ); + registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"), + true, true, true, true, "0-00000-000-0 00000", false, 15 ); + registerStyle( "code39", "gnu-barcode", tr("Code 39"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "code128", "gnu-barcode", tr("Code 128"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "code128c", "gnu-barcode", tr("Code 128C"), + true, true, true, false, "0000000000", true, 10 ); + registerStyle( "code128b", "gnu-barcode", tr("Code 128B"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "cbr", "gnu-barcode", tr("Codabar"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "msi", "gnu-barcode", tr("MSI"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "pls", "gnu-barcode", tr("Plessey"), + true, true, true, true, "0000000000", true, 10 ); + registerStyle( "code93", "gnu-barcode", tr("Code 93"), + true, true, true, false, "0000000000", true, 10 ); #endif // HAVE_GNU_BARCODE #if HAVE_QRENCODE diff --git a/glabels/BarcodeBackends/GnuBarcode.cpp b/glabels/BarcodeBackends/GnuBarcode.cpp index 1df12fc..94260d7 100644 --- a/glabels/BarcodeBackends/GnuBarcode.cpp +++ b/glabels/BarcodeBackends/GnuBarcode.cpp @@ -61,14 +61,10 @@ namespace glabels for ( unsigned int i = 0; i < data.size(); i++ ) { - if ( (data[i] & 0x80) == 0 ) + if ( isdigit(data[i]) ) { n++; } - else - { - return false; - } } return (n >= nMin) && (n <= nMax); @@ -344,6 +340,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN Barcode (Any) + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean::create() { return new Ean(); @@ -368,6 +367,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-8 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean8::create() { return new Ean8(); @@ -387,6 +389,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-8+2 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean8_2::create() { return new Ean8_2(); @@ -406,6 +411,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-8+5 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean8_5::create() { return new Ean8_5(); @@ -425,6 +433,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-13 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean13::create() { return new Ean13(); @@ -444,6 +455,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-13+2 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean13_2::create() { return new Ean13_2(); @@ -463,6 +477,9 @@ namespace glabels } + ////////////////////////////////////////////////////// + // EAN-13+5 Barcode + ////////////////////////////////////////////////////// glbarcode::Barcode* Ean13_5::create() { return new Ean13_5(); @@ -482,6 +499,407 @@ namespace glabels } + ////////////////////////////////////////////////////// + // UPC Barcode (Any) + ////////////////////////////////////////////////////// + glbarcode::Barcode* Upc::create() + { + return new Upc(); + } + + + bool Upc::validate( const std::string& rawData ) + { + return isNumericLengthValid( rawData, 6, 8 ) + || isNumericLengthValid( rawData, 11, 12 ) + || (isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 2, 2 )) + || (isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 5, 5 )) + || (isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 2, 2 )) + || (isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 5, 5 )); + } + + + std::string Upc::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-A Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcA::create() + { + return new UpcA(); + } + + + bool UpcA::validate( const std::string& rawData ) + { + return isNumericLengthValid( rawData, 11, 12 ); + } + + + std::string UpcA::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-A+2 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcA_2::create() + { + return new UpcA_2(); + } + + + bool UpcA_2::validate( const std::string& rawData ) + { + return isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 2, 2 ); + } + + + std::string UpcA_2::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-A+5 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcA_5::create() + { + return new UpcA_5(); + } + + + bool UpcA_5::validate( const std::string& rawData ) + { + return isNumericLength1Valid( rawData, 11, 12 ) && isNumericLength2Valid( rawData, 5, 5 ); + } + + + std::string UpcA_5::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-E Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcE::create() + { + return new UpcE(); + } + + + bool UpcE::validate( const std::string& rawData ) + { + return isNumericLengthValid( rawData, 6, 8 ); + } + + + std::string UpcE::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-E+2 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcE_2::create() + { + return new UpcE_2(); + } + + + bool UpcE_2::validate( const std::string& rawData ) + { + return isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 2, 2 ); + } + + + std::string UpcE_2::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // UPC-E+5 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* UpcE_5::create() + { + return new UpcE_5(); + } + + + bool UpcE_5::validate( const std::string& rawData ) + { + return isNumericLength1Valid( rawData, 6, 8 ) && isNumericLength2Valid( rawData, 5, 5 ); + } + + + std::string UpcE_5::encode( const std::string& cookedData ) + { + flags = BARCODE_UPC; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // ISBN Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Isbn::create() + { + return new Isbn(); + } + + + bool Isbn::validate( const std::string& rawData ) + { + return isNumericLengthValid( rawData, 9, 10 ); + } + + + std::string Isbn::encode( const std::string& cookedData ) + { + flags = BARCODE_ISBN; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // ISBN+5 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Isbn_5::create() + { + return new Isbn_5(); + } + + + bool Isbn_5::validate( const std::string& rawData ) + { + return isNumericLength1Valid( rawData, 9, 10 ) && isNumericLength2Valid( rawData, 5, 5 ); + } + + + std::string Isbn_5::encode( const std::string& cookedData ) + { + flags = BARCODE_ISBN; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // Code39 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Code39::create() + { + return new Code39(); + } + + + bool Code39::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Code39::encode( const std::string& cookedData ) + { + flags = BARCODE_39; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // Code128 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Code128::create() + { + return new Code128(); + } + + + bool Code128::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Code128::encode( const std::string& cookedData ) + { + flags = BARCODE_128; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // Code128C Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Code128C::create() + { + return new Code128C(); + } + + + bool Code128C::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Code128C::encode( const std::string& cookedData ) + { + flags = BARCODE_128C; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // Code128B Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Code128B::create() + { + return new Code128B(); + } + + + bool Code128B::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Code128B::encode( const std::string& cookedData ) + { + flags = BARCODE_128B; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // I25 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* I25::create() + { + return new I25(); + } + + + bool I25::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string I25::encode( const std::string& cookedData ) + { + flags = BARCODE_I25; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // CBR Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Cbr::create() + { + return new Cbr(); + } + + + bool Cbr::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Cbr::encode( const std::string& cookedData ) + { + flags = BARCODE_CBR; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // MSI Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Msi::create() + { + return new Msi(); + } + + + bool Msi::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Msi::encode( const std::string& cookedData ) + { + flags = BARCODE_MSI; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // PLS Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Pls::create() + { + return new Pls(); + } + + + bool Pls::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Pls::encode( const std::string& cookedData ) + { + flags = BARCODE_PLS; + return ""; // Actual encoding is done in vectorize + } + + + ////////////////////////////////////////////////////// + // Code93 Barcode + ////////////////////////////////////////////////////// + glbarcode::Barcode* Code93::create() + { + return new Code93(); + } + + + bool Code93::validate( const std::string& rawData ) + { + return isAscii( rawData ); + } + + + std::string Code93::encode( const std::string& cookedData ) + { + flags = BARCODE_93; + return ""; // Actual encoding is done in vectorize + } + + } } diff --git a/glabels/BarcodeBackends/GnuBarcode.h b/glabels/BarcodeBackends/GnuBarcode.h index b92e5ad..649a9de 100644 --- a/glabels/BarcodeBackends/GnuBarcode.h +++ b/glabels/BarcodeBackends/GnuBarcode.h @@ -160,6 +160,258 @@ namespace glabels std::string encode( const std::string& cookedData ) override; }; + + /** + * UPC Barcode (Any) + */ + class Upc : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-A Barcode + */ + class UpcA : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-A+2 Barcode + */ + class UpcA_2 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-A+5 Barcode + */ + class UpcA_5 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-E Barcode + */ + class UpcE : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-E+2 Barcode + */ + class UpcE_2 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * UPC-E+5 Barcode + */ + class UpcE_5 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * ISBN Barcode + */ + class Isbn : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * ISBN+5 Barcode + */ + class Isbn_5 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * Code39 Barcode + */ + class Code39 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * Code128 Barcode + */ + class Code128 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * Code128C Barcode + */ + class Code128C : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * Code128B Barcode + */ + class Code128B : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * I25 Barcode + */ + class I25 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * CBR Barcode + */ + class Cbr : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * MSI Barcode + */ + class Msi : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * PLS Barcode + */ + class Pls : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + + + /** + * Code93 Barcode + */ + class Code93 : public Base + { + public: + static Barcode* create(); + + protected: + bool validate( const std::string& rawData ) override; + std::string encode( const std::string& cookedData ) override; + }; + } } diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 35844c4..2f04cd6 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -779,42 +779,123 @@ - + EAN (any) - + EAN-8 - + EAN-8+2 - + EAN-8+5 - + EAN-13+2 - + EAN-13+5 - + + UPC (UPC-A or UPC-E) + + + + + UPC-A +2 + + + + + UPC-A +5 + + + + + UPC-E + + + + + UPC-E +2 + + + + + UPC-E +5 + + + + + ISBN + + + + + ISBN +5 + + + + + Code 128 + + + + + Code 128C + + + + + Code 128B + + + + + Interleaved 2 of 5 + + + + + Codabar + + + + + MSI + + + + + Plessey + + + + + Code 93 + + + + IEC18004 (QRCode) + Code 39 @@ -825,12 +906,13 @@ + UPC-A - + EAN-13