You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ko...@apache.org on 2010/03/23 10:53:14 UTC

svn commit: r926512 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/ pdmodel/documentinterchange/logicalstructure/

Author: koch
Date: Tue Mar 23 09:53:14 2010
New Revision: 926512

URL: http://svn.apache.org/viewvc?rev=926512&view=rev
Log:
Added some new COSNames for logical structure

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureNode.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=926512&r1=926511&r2=926512&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Tue Mar 23 09:53:14 2010
@@ -63,6 +63,14 @@ public final class COSName extends COSBa
     */
     public static final COSName ACRO_FORM = new COSName( "AcroForm" );
     /**
+     * "ActualText"
+     */
+    public static final COSName ACTUAL_TEXT = new COSName("ActualText");
+    /**
+     * "Alt"
+     */
+    public static final COSName ALT = new COSName("Alt");
+    /**
     * A common COSName value.
     */
     public static final COSName ANNOTS = new COSName( "Annots" );
@@ -115,6 +123,10 @@ public final class COSName extends COSBa
     */
     public static final COSName CATALOG = new COSName( "Catalog" );
     /**
+     * "C"
+     */
+    public static final COSName C = new COSName("C");
+    /**
     * A common COSName value.
     */
     public static final COSName CALGRAY = new COSName( "CalGray" );
@@ -230,6 +242,11 @@ public final class COSName extends COSBa
     */
     public static final COSName DW = new COSName( "DW" );
 
+    /**
+     * "E"
+     */
+    public static final COSName E = new COSName("E");
+
     /** "EmbeddedFiles" */
     public static final COSName EMBEDDED_FILES = new COSName( "EmbeddedFiles" );
 
@@ -356,6 +373,9 @@ public final class COSName extends COSBa
     /** "ID" */
     public static final COSName ID = new COSName("ID");
 
+    /** "IDTree" */
+    public static final COSName ID_TREE = new COSName("IDTree");
+
     /**
     * A common COSName value.
     */
@@ -385,6 +405,9 @@ public final class COSName extends COSBa
     */
     public static final COSName JPX_DECODE = new COSName( "JPXDecode" );
 
+    /** "K" */
+    public static final COSName K = new COSName("K");
+
     /** "Kids" */
     public static final COSName KIDS = new COSName( "Kids" );
 
@@ -496,6 +519,10 @@ public final class COSName extends COSBa
     */
     public static final COSName PARENT = new COSName( "Parent" );
     /**
+     * "ParentTreeNextKey"
+     */
+    public static final COSName PARENT_TREE_NEXT_KEY = new COSName("ParentTreeNextKey");
+    /**
     * A common COSName value.
     */
     public static final COSName PATTERN = new COSName( "Pattern" );
@@ -504,6 +531,10 @@ public final class COSName extends COSBa
     */
     public static final COSName PDF_DOC_ENCODING = new COSName( "PDFDocEncoding" );
     /**
+     * "Pg"
+     */
+    public static final COSName PG = new COSName("Pg");
+    /**
     * A common COSName value.
     */
     public static final COSName PREV = new COSName( "Prev" );
@@ -524,6 +555,10 @@ public final class COSName extends COSBa
     */
     public static final COSName RESOURCES = new COSName( "Resources" );
     /**
+     * "RoleMap"
+     */
+    public static final COSName ROLE_MAP = new COSName("RoleMap");
+    /**
     * A common COSName value.
     */
     public static final COSName ROOT = new COSName( "Root" );
@@ -540,6 +575,10 @@ public final class COSName extends COSBa
     */
     public static final COSName RUN_LENGTH_DECODE_ABBREVIATION = new COSName( "RL" );
     /**
+     * "S"
+     */
+    public static final COSName S = new COSName("S");
+    /**
     * A common COSName value.
     */
     public static final COSName SEPARATION = new COSName( "Separation" );
@@ -563,6 +602,11 @@ public final class COSName extends COSBa
     */
     public static final COSName SUBTYPE = new COSName( "Subtype" );
 
