You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/06/04 19:26:17 UTC
[Bug 53355] New: When changing text content, formatting is lost.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53355
Priority: P2
Bug ID: 53355
Assignee: dev@poi.apache.org
Summary: When changing text content, formatting is lost.
Severity: minor
Classification: Unclassified
OS: All
Reporter: mark.horninger@dimensiondata.com
Hardware: All
Status: NEW
Version: 3.8
Component: HSLF
Product: POI
When changing text on a slide, formatting is lost. See example code below:
private boolean replaceTextInPowerPoint(final File destFile,
final String assessmentId) {
logger.log(Level.TRACE,
"Entering WordDocGenerator.replaceVariablesInWordDoc(File,
String)");
boolean result = Boolean.FALSE;
if (destFile.canWrite()) {
FileInputStream is;
final AnnexVarDao dao = new AnnexVarDao();
final Map<String, String> variableRs = dao
.loadVarReplacementMapByAssessmentId(assessmentId);
final Map<String, String> summaryVars = dao
.loadSummaryValuesByAssessment(assessmentId);
final Map<String, String> qnAVars = dao
.loadQuestionAndAnswerVarsByAssessment(assessmentId);
if (summaryVars != null) {
variableRs.putAll(summaryVars);
}
// 04/03/2012 [MJH] Change in regards to BUG: 72
// Added Q&A section to the document.
// For more detail, see Bugzilla at:
// http://tlma.dimensiondata.com/bugs/show_bug.cgi?id=72
if ((qnAVars != null) && (0 < qnAVars.size())) {
variableRs.putAll(qnAVars);
}
final StrLookupDefaultReplace<String> strLookup = new
StrLookupDefaultReplace<String>(
variableRs);
final StrSubstitutor subtitution = new StrSubstitutor(strLookup,
StrSubstitutor.DEFAULT_PREFIX,
StrSubstitutor.DEFAULT_SUFFIX,
StrSubstitutor.DEFAULT_ESCAPE);
try {
if (0 < variableRs.size()) {
is = new FileInputStream(destFile);
final XMLSlideShow pptx = new XMLSlideShow(is);
for(final XSLFSlide slide : pptx.getSlides()) {
for (final XSLFTextShape textShape : slide
.getPlaceholders()) {
String shapeText = textShape.getText();
logger.log(Level.DEBUG, String.format(
"Got shape text%s%s",
Configuration.SYSTEM_NEWLINE_STRING,
shapeText));
// 05/31/2012 [MJH] Change in regards to BUG: 89
// Reducing the number of replacements that are
done
// where possible.
// For more detail, see Bugzilla at:
//
http://tlma.dimensiondata.com/bugs/show_bug.cgi?id=89
if (StringUtils.contains(shapeText, "${")) {
shapeText = subtitution.replace(shapeText);
textShape.clearText();
logger.log(Level.DEBUG, String.format(
"Replacing shape text on slide: %s",
slide.getTitle()));
textShape.setText(shapeText);
}
logger.log(Level.DEBUG, String.format(
"New shape text%s%s",
Configuration.SYSTEM_NEWLINE_STRING,
shapeText));
}
}
final FileOutputStream os = new FileOutputStream(destFile);
pptx.write(os);
result = Boolean.TRUE;
}
} catch (final FileNotFoundException e) {
logger.log(Level.ERROR, e.getMessage(), e);
} catch (final IOException e) {
logger.log(Level.ERROR, e.getMessage(), e);
}
}
logger.log(Level.TRACE,
"Exiting WordDocGenerator.replaceVariablesInWordDoc(File,
String)");
return result;
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 53355] When changing text content, formatting is lost.
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53355
--- Comment #1 from Mark <ma...@dimensiondata.com> ---
I know that the trace log entries reference the wrong method name. I assure
you that it is receiving a powerpoint file.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org