Bläddra i källkod

#55030 - RichTextRun getFontName can not get Chinese font name

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1722479 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_14_FINAL
Andreas Beeker 8 år sedan
förälder
incheckning
720db41739

+ 15
- 3
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Visa fil

* Fetch the value of the given Paragraph related TextProp. Returns null if * Fetch the value of the given Paragraph related TextProp. Returns null if
* that TextProp isn't present. If the TextProp isn't present, the value * that TextProp isn't present. If the TextProp isn't present, the value
* from the appropriate Master Sheet will apply. * from the appropriate Master Sheet will apply.
*
* The propName can be a comma-separated list, in case multiple equivalent values
* are queried
*/ */
protected static TextProp getPropVal(TextPropCollection props, String propName, HSLFTextParagraph paragraph) { protected static TextProp getPropVal(TextPropCollection props, String propName, HSLFTextParagraph paragraph) {
TextProp prop = props.findByName(propName);
if (prop != null) return prop;
String propNames[] = propName.split(",");
for (String pn : propNames) {
TextProp prop = props.findByName(pn);
if (prop != null) return prop;
}
BitMaskTextProp maskProp = (BitMaskTextProp) props.findByName(ParagraphFlagsTextProp.NAME); BitMaskTextProp maskProp = (BitMaskTextProp) props.findByName(ParagraphFlagsTextProp.NAME);
boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0); boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0);
} }
boolean isChar = props.getTextPropType() == TextPropType.character; boolean isChar = props.getTextPropType() == TextPropType.character;
return master.getStyleAttribute(txtype, paragraph.getIndentLevel(), propName, isChar);
for (String pn : propNames) {
TextProp prop = master.getStyleAttribute(txtype, paragraph.getIndentLevel(), pn, isChar);
if (prop != null) return prop;
}
return null;
} }
/** /**

+ 1
- 1
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java Visa fil

if (sheet == null || slideShow == null) { if (sheet == null || slideShow == null) {
return _fontFamily; return _fontFamily;
} }
TextProp tp = getPropVal(characterStyle, "font.index", parentParagraph);
TextProp tp = getPropVal(characterStyle, "font.index,asian.font.index,ansi.font.index,symbol.font.index", parentParagraph);
if (tp == null) { return null; } if (tp == null) { return null; }
return slideShow.getFontCollection().getFontWithId(tp.getValue()); return slideShow.getFontCollection().getFontWithId(tp.getValue());
} }

+ 20
- 4
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Visa fil

import org.apache.poi.hslf.extractor.PowerPointExtractor; import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hslf.model.HeadersFooters; import org.apache.poi.hslf.model.HeadersFooters;
import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.record.OEPlaceholderAtom;
import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
import org.apache.poi.hslf.record.SlideListWithText; import org.apache.poi.hslf.record.SlideListWithText;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet; import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
import org.apache.poi.hslf.record.TextHeaderAtom; import org.apache.poi.hslf.record.TextHeaderAtom;


@Test @Test
public void bug58159() throws IOException { public void bug58159() throws IOException {
File sample = HSLFTestDataSamples.getSampleFile("bug58159_headers-and-footers.ppt");
HSLFSlideShow ppt = (HSLFSlideShow)SlideShowFactory.create(sample);
HSLFSlideShow ppt = open("bug58159_headers-and-footers.ppt");
HeadersFooters hf = ppt.getSlideHeadersFooters(); HeadersFooters hf = ppt.getSlideHeadersFooters();
assertNull(hf.getHeaderText()); assertNull(hf.getHeaderText());
assertEquals("Slide footer", hf.getFooterText()); assertEquals("Slide footer", hf.getFooterText());
} }
ppt.close(); ppt.close();
} }

@Test
public void bug55030() throws IOException {
HSLFSlideShow ppt = open("bug55030.ppt");
String expFamily = "\u96b6\u4e66";
HSLFSlide sl = ppt.getSlides().get(0);
for (List<HSLFTextParagraph> paraList : sl.getTextParagraphs()) {
for (HSLFTextParagraph htp : paraList) {
for (HSLFTextRun htr : htp) {
String actFamily = htr.getFontFamily();
assertEquals(expFamily, actFamily);
}
}
}
ppt.close();
}
private static HSLFSlideShow open(String fileName) throws IOException { private static HSLFSlideShow open(String fileName) throws IOException {
File sample = HSLFTestDataSamples.getSampleFile(fileName); File sample = HSLFTestDataSamples.getSampleFile(fileName);

Binär
test-data/slideshow/bug55030.ppt Visa fil


Laddar…
Avbryt
Spara