Integrate contribution from TrekGlobal - developed by Heng Sin Low and Elaine Tan

1007781 Fix barcode text bug
1009003 add QR Code as Barcode Type for Print Formats
1006829 Add "Print Barcode Text" flag to print format item. Fix wrong scaling for barcode image. Fix barcode print format item doesn't respect max height.
IDEMPIERE-3948 Implement QRCode support in report engine
IDEMPIERE-1854 Barcode issue: Code Missing from barcodes in Code 128 B
IDEMPIERE-1838 Adding UPC-A barcode support in print format and adding setting fonts from print format item
This commit is contained in:
Carlos Ruiz 2019-04-10 17:57:08 +02:00
parent 18ec16c2fb
commit d28c1e682d
19 changed files with 1142 additions and 27 deletions

View File

@ -0,0 +1,170 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Nov 29, 2016 2:52:01 PM GMT+08:00
-- 1006829 - Create product label
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203058,'IsPrintBarcodeText',TO_DATE('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),'Print Barcode Text','Print barcode text at the bottom of barcode','Print Barcode Text','ef298ad1-4d63-44eb-bf6f-c38f442bda1f','Y',TO_DATE('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'U')
;
-- Nov 29, 2016 2:53:24 PM GMT+08:00
UPDATE AD_Element SET EntityType='D',Updated=TO_DATE('2016-11-29 14:53:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203058
;
-- Nov 29, 2016 2:53:57 PM GMT+08:00
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (212946,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','bbe56dbf-97c7-4705-96be-5fc434f1c6c1',TO_DATE('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintBarcodeText','Print barcode text at the bottom of barcode','Y','Print Barcode Text','Y','Y',100,100,'N','N',0,0,TO_DATE('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203058,20,489)
;
-- Nov 29, 2016 2:54:06 PM GMT+08:00
ALTER TABLE AD_PrintFormatItem ADD IsPrintBarcodeText CHAR(1) DEFAULT 'Y' CHECK (IsPrintBarcodeText IN ('Y','N')) NOT NULL
;
-- Nov 29, 2016 2:57:37 PM GMT+08:00
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,204351,'N',0,'N','N',560,'Y','N','@PrintFormatType@=F & @BarcodeType@!''''',0,TO_DATE('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),'Print barcode text at the bottom of barcode','Print Barcode Text','0bc427e5-7aae-498a-8a27-d6fe946cdaf5','Y','N',100,100,'Y','Y',560,1,'N',0,TO_DATE('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',212946,'D',426)
;
-- Nov 29, 2016 2:58:35 PM GMT+08:00
UPDATE AD_Field SET SeqNo=220, IsDisplayed='Y', XPosition=2,Updated=TO_DATE('2016-11-29 14:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204351
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=230,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5677
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=240,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5761
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=250,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5690
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=260,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5681
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=270,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5669
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=280,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5804
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=290,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5763
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=300,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5695
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=310,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5691
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=320,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5685
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=330,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5673
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=340,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5678
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=350,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5805
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=360,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11023
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=370,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5689
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=380,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5688
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=390,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11021
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=400,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5682
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=410,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5686
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=420,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11020
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=430,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5693
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=440,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5674
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=450,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200001
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=460,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5694
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=470,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5676
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=480,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5680
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=490,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8294
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=500,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5757
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=510,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8293
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=520,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8295
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=530,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8292
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=540,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5758
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=550,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8604
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=560,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8605
;
UPDATE AD_PrintFormatItem SET IsPrintBarcodeText='N' WHERE BarcodeType='USP'
;
SELECT register_migration_script('201611301200_Ticket_1006829.sql') FROM dual
;

View File

@ -0,0 +1,14 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- May 23, 2017 6:42:29 PM SGT
-- 1007781 Fix barcode text bug
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200374,'af593ade-94ff-47bf-9b4e-a60c278d3541','Code 39 with Checksum','39C','Y',100,100,0,0,TO_DATE('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),'D',377)
;
-- May 23, 2017 6:42:30 PM SGT
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200375,'918c6018-41f7-40ba-965b-65512ec99808','Code 39 w/o Checksum','39c','Y',100,100,0,0,TO_DATE('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),'D',377)
;
SELECT register_migration_script('201705231845_Ticket_1007781.sql') FROM dual
;

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- May 17, 2018 12:24:17 PM SGT
-- 1009003 add QR Code as Barcode Type for Print Formats
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,CreatedBy,UpdatedBy,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200396,TO_DATE('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),'D',0,0,100,100,'QRC','QR Code','Y','702f344c-557a-4a34-aaae-578cb1b2d137',377)
;
SELECT register_migration_script('201805221235_Ticket_1009003.sql') FROM dual
;

View File

@ -0,0 +1,167 @@
-- Nov 29, 2016 2:52:01 PM GMT+08:00
-- 1006829 - Create product label
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203058,'IsPrintBarcodeText',TO_TIMESTAMP('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),'Print Barcode Text','Print barcode text at the bottom of barcode','Print Barcode Text','ef298ad1-4d63-44eb-bf6f-c38f442bda1f','Y',TO_TIMESTAMP('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'U')
;
-- Nov 29, 2016 2:53:24 PM GMT+08:00
UPDATE AD_Element SET EntityType='D',Updated=TO_TIMESTAMP('2016-11-29 14:53:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203058
;
-- Nov 29, 2016 2:53:57 PM GMT+08:00
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (212946,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','bbe56dbf-97c7-4705-96be-5fc434f1c6c1',TO_TIMESTAMP('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintBarcodeText','Print barcode text at the bottom of barcode','Y','Print Barcode Text','Y','Y',100,100,'N','N',0,0,TO_TIMESTAMP('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203058,20,489)
;
-- Nov 29, 2016 2:54:06 PM GMT+08:00
ALTER TABLE AD_PrintFormatItem ADD COLUMN IsPrintBarcodeText CHAR(1) DEFAULT 'Y' CHECK (IsPrintBarcodeText IN ('Y','N')) NOT NULL
;
-- Nov 29, 2016 2:57:37 PM GMT+08:00
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,204351,'N',0,'N','N',560,'Y','N','@PrintFormatType@=F & @BarcodeType@!''''',0,TO_TIMESTAMP('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),'Print barcode text at the bottom of barcode','Print Barcode Text','0bc427e5-7aae-498a-8a27-d6fe946cdaf5','Y','N',100,100,'Y','Y',560,1,'N',0,TO_TIMESTAMP('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',212946,'D',426)
;
-- Nov 29, 2016 2:58:35 PM GMT+08:00
UPDATE AD_Field SET SeqNo=220, IsDisplayed='Y', XPosition=2,Updated=TO_TIMESTAMP('2016-11-29 14:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204351
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5677
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5761
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5690
;
-- Nov 29, 2016 2:58:36 PM GMT+08:00
UPDATE AD_Field SET SeqNo=260,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5681
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=270,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5669
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=280,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5804
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=290,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5763
;
-- Nov 29, 2016 2:58:37 PM GMT+08:00
UPDATE AD_Field SET SeqNo=300,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5695
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=310,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5691
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=320,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5685
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=330,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5673
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=340,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5678
;
-- Nov 29, 2016 2:58:38 PM GMT+08:00
UPDATE AD_Field SET SeqNo=350,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5805
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=360,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11023
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=370,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5689
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=380,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5688
;
-- Nov 29, 2016 2:58:39 PM GMT+08:00
UPDATE AD_Field SET SeqNo=390,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11021
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=400,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5682
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=410,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5686
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=420,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11020
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=430,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5693
;
-- Nov 29, 2016 2:58:40 PM GMT+08:00
UPDATE AD_Field SET SeqNo=440,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5674
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=450,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200001
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=460,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5694
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=470,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5676
;
-- Nov 29, 2016 2:58:41 PM GMT+08:00
UPDATE AD_Field SET SeqNo=480,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5680
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=490,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8294
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=500,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5757
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=510,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8293
;
-- Nov 29, 2016 2:58:42 PM GMT+08:00
UPDATE AD_Field SET SeqNo=520,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8295
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=530,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8292
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=540,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5758
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=550,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8604
;
-- Nov 29, 2016 2:58:43 PM GMT+08:00
UPDATE AD_Field SET SeqNo=560,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8605
;
UPDATE AD_PrintFormatItem SET IsPrintBarcodeText='N' WHERE BarcodeType='USP'
;
SELECT register_migration_script('201611301200_Ticket_1006829.sql') FROM dual
;

View File

@ -0,0 +1,11 @@
-- May 23, 2017 6:42:29 PM SGT
-- 1007781 Fix barcode text bug
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200374,'af593ade-94ff-47bf-9b4e-a60c278d3541','Code 39 with Checksum','39C','Y',100,100,0,0,TO_TIMESTAMP('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),'D',377)
;
-- May 23, 2017 6:42:30 PM SGT
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200375,'918c6018-41f7-40ba-965b-65512ec99808','Code 39 w/o Checksum','39c','Y',100,100,0,0,TO_TIMESTAMP('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),'D',377)
;
SELECT register_migration_script('201705231845_Ticket_1007781.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- May 17, 2018 12:24:17 PM SGT
-- 1009003 add QR Code as Barcode Type for Print Formats
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,CreatedBy,UpdatedBy,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200396,TO_TIMESTAMP('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),'D',0,0,100,100,'QRC','QR Code','Y','702f344c-557a-4a34-aaae-578cb1b2d137',377)
;
SELECT register_migration_script('201805221235_Ticket_1009003.sql') FROM dual
;

View File

@ -6,12 +6,13 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src/"/>
<classpathentry exported="true" kind="lib" path="lib/bsh.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-validator.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cron4j.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jnlp.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jython-engine.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jython.jar"/>
<classpathentry exported="true" kind="lib" path="lib/avalon-framework-api.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -9,7 +9,8 @@ Bundle-ClassPath: .,
lib/cron4j.jar,
lib/jnlp.jar,
lib/jython-engine.jar,
lib/jython.jar
lib/jython.jar,
lib/avalon-framework-api.jar
Export-Package: bsh,
bsh.classpath,
bsh.collection,
@ -58,7 +59,10 @@ Export-Package: bsh,
org.idempiere.model
Comment: Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.11))"
Import-Package: com.sun.mail.smtp;version="1.5",
Import-Package: com.google.zxing,
com.google.zxing.qrcode.decoder,
com.google.zxing.qrcode.encoder,
com.sun.mail.smtp;version="1.5",
javax.jms;version="1.1.0",
javax.mail;version="1.5",
javax.mail.internet;version="1.5",

View File

@ -20,6 +20,7 @@ bin.includes = plugin.xml,\
schema/,\
.,\
META-INF/,\
lib/avalon-framework-api.jar,\
lib/bsh.jar,\
lib/commons-validator.jar,\
lib/cron4j.jar,\

View File

@ -53,6 +53,11 @@
<artifactId>jnlp</artifactId>
<version>1.5.0</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.3.1</version>
</artifactItem>
</artifactItems>
<outputDirectory>lib</outputDirectory>
<stripVersion>true</stripVersion>

View File

@ -502,6 +502,19 @@ public interface I_AD_PrintFormatItem
*/
public boolean isPageBreak();
/** Column name IsPrintBarcodeText */
public static final String COLUMNNAME_IsPrintBarcodeText = "IsPrintBarcodeText";
/** Set Print Barcode Text.
* Print barcode text at the bottom of barcode
*/
public void setIsPrintBarcodeText (boolean IsPrintBarcodeText);
/** Get Print Barcode Text.
* Print barcode text at the bottom of barcode
*/
public boolean isPrintBarcodeText();
/** Column name IsPrinted */
public static final String COLUMNNAME_IsPrinted = "IsPrinted";

View File

@ -30,7 +30,7 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
/**
*
*/
private static final long serialVersionUID = 20190106L;
private static final long serialVersionUID = 20190403L;
/** Standard Constructor */
public X_AD_PrintFormatItem (Properties ctx, int AD_PrintFormatItem_ID, String trxName)
@ -64,6 +64,8 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
setIsNextPage (false);
setIsOrderBy (false);
setIsPageBreak (false);
setIsPrintBarcodeText (true);
// Y
setIsPrinted (true);
// Y
setIsRelativePosition (true);
@ -399,6 +401,12 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
public static final String BARCODETYPE_EAN13 = "E13";
/** UPC-A = UPA */
public static final String BARCODETYPE_UPC_A = "UPA";
/** Code 39 with Checksum = 39C */
public static final String BARCODETYPE_Code39WithChecksum = "39C";
/** Code 39 w/o Checksum = 39c */
public static final String BARCODETYPE_Code39WOChecksum = "39c";
/** QR Code = QRC */
public static final String BARCODETYPE_QRCode = "QRC";
/** Set Barcode Type.
@param BarcodeType
Type of barcode
@ -909,6 +917,30 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
return false;
}
/** Set Print Barcode Text.
@param IsPrintBarcodeText
Print barcode text at the bottom of barcode
*/
public void setIsPrintBarcodeText (boolean IsPrintBarcodeText)
{
set_Value (COLUMNNAME_IsPrintBarcodeText, Boolean.valueOf(IsPrintBarcodeText));
}
/** Get Print Barcode Text.
@return Print barcode text at the bottom of barcode
*/
public boolean isPrintBarcodeText ()
{
Object oo = get_Value(COLUMNNAME_IsPrintBarcodeText);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Printed.
@param IsPrinted
Indicates if this document / line is printed

View File

@ -22,19 +22,22 @@ import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.util.Properties;
import net.sourceforge.barbecue.Barcode;
import net.sourceforge.barbecue.BarcodeFactory;
import net.sourceforge.barbecue.BarcodeImageHandler;
import net.sourceforge.barbecue.linear.ean.UCCEAN128Barcode;
import org.compiere.print.MPrintFont;
import org.compiere.print.MPrintFormatItem;
import org.krysalis.barcode4j.BarcodeDimension;
import org.krysalis.barcode4j.ChecksumMode;
import org.krysalis.barcode4j.HumanReadablePlacement;
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.impl.qr.QRCodeBean;
import org.krysalis.barcode4j.impl.upcean.UPCABean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import net.sourceforge.barbecue.Barcode;
import net.sourceforge.barbecue.BarcodeFactory;
import net.sourceforge.barbecue.BarcodeImageHandler;
import net.sourceforge.barbecue.linear.ean.UCCEAN128Barcode;
/**
* Barcode Print Element
*
@ -49,7 +52,12 @@ public class BarcodeElement extends PrintElement
/**
*
*/
private static final long serialVersionUID = -935853466496345172L;
private static final long serialVersionUID = -6825913765885213717L;
/**
*
*/
/**
* Barcode Element Constructor
@ -65,7 +73,7 @@ public class BarcodeElement extends PrintElement
m_valid = false;
createBarcode(code, item);
if (m_barcode == null && m_upc == null)
if (m_barcode == null && m_barcodeBean == null)
m_valid = false;
m_allowOverflow = item.isHeightOneLine(); // teo_sarca, [ 1673590 ]
} // BarcodeElement
@ -78,7 +86,7 @@ public class BarcodeElement extends PrintElement
private boolean m_allowOverflow = true;
private float m_scaleFactor = 1;
private UPCABean m_upc = null;
private AbstractBarcodeBean m_barcodeBean = null;
private String m_code;
/**
@ -139,17 +147,48 @@ public class BarcodeElement extends PrintElement
m_barcode = BarcodeFactory.createUCC128(UCCEAN128Barcode.EAN128_AI, code);
else if (type.equals(MPrintFormatItem.BARCODETYPE_EAN13)) //@Trifon
m_barcode = BarcodeFactory.createEAN13(code); //@Trifon
else if (type.equals(MPrintFormatItem.BARCODETYPE_UPC_A )) {
m_upc = new UPCABean();
m_upc.setChecksumMode(ChecksumMode.CP_AUTO);
m_upc.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
else if (type.equals(MPrintFormatItem.BARCODETYPE_UPC_A)) {
m_barcodeBean = new UPCABean();
((UPCABean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_AUTO);
if (item.isPrintBarcodeText())
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
else
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
m_code = code;
}
else if (type.equals(MPrintFormatItem.BARCODETYPE_Code39WithChecksum))
{
m_barcodeBean = new Code39Bean();
((Code39Bean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_AUTO);
if (item.isPrintBarcodeText())
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
else
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
m_code = code;
}
else if (type.equals(MPrintFormatItem.BARCODETYPE_Code39WOChecksum))
{
m_barcodeBean = new Code39Bean();
((Code39Bean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_IGNORE);
if (item.isPrintBarcodeText())
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
else
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
m_code = code;
}
// http://www.usps.com/cpim/ftp/pubs/pub97/97apxs_006.html#_Toc481397331
else if (type.equals(MPrintFormatItem.BARCODETYPE_USPostalServiceUCCEAN128))
{
m_barcode = BarcodeFactory.createUSPS(code);
m_barcode.setDrawingText(false);
}
else if (type.equals(MPrintFormatItem.BARCODETYPE_QRCode))
{
m_barcodeBean = new QRCodeBean();
if (item.isPrintBarcodeText())
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
else
m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
m_code = code;
}
else
log.warning("Invalid Type" + type);
@ -168,6 +207,7 @@ public class BarcodeElement extends PrintElement
if (mFont != null)
m_barcode.setFont(mFont.getFont());
}
m_barcode.setDrawingText(item.isPrintBarcodeText());
}
} // createBarcode
@ -189,7 +229,7 @@ public class BarcodeElement extends PrintElement
{
p_width = 0;
p_height = 0;
if (m_barcode == null && m_upc == null)
if (m_barcode == null && m_barcodeBean == null)
return true;
if (m_barcode != null)
@ -205,14 +245,14 @@ public class BarcodeElement extends PrintElement
}
else
{
BarcodeDimension t = m_upc.calcDimensions(m_code);
BarcodeDimension t = m_barcodeBean.calcDimensions(m_code);
//convert from mm to point/inch
p_width = (float) (t.getWidthPlusQuiet() / 25.4f * 72f);
p_height = (float) (t.getHeight() / 25.4f * 72f);
// * 3 for resolution of 216 dpi ( 72 * 3 )
p_width *= 3f;
p_height *=3f;
// * 6 for resolution of 432 dpi ( 72 * 6 )
p_width *= 6f;
p_height *= 6f;
}
if (p_width * p_height == 0)
@ -223,6 +263,8 @@ public class BarcodeElement extends PrintElement
m_scaleFactor = p_maxWidth / p_width;
if (p_maxHeight != 0 && p_height > p_maxHeight && p_maxHeight/p_height < m_scaleFactor)
m_scaleFactor = p_maxHeight / p_height;
else if (p_maxHeight != 0 && (m_scaleFactor * p_height) > p_maxHeight)
m_scaleFactor = p_maxHeight / p_height;
p_width = (float) m_scaleFactor * p_width;
p_height = (float) m_scaleFactor * p_height;
@ -255,7 +297,7 @@ public class BarcodeElement extends PrintElement
public void paint (Graphics2D g2D, int pageNo, Point2D pageStart,
Properties ctx, boolean isView)
{
if (!m_valid || (m_barcode == null && m_upc == null ))
if (!m_valid || (m_barcode == null && m_barcodeBean == null ))
return;
// Position
@ -283,9 +325,9 @@ public class BarcodeElement extends PrintElement
}
else
{
//use resolution of 216 dpi (72 * 3) for better output
BitmapCanvasProvider provider = new BitmapCanvasProvider(72*3, BufferedImage.TYPE_INT_ARGB, true, 0);
m_upc.generateBarcode(provider, m_code);
//use resolution of 432 dpi (72 * 6) for better output
BitmapCanvasProvider provider = new BitmapCanvasProvider(72*6, BufferedImage.TYPE_INT_ARGB, true, 0);
m_barcodeBean.generateBarcode(provider, m_code);
provider.finish();
image = provider.getBufferedImage();
}
@ -293,7 +335,8 @@ public class BarcodeElement extends PrintElement
// scale barcode and paint
AffineTransform transform = new AffineTransform();
transform.translate(x,y);
transform.scale(m_scaleFactor, m_scaleFactor);
float scaleFactor = m_scaleFactor * 3f / 4f;
transform.scale(scaleFactor, scaleFactor);
g2D.drawImage(image, transform, this);
} catch (Exception e) {

View File

@ -0,0 +1,97 @@
/*
* Copyright 2012 Jeremias Maerki.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: QRCode.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */
package org.krysalis.barcode4j.impl.qr;
import java.awt.Dimension;
import org.krysalis.barcode4j.impl.ConfigurableBarcodeGenerator;
import org.krysalis.barcode4j.tools.Length;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
/**
* This class is an implementation of QR Code.
*
* @version $Id: QRCode.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $
*/
public class QRCode extends ConfigurableBarcodeGenerator
implements Configurable {
/** Create a new instance. */
public QRCode() {
this.bean = new QRCodeBean();
}
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
public void configure(Configuration cfg) throws ConfigurationException {
//Module width (MUST ALWAYS BE FIRST BECAUSE QUIET ZONE MAY DEPEND ON IT)
String mws = cfg.getChild("module-width").getValue(null);
if (mws != null) {
Length mw = new Length(mws, "mm");
getQRBean().setModuleWidth(mw.getValueAsMillimeter());
}
super.configure(cfg);
String encoding = cfg.getChild("encoding").getValue(null);
if (encoding != null) {
getQRBean().setEncoding(encoding);
}
String ecLevel = cfg.getChild("ec-level").getValue(null);
if (ecLevel != null && ecLevel.length() > 0) {
getQRBean().setErrorCorrectionLevel(ecLevel.charAt(0));
}
String size;
size = cfg.getChild("min-symbol-size").getValue(null);
if (size != null) {
getQRBean().setMinSize(parseSymbolSize(size));
}
size = cfg.getChild("max-symbol-size").getValue(null);
if (size != null) {
getQRBean().setMaxSize(parseSymbolSize(size));
}
}
private Dimension parseSymbolSize(String size) {
int idx = size.indexOf('x');
Dimension dim;
if (idx > 0) {
dim = new Dimension(Integer.parseInt(size.substring(0, idx)),
Integer.parseInt(size.substring(idx + 1)));
} else {
int extent = Integer.parseInt(size);
dim = new Dimension(extent, extent);
}
return dim;
}
/**
* @return the underlying DataMatrix bean
*/
public QRCodeBean getQRBean() {
return (QRCodeBean)getBean();
}
}

View File

@ -0,0 +1,229 @@
/*
* Copyright 2012 Jeremias Maerki.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: QRCodeBean.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ */
package org.krysalis.barcode4j.impl.qr;
import java.awt.Dimension;
import org.krysalis.barcode4j.BarcodeDimension;
import org.krysalis.barcode4j.TwoDimBarcodeLogicHandler;
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
import org.krysalis.barcode4j.impl.DefaultTwoDimCanvasLogicHandler;
import org.krysalis.barcode4j.output.Canvas;
import org.krysalis.barcode4j.output.CanvasProvider;
import org.krysalis.barcode4j.tools.ECIUtil;
import org.krysalis.barcode4j.tools.UnitConv;
import com.google.zxing.WriterException;
import com.google.zxing.qrcode.encoder.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
/**
* This class is an implementation of QR Code (ISO 18004:2006(E)).
*
* @version $Id: QRCodeBean.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $
*/
public class QRCodeBean extends AbstractBarcodeBean {
/** The default module width (dot size) for DataMatrix. */
protected static final double DEFAULT_MODULE_WIDTH = UnitConv.in2mm(1.0 / 72); //1px at 72dpi
/** Error correction level */
private char errorCorrectionLevel = QRConstants.ERROR_CORRECTION_LEVEL_L;
/** Message encoding */
private String encoding = "ISO-8859-1"; //ECI 000003
/** Optional: the minimum size of the symbol. */
private Dimension minSize;
/** Optional: the maximum size of the symbol. */
private Dimension maxSize;
/** Create a new instance. */
public QRCodeBean() {
this.height = 0.0; //not used by DataMatrix
this.moduleWidth = DEFAULT_MODULE_WIDTH;
setQuietZone(QRConstants.QUIET_ZONE_SIZE * moduleWidth);
}
/**
* Sets the error correction level.
* @param level the error correction level (one of L, M, Q and H)
*/
public void setErrorCorrectionLevel(char level) {
switch (level) {
case QRConstants.ERROR_CORRECTION_LEVEL_L:
case QRConstants.ERROR_CORRECTION_LEVEL_M:
case QRConstants.ERROR_CORRECTION_LEVEL_Q:
case QRConstants.ERROR_CORRECTION_LEVEL_H:
this.errorCorrectionLevel = level;
break;
default:
throw new IllegalArgumentException(
"Invalid error correction level. Valid levels are: L, M, Q and H");
}
}
/**
* Returns the selected error correction level.
* @return the error correction level (one of L, M, Q and H)
*/
public char getErrorCorrectionLevel() {
return this.errorCorrectionLevel;
}
/**
* Sets the message encoding. The value must conform to one of Java's encodings and
* have a mapping in the ECI registry.
* @param encoding the message encoding
*/
public void setEncoding(String encoding) {
if (ECIUtil.getECIForEncoding(encoding) < 0) {
throw new IllegalArgumentException("Not a valid encoding: " + encoding);
}
this.encoding = encoding;
}
/**
* Returns the message encoding.
* @return the message encoding (default is "ISO-8859-1")
*/
public String getEncoding() {
return this.encoding;
}
/**
* Sets the minimum symbol size that is to be produced.
* @param minSize the minimum size (in pixels), or null for no constraint
*/
public void setMinSize(Dimension minSize) {
this.minSize = (minSize != null ? new Dimension(minSize) : null);
}
/**
* Returns the minimum symbol size that is to be produced. If the method returns null,
* there's no constraint on the symbol size.
* @return the minimum symbol size (in pixels), or null if there's no size constraint
*/
public Dimension getMinSize() {
if (this.minSize != null) {
return new Dimension(this.minSize);
} else {
return null;
}
}
/**
* Sets the maximum symbol size that is to be produced.
* @param maxSize the maximum size (in pixels), or null for no constraint
*/
public void setMaxSize(Dimension maxSize) {
this.maxSize = (maxSize != null ? new Dimension(maxSize) : null);
}
/**
* Returns the maximum symbol size that is to be produced. If the method returns null,
* there's no constraint on the symbol size.
* @return the maximum symbol size (in pixels), or null if there's no size constraint
*/
public Dimension getMaxSize() {
if (this.maxSize != null) {
return new Dimension(this.maxSize);
} else {
return null;
}
}
/** {@inheritDoc} */
public void generateBarcode(CanvasProvider canvas, String msg) {
if ((msg == null)
|| (msg.length() == 0)) {
throw new NullPointerException("Parameter msg must not be empty");
}
TwoDimBarcodeLogicHandler handler =
new DefaultTwoDimCanvasLogicHandler(this, new Canvas(canvas));
QRLogicImpl impl = new QRLogicImpl();
impl.generateBarcodeLogic(handler, msg, encoding, errorCorrectionLevel,
getMinSize(), getMaxSize());
}
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
QRCode code = new QRCode();
try {
code = Encoder.encode(msg,
QRLogicImpl.getZXingErrorLevel(errorCorrectionLevel),
QRLogicImpl.createHints(encoding));
} catch (WriterException e) {
throw new RuntimeException(e.getMessage());
}
ByteMatrix matrix = code.getMatrix();
int effWidth = matrix.getWidth();
int effHeight = matrix.getHeight();
checkSizeConstraints(effWidth, effHeight);
double width = effWidth * getModuleWidth();
double height = effHeight * getBarHeight();
double qzh = (hasQuietZone() ? getQuietZone() : 0);
double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0);
return new BarcodeDimension(width, height,
width + (2 * qzh), height + (2 * qzv),
qzh, qzv);
}
private void checkSizeConstraints(int width, int height) {
//Note: we're only checking the constraints, we can't currently influence ZXing's encoder.
if (this.minSize != null) {
if (width < this.minSize.width || height < this.minSize.height) {
throw new IllegalArgumentException(
"The given message would result in a smaller symbol than required."
+ " Requested minimum: "
+ this.minSize.width + " x " + this.minSize.height
+ ", effective: "
+ width + " x " + height);
}
}
if (this.maxSize != null) {
if (width > this.maxSize.width || height > this.maxSize.height) {
throw new IllegalArgumentException(
"The given message would result in a larger symbol than required."
+ " Requested maximum: "
+ this.maxSize.width + " x " + this.maxSize.height
+ ", effective: "
+ width + " x " + height);
}
}
}
/** {@inheritDoc} */
public double getVerticalQuietZone() {
return getQuietZone();
}
/** {@inheritDoc} */
public double getBarWidth(int width) {
return moduleWidth;
}
/** {@inheritDoc} */
public double getBarHeight() {
return moduleWidth;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright 2012 Jeremias Maerki, Switzerland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: QRConstants.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */
package org.krysalis.barcode4j.impl.qr;
/**
* Constants for QR Code.
*
* @version $Id: QRConstants.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $
*/
public interface QRConstants {
char ERROR_CORRECTION_LEVEL_L = 'L';
char ERROR_CORRECTION_LEVEL_M = 'M';
char ERROR_CORRECTION_LEVEL_Q = 'Q';
char ERROR_CORRECTION_LEVEL_H = 'H';
int QUIET_ZONE_SIZE = 4;
int QUIET_ZONE_SIZE_MICRO = 2;
int NUMERIC = 0;
int ALPHANUMERIC = 1;
int BINARY = 2;
int[] ALPHANUMERIC_TABLE = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //0x00-0x0f
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //0x10-0x1f
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //0x20-0x2f
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //0x30-0x3f
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //0x40-0x4f
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //0x50-0x5f
};
}

View File

@ -0,0 +1,64 @@
/*
* Copyright 2012 Jeremias Maerki, Switzerland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: QRHighLevelEncoder.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */
package org.krysalis.barcode4j.impl.qr;
/**
* High-level encoder for QR Code.
*
* @version $Id: QRHighLevelEncoder.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $
*/
public class QRHighLevelEncoder implements QRConstants {
private final String msg;
private int encodingMode;
public QRHighLevelEncoder(String msg) {
this.msg = msg;
this.encodingMode = analyzeMessage(msg);
}
public int getEncodingMode() {
return this.encodingMode;
}
private int analyzeMessage(String msg) {
int mode = NUMERIC;
for (int i = 0, c = msg.length(); i < c; i++) {
char ch = msg.charAt(i);
if (isDigit(ch)) {
//nop
} else if (mode == NUMERIC && isAlphanumeric(ch)) {
mode = ALPHANUMERIC;
} else {
mode = BINARY;
break;
}
}
return mode;
}
private static final boolean isDigit(char ch) {
return ch >= '0' && ch <= '9';
}
private static final boolean isAlphanumeric(char ch) {
return ALPHANUMERIC_TABLE[ch] >= 0;
}
}

View File

@ -0,0 +1,116 @@
/*
* Copyright 2012 Jeremias Maerki.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: QRLogicImpl.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ */
package org.krysalis.barcode4j.impl.qr;
import java.awt.Dimension;
import java.util.Hashtable;
import org.krysalis.barcode4j.TwoDimBarcodeLogicHandler;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.encoder.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
/**
* Top-level class for the logic part of the DataMatrix implementation.
*
* @version $Id: QRLogicImpl.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $
*/
public class QRLogicImpl implements QRConstants {
/**
* Generates the barcode logic.
* @param logic the logic handler to receive generated events
* @param msg the message to encode
* @param errorCorrectionLevel the error correction level (one of L, M, Q, H)
* @param encoding the message encoding
* @param minSize the minimum symbol size constraint or null for no constraint
* @param maxSize the maximum symbol size constraint or null for no constraint
*/
public void generateBarcodeLogic(TwoDimBarcodeLogicHandler logic, String msg,
String encoding,
char errorCorrectionLevel,
Dimension minSize, Dimension maxSize) {
//TODO ZXing doesn't allow to set minSize/maxSize through its API
ErrorCorrectionLevel zxingErrLevel = getZXingErrorLevel(errorCorrectionLevel);
Hashtable<EncodeHintType,String> hints = createHints(encoding);
QRCode code = new QRCode();
try {
code = Encoder.encode(msg, zxingErrLevel, hints);
} catch (WriterException e) {
throw new RuntimeException(e.getMessage(), e);
}
ByteMatrix matrix = code.getMatrix();
//finally, paint the barcode
logic.startBarcode(msg, msg);
encodeLowLevel(logic, matrix);
logic.endBarcode();
}
static Hashtable<EncodeHintType,String> createHints(String encoding) {
Hashtable<EncodeHintType,String> hints = null;
if (!"ISO-8859-1".equals(encoding)) {
hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, encoding);
}
return hints;
}
static ErrorCorrectionLevel getZXingErrorLevel(char errorCorrectionLevel) {
ErrorCorrectionLevel zxingErrLevel;
switch (errorCorrectionLevel) {
case ERROR_CORRECTION_LEVEL_L:
zxingErrLevel = ErrorCorrectionLevel.L;
break;
case ERROR_CORRECTION_LEVEL_M:
zxingErrLevel = ErrorCorrectionLevel.M;
break;
case ERROR_CORRECTION_LEVEL_Q:
zxingErrLevel = ErrorCorrectionLevel.Q;
break;
case ERROR_CORRECTION_LEVEL_H:
zxingErrLevel = ErrorCorrectionLevel.H;
break;
default:
throw new IllegalArgumentException(
"Invalid error correction level: " + errorCorrectionLevel);
}
return zxingErrLevel;
}
private void encodeLowLevel(TwoDimBarcodeLogicHandler logic, ByteMatrix matrix) {
int symbolWidth = matrix.getWidth();
int symbolHeight = matrix.getHeight();
for (int y = 0; y < symbolHeight; y++) {
logic.startRow();
for (int x = 0; x < symbolWidth; x++) {
logic.addBar(matrix.get(x, y) == 1, 1);
}
logic.endRow();
}
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright 2012 Jeremias Maerki, Switzerland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: ECIUtil.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */
package org.krysalis.barcode4j.tools;
import java.util.Map;
/**
* Utilities around ECI (extended channel interpretation).
*
* @version $Id: ECIUtil.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $
*/
public class ECIUtil {
/** ECI code for 8-bit binary data */
public static final int ECI_BINARY = 899;
private static final Map encodingToECI = new java.util.HashMap();
static {
mapEncoding("Cp437", 2);
mapEncoding("ISO-8859-1", 3);
mapEncoding("ISO-8859-2", 4);
mapEncoding("ISO-8859-3", 5);
mapEncoding("ISO-8859-4", 6);
mapEncoding("ISO-8859-5", 7);
mapEncoding("ISO-8859-6", 8);
mapEncoding("ISO-8859-7", 9);
mapEncoding("ISO-8859-8", 10);
mapEncoding("ISO-8859-9", 11);
mapEncoding("ISO-8859-10", 12);
mapEncoding("ISO-8859-11", 13);
mapEncoding("ISO-8859-13", 15);
mapEncoding("ISO-8859-14", 16);
mapEncoding("ISO-8859-15", 17);
mapEncoding("ISO-8859-16", 18);
mapEncoding("SJIS", 20);
mapEncoding("Cp1250", 21);
mapEncoding("Cp1251", 22);
mapEncoding("Cp1252", 23);
mapEncoding("Cp1256", 24);
mapEncoding("UnicodeBigUnmarked", 25);
mapEncoding("UTF-8", 26);
mapEncoding("US-ASCII", 27);
mapEncoding("Big5", 28);
mapEncoding("GB18030", 29);
}
private static void mapEncoding(String encoding, int eci) {
encodingToECI.put(encoding, new Integer(eci));
}
/**
* Returns the ECI code for a given encoding.
* @param encoding the encoding
* @return the corresponding ECI code
*/
public static int getECIForEncoding(String encoding) {
Integer code = (Integer)encodingToECI.get(encoding);
if (code != null) {
return code.intValue();
} else {
return -1; //undefined
}
}
}