Skip to content

Commit

Permalink
修复二维码及条码在设置表达式时显示内容不正确的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
jacky6024 committed Dec 1, 2017
1 parent 60eb55d commit 64a1cc8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
import com.bstek.ureport.definition.value.ZxingValue;
import com.bstek.ureport.exception.ReportComputeException;
import com.bstek.ureport.expression.model.Expression;
import com.bstek.ureport.expression.model.data.BindDataListExpressionData;
import com.bstek.ureport.expression.model.data.ExpressionData;
import com.bstek.ureport.expression.model.data.ObjectExpressionData;
import com.bstek.ureport.expression.model.data.ObjectListExpressionData;
import com.bstek.ureport.model.Cell;
import com.bstek.ureport.model.Image;
import com.google.zxing.BarcodeFormat;
Expand Down Expand Up @@ -70,26 +73,44 @@ public List<BindData> compute(Cell cell, Context context) {
}else{
Expression expression=value.getExpression();
ExpressionData<?> data=expression.execute(cell,cell, context);
Object obj=data.getData();
if(obj instanceof List){
List<?> listData=(List<?>)obj;
for(Object o:listData){
if(o!=null){
Image image=buildImage(barcodeForamt,o.toString(),w,h);
list.add(new BindData(image));
}
if(data instanceof BindDataListExpressionData){
BindDataListExpressionData listData=(BindDataListExpressionData)data;
List<BindData> bindDataList=listData.getData();
for(BindData bindData:bindDataList){
Object obj=bindData.getValue();
if(obj==null)obj="";
Image image=buildImage(barcodeForamt,obj.toString(),w,h);
list.add(new BindData(image));
}
}else if(obj instanceof String){
String text=obj.toString();
if(text.startsWith("\"") && text.endsWith("\"")){
text=text.substring(1,text.length()-1);
}else if(data instanceof ObjectExpressionData){
ObjectExpressionData exprData=(ObjectExpressionData)data;
Object obj=exprData.getData();
if(obj==null){
obj="";
}else if(obj instanceof String){
String text=obj.toString();
if(text.startsWith("\"") && text.endsWith("\"")){
text=text.substring(1,text.length()-1);
}
obj=text;
}
Image image=buildImage(barcodeForamt,text,w,h);
list.add(new BindData(image));
}else{
if(obj!=null){
Image image=buildImage(barcodeForamt,obj.toString(),w,h);
list.add(new BindData(image));
}else if(data instanceof ObjectListExpressionData){
ObjectListExpressionData listExprData=(ObjectListExpressionData)data;
List<?> listData=listExprData.getData();
for(Object obj:listData){
if(obj==null){
obj="";
}else if(obj instanceof String){
String text=obj.toString();
if(text.startsWith("\"") && text.endsWith("\"")){
text=text.substring(1,text.length()-1);
}
obj=text;
}
Image image=buildImage(barcodeForamt,obj.toString(),w,h);
list.add(new BindData(image));
list.add(new BindData(image));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private StringBuilder buildTable(Context context,List<Row> rows, List<Column> co
if(StringUtils.isBlank(target))target="_self";
sb.append("<a href=\""+linkURL+"\" target=\""+target+"\">");
}
Object obj=(cell.getFormatData()== null) ? "&nbsp;" : cell.getFormatData();
Object obj=(cell.getFormatData()== null) ? "" : cell.getFormatData();
if(obj instanceof Image){
Image img=(Image)obj;
String path=img.getPath();
Expand Down Expand Up @@ -229,6 +229,9 @@ private StringBuilder buildTable(Context context,List<Row> rows, List<Column> co
text=text.replaceAll("\r\n", "<br>");
text=text.replaceAll("\n", "<br>");
text=text.replaceAll(" ", "&nbsp;");
if(text.equals("")){
text="&nbsp;";
}
sb.append(text);
}
if(hasLink){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public class CurrentCellValueExpression extends BaseExpression {

@Override
protected ExpressionData<?> compute(Cell cell, Cell currentCell,Context context) {
return new ObjectExpressionData(cell.getFormatData());
return new ObjectExpressionData(cell.getData());
}
}

0 comments on commit 64a1cc8

Please sign in to comment.