Author: ssteiner Date: Wed Jan 29 10:15:14 2020 New Revision: 1873293 URL: http://svn.apache.org/viewvc?rev=1873293&view=rev Log: FOP-2908: Repeated image in header not shown in structure tree
Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java (with props) Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java?rev=1873293&r1=1873292&r2=1873293&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java Wed Jan 29 10:15:14 2020 @@ -183,8 +183,11 @@ public class PDFLogicalStructureHandler return ARTIFACT; } else { MarkedContentInfo mci = addToParentTree(structElem); - mci.parent.setMCIDKid(mci.mcid); - mci.parent.setPage(this.currentPage); + PDFDictionary contentItem = new PDFDictionary(); + contentItem.put("Type", MCR); + contentItem.put("Pg", this.currentPage); + contentItem.put("MCID", mci.mcid); + mci.parent.addKid(contentItem); return mci; } } Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java?rev=1873293&view=auto ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java (added) +++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java Wed Jan 29 10:15:14 2020 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.render.pdf; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import org.apache.fop.pdf.PDFDocument; +import org.apache.fop.pdf.PDFFactory; +import org.apache.fop.pdf.PDFResources; +import org.apache.fop.pdf.PDFStructElem; +import org.apache.fop.pdf.StandardStructureTypes; + +public class PDFStructureTreeBuilderTestCase { + private PDFFactory pdfFactory; + + @Test + public void testAddImageContentItem() throws IOException { + PDFStructElem structElem = new PDFStructElem(null, StandardStructureTypes.Illustration.FIGURE); + structElem.setDocument(pdfFactory.getDocument()); + PDFLogicalStructureHandler logicalStructureHandler = new PDFLogicalStructureHandler(null); + logicalStructureHandler.startPage(pdfFactory.makePage(new PDFResources(pdfFactory.getDocument()), 0, 0)); + logicalStructureHandler.addImageContentItem(structElem); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + structElem.output(bos); + assertEquals(bos.toString(), "<< /S /Figure /K [<<\n" + + " /Type /MCR\n" + + " /Pg 1 0 R\n" + + " /MCID 0\n" + + ">>] >>"); + } + + @Before + public void setUp() { + PDFDocument doc = new PDFDocument(""); + pdfFactory = new PDFFactory(doc); + } +} Propchange: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/pdf/PDFStructureTreeBuilderTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org