26
26
import java .util .*;
27
27
28
28
import org .apache .fop .accessibility .StructureTreeElement ;
29
+ import org .apache .fop .fo .extensions .InternalElementMapping ;
29
30
import org .apache .fop .pdf .StandardStructureAttributes .Table ;
30
31
import org .apache .fop .util .LanguageTags ;
32
+ import org .xml .sax .Attributes ;
31
33
32
34
/**
33
35
* Class representing a PDF Structure Element.
@@ -255,22 +257,29 @@ protected boolean attachKids() {
255
257
return kidsAttached ;
256
258
}
257
259
258
- public void setTableAttributeColSpan (int colSpan ) {
259
- setTableAttributeRowColumnSpan ("ColSpan" , colSpan );
260
+ public void setTableAttributeColSpan (int colSpan , Attributes attributes ) {
261
+ setTableAttributeRowColumnSpan ("ColSpan" , colSpan , attributes );
260
262
}
261
263
262
- public void setTableAttributeRowSpan (int rowSpan ) {
263
- setTableAttributeRowColumnSpan ("RowSpan" , rowSpan );
264
+ public void setTableAttributeRowSpan (int rowSpan , Attributes attributes ) {
265
+ setTableAttributeRowColumnSpan ("RowSpan" , rowSpan , attributes );
264
266
}
265
267
266
- private void setTableAttributeRowColumnSpan (String typeSpan , int span ) {
268
+ private void setTableAttributeRowColumnSpan (String typeSpan , int span , Attributes attributes ) {
267
269
PDFDictionary attribute = new PDFDictionary ();
268
270
attribute .put ("O" , Table .NAME );
269
271
attribute .put (typeSpan , span );
270
- if (attributes == null ) {
271
- attributes = new ArrayList <PDFDictionary >(attribute .entries .size ());
272
+ String scopeAttribute = attributes .getValue (InternalElementMapping .URI ,
273
+ InternalElementMapping .SCOPE );
274
+ Table .Scope scope = (scopeAttribute == null )
275
+ ? Table .Scope .COLUMN
276
+ : Table .Scope .valueOf (scopeAttribute .toUpperCase (Locale .ENGLISH ));
277
+ attribute .put ("Scope" , scope .getName ());
278
+
279
+ if (this .attributes == null ) {
280
+ this .attributes = new ArrayList <PDFDictionary >(attribute .entries .size ());
272
281
}
273
- attributes .add (attribute );
282
+ this . attributes .add (attribute );
274
283
}
275
284
276
285
public List <PDFObject > getKids () {
@@ -281,7 +290,7 @@ public int output(OutputStream stream) throws IOException {
281
290
if (getDocument () != null && getDocument ().getProfile ().getPDFUAMode ().isEnabled ()) {
282
291
if (entries .containsKey ("Alt" ) && "" .equals (get ("Alt" ))) {
283
292
put ("Alt" , "No alternate text specified" );
284
- } else if (kids != null ) {
293
+ } else if (kids != null && structureType != null ) {
285
294
for (PDFObject kid : kids ) {
286
295
if (kid instanceof PDFStructElem && isBSLE (((PDFStructElem ) kid ))) {
287
296
structureType = StandardStructureTypes .Grouping .DIV ;
0 commit comments