ASF Bugzilla – Attachment 28009 Details for
Bug 52268
Missing images on cloned sheets.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch that solves problem with cloning sheet with images
poi.patch (text/plain), 3.47 KB, created by
Michael
on 2011-12-01 10:01:18 UTC
(
hide
)
Description:
Patch that solves problem with cloning sheet with images
Filename:
MIME Type:
Creator:
Michael
Created:
2011-12-01 10:01:18 UTC
Size:
3.47 KB
patch
obsolete
>Index: ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java >=================================================================== >--- ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (revision 1207839) >+++ ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (working copy) >@@ -77,7 +77,10 @@ > */ > protected XSSFDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException { > super(part, rel); >- drawing = CTDrawing.Factory.parse(part.getInputStream()); >+ XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS); >+ //Removing root element >+ options.setLoadReplaceDocumentElement(null); >+ drawing = CTDrawing.Factory.parse(part.getInputStream(),options); > } > > /** >Index: ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java >=================================================================== >--- ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (revision 1207839) >+++ ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (working copy) >@@ -61,6 +61,10 @@ > import org.apache.xmlbeans.XmlException; > import org.apache.xmlbeans.XmlObject; > import org.apache.xmlbeans.XmlOptions; >+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTAbsoluteAnchor; >+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing; >+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTOneCellAnchor; >+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor; > import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews; >@@ -383,10 +387,44 @@ > throw new POIXMLException("Failed to clone sheet", e); > } > CTWorksheet ct = clonedSheet.getCTWorksheet(); >- if(ct.isSetDrawing()) { >- logger.log(POILogger.WARN, "Cloning sheets with drawings is not yet supported."); >- ct.unsetDrawing(); >- } >+ if(ct.isSetPageSetup()) >+ { >+ logger.log(POILogger.WARN, "Cloning sheets with page setup is not yet supported."); >+ ct.unsetPageSetup(); >+ } >+ if (ct.isSetDrawing()) >+ { >+ ct.unsetDrawing(); >+ >+ CTDrawing srcDrawing = srcSheet.createDrawingPatriarch().getCTDrawing(); >+ >+ // Clone drawing relations >+ List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations(); >+ for (POIXMLDocumentPart rel : srcRels) >+ { >+ PackageRelationship relation = rel.getPackageRelationship(); >+ clonedSheet >+ .createDrawingPatriarch() >+ .getPackagePart() >+ .addRelationship(relation.getTargetURI(), relation.getTargetMode(), >+ relation.getRelationshipType(), relation.getId()); >+ } >+ >+ // Clone drawing content >+ CTDrawing clonedDrawing = clonedSheet.createDrawingPatriarch().getCTDrawing(); >+ for (CTTwoCellAnchor anchor : srcDrawing.getTwoCellAnchorList()) >+ { >+ clonedDrawing.getTwoCellAnchorList().add(anchor); >+ } >+ for (CTOneCellAnchor anchor : srcDrawing.getOneCellAnchorList()) >+ { >+ clonedDrawing.getOneCellAnchorList().add(anchor); >+ } >+ for (CTAbsoluteAnchor anchor : srcDrawing.getAbsoluteAnchorList()) >+ { >+ clonedDrawing.getAbsoluteAnchorList().add(anchor); >+ } >+ } > if(ct.isSetLegacyDrawing()) { > logger.log(POILogger.WARN, "Cloning sheets with comments is not yet supported."); > ct.unsetLegacyDrawing();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 52268
: 28009 |
28010