Pārlūkot izejas kodu

fixed bug 46250

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1382494 13f79535-47bb-0310-9956-ffa450edef68
tags/3.10-beta1
Evgeniy Berlog pirms 11 gadiem
vecāks
revīzija
a0ad9be37d

+ 17
- 1
src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java Parādīt failu

HSSFRichTextString rtr = (HSSFRichTextString) string; HSSFRichTextString rtr = (HSSFRichTextString) string;
// If font is not set we must set the default one // If font is not set we must set the default one
if (rtr.numFormattingRuns() == 0) rtr.applyFont((short) 0); if (rtr.numFormattingRuns() == 0) rtr.applyFont((short) 0);
_textObjectRecord.setStr(rtr);
TextObjectRecord txo = getOrCreateTextObjRecord();
txo.setStr(rtr);
if (string.getString() != null){ if (string.getString() != null){
setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, string.getString().hashCode())); setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, string.getString().hashCode()));
} }
EscherSpRecord spRecord = getEscherContainer().getChildById(EscherSpRecord.RECORD_ID); EscherSpRecord spRecord = getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
spRecord.setShapeType((short) value); spRecord.setShapeType((short) value);
} }
private TextObjectRecord getOrCreateTextObjRecord(){
if (getTextObjectRecord() == null){
_textObjectRecord = createTextObjRecord();
}
EscherTextboxRecord escherTextbox = getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID);
if (null == escherTextbox){
escherTextbox = new EscherTextboxRecord();
escherTextbox.setRecordId(EscherTextboxRecord.RECORD_ID);
escherTextbox.setOptions((short) 0x0000);
getEscherContainer().addChildRecord(escherTextbox);
getPatriarch()._getBoundAggregate().associateShapeToObjRecord(escherTextbox, _textObjectRecord);
}
return _textObjectRecord;
}
} }

+ 4
- 2
src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java Parādīt failu

void afterInsert(HSSFPatriarch patriarch) { void afterInsert(HSSFPatriarch patriarch) {
EscherAggregate agg = patriarch._getBoundAggregate(); EscherAggregate agg = patriarch._getBoundAggregate();
agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord()); agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord());
agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID), getTextObjectRecord());
if (getTextObjectRecord() != null){
agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID), getTextObjectRecord());
}
} }


/** /**


@Override @Override
protected HSSFShape cloneShape() { protected HSSFShape cloneShape() {
TextObjectRecord txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
TextObjectRecord txo = getTextObjectRecord() == null ? null : (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
EscherContainerRecord spContainer = new EscherContainerRecord(); EscherContainerRecord spContainer = new EscherContainerRecord();
byte[] inSp = getEscherContainer().serialize(); byte[] inSp = getEscherContainer().serialize();
spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory()); spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());

+ 14
- 0
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Parādīt failu

wb = writeOutAndReadBack((HSSFWorkbook) wb); wb = writeOutAndReadBack((HSSFWorkbook) wb);
assertEquals(wb.getAllPictures().size(), 1); assertEquals(wb.getAllPictures().size(), 1);
} }

public void test46250(){
Workbook wb = openSample("46250.xls");
Sheet sh = wb.getSheet("Template");
Sheet cSh = wb.cloneSheet(wb.getSheetIndex(sh));

HSSFPatriarch patriarch = (HSSFPatriarch) cSh.createDrawingPatriarch();
HSSFTextbox tb = (HSSFTextbox) patriarch.getChildren().get(2);

tb.setString(new HSSFRichTextString("POI test"));
tb.setAnchor(new HSSFClientAnchor(0,0,0,0,(short)0,0,(short)10,10));

wb = writeOutAndReadBack((HSSFWorkbook) wb);
}
} }

Binārs
test-data/spreadsheet/46250.xls Parādīt failu


Notiek ielāde…
Atcelt
Saglabāt