+    /**
+     * "T"
+     */
+    public static final COSName T = new COSName("T");
+
     /** "Threads" */
     public static final COSName THREADS = new COSName("Threads");
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java?rev=926512&r1=926511&r2=926512&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElement.java Tue Mar 23 09:53:14 2010
@@ -70,7 +70,7 @@ public class PDStructureElement extends 
      */
     public String getStructureType()
     {
-        return this.getCOSDictionary().getNameAsString("S");
+        return this.getCOSDictionary().getNameAsString(COSName.S);
     }
 
     /**
@@ -80,7 +80,7 @@ public class PDStructureElement extends 
      */
     public void setStructureType(String structureType)
     {
-        this.getCOSDictionary().setName("S", structureType);
+        this.getCOSDictionary().setName(COSName.S, structureType);
     }
 
     /**
@@ -116,7 +116,7 @@ public class PDStructureElement extends 
      */
     public String getElementIdentifier()
     {
-        return this.getCOSDictionary().getString("ID");
+        return this.getCOSDictionary().getString(COSName.ID);
     }
 
     /**
@@ -126,7 +126,7 @@ public class PDStructureElement extends 
      */
     public void setElementIdentifier(String id)
     {
-        this.getCOSDictionary().setString("ID", id);
+        this.getCOSDictionary().setString(COSName.ID, id);
     }
 
     /**
@@ -139,7 +139,7 @@ public class PDStructureElement extends 
     public PDPage getPage()
     {
         COSDictionary pageDic = (COSDictionary) this.getCOSDictionary()
-            .getDictionaryObject("Pg");
+            .getDictionaryObject(COSName.PG);
         if (pageDic == null)
         {
             return null;
@@ -155,7 +155,7 @@ public class PDStructureElement extends 
      */
     public void setPage(PDPage page)
     {
-        this.getCOSDictionary().setItem("Pg", page);
+        this.getCOSDictionary().setItem(COSName.PG, page);
     }
 
     /**
@@ -165,7 +165,7 @@ public class PDStructureElement extends 
      */
     public Revisions<String> getClassNames()
     {
-        String key = "C";
+        COSName key = COSName.C;
         Revisions<String> classNames = new Revisions<String>();
         COSBase c = this.getCOSDictionary().getDictionaryObject(key);
         if (c instanceof COSName)
@@ -202,7 +202,7 @@ public class PDStructureElement extends 
      */
     public void setClassNames(Revisions<String> classNames)
     {
-        String key = "C";
+        COSName key = COSName.C;
         if ((classNames.size() == 1) && (classNames.getRevisionNumber(0) == 0))
         {
             String className = classNames.getObject(0);
@@ -231,7 +231,7 @@ public class PDStructureElement extends 
      */
     public void addClassName(String className)
     {
-        String key = "C";
+        COSName key = COSName.C;
         COSBase c = this.getCOSDictionary().getDictionaryObject(key);
         COSArray array = null;
         if (c instanceof COSArray)
@@ -259,7 +259,7 @@ public class PDStructureElement extends 
      */
     public void removeClassName(String className)
     {
-        String key = "C";
+        COSName key = COSName.C;
         COSBase c = this.getCOSDictionary().getDictionaryObject(key);
         COSName name = COSName.getPDFName(className);
         if (c instanceof COSArray)
@@ -312,7 +312,7 @@ public class PDStructureElement extends 
      */
     public String getTitle()
     {
-        return this.getCOSDictionary().getString("T");
+        return this.getCOSDictionary().getString(COSName.T);
     }
 
     /**
@@ -322,7 +322,7 @@ public class PDStructureElement extends 
      */
     public void setTitle(String title)
     {
-        this.getCOSDictionary().setString("T", title);
+        this.getCOSDictionary().setString(COSName.T, title);
     }
 
     /**
@@ -332,7 +332,7 @@ public class PDStructureElement extends 
      */
     public String getLanguage()
     {
-        return this.getCOSDictionary().getString("Lang");
+        return this.getCOSDictionary().getString(COSName.LANG);
     }
 
     /**
@@ -342,7 +342,7 @@ public class PDStructureElement extends 
      */
     public void setLanguage(String language)
     {
-        this.getCOSDictionary().setString("Lang", language);
+        this.getCOSDictionary().setString(COSName.LANG, language);
     }
 
     /**
@@ -352,7 +352,7 @@ public class PDStructureElement extends 
      */
     public String getAlternateDescription()
     {
-        return this.getCOSDictionary().getString("Alt");
+        return this.getCOSDictionary().getString(COSName.ALT);
     }
 
     /**
@@ -362,7 +362,7 @@ public class PDStructureElement extends 
      */
     public void setAlternateDescription(String alternateDescription)
     {
-        this.getCOSDictionary().setString("Alt", alternateDescription);
+        this.getCOSDictionary().setString(COSName.ALT, alternateDescription);
     }
 
     /**
@@ -372,7 +372,7 @@ public class PDStructureElement extends 
      */
     public String getExpandedForm()
     {
-        return this.getCOSDictionary().getString("E");
+        return this.getCOSDictionary().getString(COSName.E);
     }
 
     /**
@@ -382,7 +382,7 @@ public class PDStructureElement extends 
      */
     public void setExpandedForm(String expandedForm)
     {
-        this.getCOSDictionary().setString("E", expandedForm);
+        this.getCOSDictionary().setString(COSName.E, expandedForm);
     }
 
     /**
@@ -392,7 +392,7 @@ public class PDStructureElement extends 
      */
     public String getActualText()
     {
-        return this.getCOSDictionary().getString("ActualText");
+        return this.getCOSDictionary().getString(COSName.ACTUAL_TEXT);
     }
 
     /**
@@ -402,7 +402,7 @@ public class PDStructureElement extends 
      */
     public void setActualText(String actualText)
     {
-        this.getCOSDictionary().setString("ActualText", actualText);
+        this.getCOSDictionary().setString(COSName.ACTUAL_TEXT, actualText);
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureNode.java?rev=926512&r1=926511&r2=926512&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureNode.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureNode.java Tue Mar 23 09:53:14 2010
@@ -116,7 +116,7 @@ public abstract class PDStructureNode im
     public List<Object> getKids()
     {
         List<Object> kidObjects = new ArrayList<Object>();
-        COSBase k = this.getCOSDictionary().getDictionaryObject("K");
+        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
         if (k instanceof COSArray)
         {
             Iterator<COSBase> kids = ((COSArray) k).iterator();
@@ -148,7 +148,7 @@ public abstract class PDStructureNode im
      */
     public void setKids(List<Object> kids)
     {
-        this.getCOSDictionary().setItem("K",
+        this.getCOSDictionary().setItem(COSName.K,
             COSArrayList.converterToCOSArray(kids));
     }
 
@@ -188,11 +188,11 @@ public abstract class PDStructureNode im
         {
             return;
         }
-        COSBase k = this.getCOSDictionary().getDictionaryObject("K");
+        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
         if (k == null)
         {
             // currently no kid: set new kid as kids
-            this.getCOSDictionary().setItem("K", object);
+            this.getCOSDictionary().setItem(COSName.K, object);
         }
         else if (k instanceof COSArray)
         {
@@ -206,7 +206,7 @@ public abstract class PDStructureNode im
             COSArray array = new COSArray();
             array.add(k);
             array.add(object);
-            this.getCOSDictionary().setItem("K", array);
+            this.getCOSDictionary().setItem(COSName.K, array);
         }
     }
 
@@ -248,7 +248,7 @@ public abstract class PDStructureNode im
         {
             return;
         }
-        COSBase k = this.getCOSDictionary().getDictionaryObject("K");
+        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
         if (k == null)
         {
             return;
@@ -281,7 +281,7 @@ public abstract class PDStructureNode im
                 COSArray array = new COSArray();
                 array.add(newKid);
                 array.add(refKidBase);
-                this.getCOSDictionary().setItem("K", array);
+                this.getCOSDictionary().setItem(COSName.K, array);
             }
         }
     }
@@ -329,7 +329,7 @@ public abstract class PDStructureNode im
         {
             return false;
         }
-        COSBase k = this.getCOSDictionary().getDictionaryObject("K");
+        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
         if (k == null)
         {
             // no kids: objectable is not a kid
@@ -343,7 +343,7 @@ public abstract class PDStructureNode im
             // if now only one kid: set remaining kid as kids
             if (array.size() == 1)
             {
-                this.getCOSDictionary().setItem("K", array.getObject(0));
+                this.getCOSDictionary().setItem(COSName.K, array.getObject(0));
             }
             return removed;
         }
@@ -358,7 +358,7 @@ public abstract class PDStructureNode im
             }
             if (onlyKid)
             {
-                this.getCOSDictionary().setItem("K", null);
+                this.getCOSDictionary().setItem(COSName.K, null);
                 return true;
             }
             return false;
@@ -396,7 +396,7 @@ public abstract class PDStructureNode im
         }
         if (kidDic != null)
         {
-            String type = kidDic.getNameAsString("Type");
+            String type = kidDic.getNameAsString(COSName.TYPE);
             if ((type == null) || PDStructureElement.TYPE.equals(type))
             {
                 // A structure element dictionary denoting another structure
@@ -408,7 +408,7 @@ public abstract class PDStructureNode im
                 // An object reference dictionary denoting a PDF object
                 return new PDObjectReference(kidDic);
             }
-            else if ("MCR".equals(type))
+            else if (PDMarkedContentReference.TYPE.equals(type))
             {
                 // A marked-content reference dictionary denoting a
                 // marked-content sequence

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java?rev=926512&r1=926511&r2=926512&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java Tue Mar 23 09:53:14 2010
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.COSDictionaryMap;
 import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
 
@@ -65,7 +66,7 @@ public class PDStructureTreeRoot extends
     public PDNameTreeNode getIDTree()
     {
         COSDictionary idTreeDic = (COSDictionary) this.getCOSDictionary()
-            .getDictionaryObject("IDTree");
+            .getDictionaryObject(COSName.ID_TREE);
         if (idTreeDic != null)
         {
             return new PDNameTreeNode(idTreeDic, PDStructureElement.class);
@@ -80,7 +81,7 @@ public class PDStructureTreeRoot extends
      */
     public void setIDTree(PDNameTreeNode idTree)
     {
-        this.getCOSDictionary().setItem("IDTree", idTree);
+        this.getCOSDictionary().setItem(COSName.ID_TREE, idTree);
     }
 
     /**
@@ -90,7 +91,7 @@ public class PDStructureTreeRoot extends
      */
     public int getParentTreeNextKey()
     {
-        return this.getCOSDictionary().getInt("ParentTreeNextKey");
+        return this.getCOSDictionary().getInt(COSName.PARENT_TREE_NEXT_KEY);
     }
 
     /**
@@ -101,7 +102,7 @@ public class PDStructureTreeRoot extends
     @SuppressWarnings("unchecked")
     public Map<String, String> getRoleMap()
     {
-        COSBase rm = this.getCOSDictionary().getDictionaryObject("RoleMap");
+        COSBase rm = this.getCOSDictionary().getDictionaryObject(COSName.ROLE_MAP);
         if (rm instanceof COSDictionary)
         {
             try
@@ -128,7 +129,7 @@ public class PDStructureTreeRoot extends
         {
             rmDic.setName(key, roleMap.get(key));
         }
-        this.getCOSDictionary().setItem("RoleMap", rmDic);
+        this.getCOSDictionary().setItem(COSName.ROLE_MAP, rmDic);
     }
 
 }