001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.pdf.cos;
031:
032: /**
033: * The document catalog object of the PDF document.
034: */
035: public class COSCatalog extends COSBasedObject {
036: /**
037: * The meta class implementation
038: */
039: static public class MetaClass extends COSBasedObject.MetaClass {
040: protected MetaClass(Class instanceClass) {
041: super (instanceClass);
042: }
043: }
044:
045: public static final COSName DK_AcroForm = COSName
046: .constant("AcroForm"); //$NON-NLS-1$
047:
048: static public final COSName DK_Dests = COSName.constant("Dests"); //$NON-NLS-1$
049:
050: public static final COSName DK_FDF = COSName.constant("FDF"); //$NON-NLS-1$
051:
052: static public final COSName DK_Names = COSName.constant("Names"); //$NON-NLS-1$
053:
054: static public final COSName DK_OpenAction = COSName
055: .constant("OpenAction"); //$NON-NLS-1$
056:
057: static public final COSName DK_Outlines = COSName
058: .constant("Outlines"); //$NON-NLS-1$
059:
060: public static final COSName DK_Sig = COSName.constant("Sig"); //$NON-NLS-1$
061:
062: public static final COSName DK_Type = COSName.constant("Type"); //$NON-NLS-1$
063:
064: public static final COSName DK_Metadata = COSName
065: .constant("Metadata"); //$NON-NLS-1$
066:
067: public static final COSName DK_OutputIntents = COSName
068: .constant("OutputIntents"); //$NON-NLS-1$
069:
070: static public final COSName DK_PageMode = COSName
071: .constant("PageMode"); //$NON-NLS-1$
072:
073: public static final COSName DK_Pages = COSName.constant("Pages"); //$NON-NLS-1$
074:
075: public static final COSName DK_PieceInfo = COSName
076: .constant("PieceInfo"); //$NON-NLS-1$
077:
078: static public final COSName CN_Type_Catalog = COSName
079: .constant("Catalog"); //$NON-NLS-1$
080:
081: public static final COSName DK_URI = COSName.constant("URI"); //$NON-NLS-1$
082:
083: static public final COSName DK_Version = COSName
084: .constant("Version"); //$NON-NLS-1$
085:
086: /** Well known attribute names */
087: static public final COSName CN_Version_1_4 = COSName
088: .constant("1.4"); //$NON-NLS-1$
089:
090: /** The meta class instance */
091: static public final MetaClass META = new MetaClass(MetaClass.class
092: .getDeclaringClass());
093:
094: protected COSCatalog(COSObject object) {
095: super (object);
096: }
097:
098: /**
099: * The /Dests field in the document catalog.
100: *
101: * @return The /Dests field in the document catalog.
102: */
103: public COSDictionary cosGetDests() {
104: return cosGetField(DK_Dests).asDictionary();
105: }
106:
107: /**
108: * The /FDF field in the document catalog.
109: *
110: * @return The /FDF field in the document catalog.
111: */
112: public COSDictionary cosGetFDF() {
113: return cosGetField(DK_FDF).asDictionary();
114: }
115:
116: /**
117: * The /Names field in the document catalog.
118: *
119: * @return The /Names field in the document catalog.
120: */
121: public COSDictionary cosGetNames() {
122: return cosGetField(DK_Names).asDictionary();
123: }
124:
125: /**
126: * Set the /Names field in the document catalog.
127: *
128: */
129: public COSDictionary cosSetNames(COSDictionary pNames) {
130: return cosSetField(DK_Names, pNames).asDictionary();
131: }
132:
133: /**
134: * The object defining the open action for the document.
135: *
136: * @return COSDictionary or COSArray or COSNull if no entry defined.
137: */
138: public COSObject cosGetOpenAction() {
139: return cosGetField(DK_OpenAction);
140: }
141:
142: /**
143: * The /Outlines field in the document catalog.
144: *
145: * @return The /Outlines field in the document catalog.
146: */
147: public COSDictionary cosGetOutline() {
148: return cosGetField(DK_Outlines).asDictionary();
149: }
150:
151: /**
152: * The /Sig field in the document catalog.
153: *
154: * @return The /Sig field in the document catalog.
155: */
156: public COSDictionary cosGetSig() {
157: return cosGetField(DK_Sig).asDictionary();
158: }
159:
160: /**
161: * Set the /FDF field in the document catalog.
162: *
163: */
164: public COSDictionary cosSetFDF(COSDictionary fdfDict) {
165: return cosSetField(DK_FDF, fdfDict).asDictionary();
166: }
167:
168: /**
169: * Set the /Outlines field in the document catalog.
170: *
171: */
172: public COSDictionary cosSetOutline(COSDictionary dict) {
173: return cosSetField(DK_Outlines, dict).asDictionary();
174: }
175:
176: /**
177: * Set the /Sig field in the document catalog.
178: *
179: */
180: public COSDictionary cosSetSig(COSDictionary sigDict) {
181: return cosSetField(DK_Sig, sigDict).asDictionary();
182: }
183:
184: /**
185: * The /PageMode field in the document catalog.
186: *
187: * @return The /PageMode field in the document catalog.
188: */
189: public String getPageMode() {
190: return getFieldString(DK_PageMode, "UseNone"); //$NON-NLS-1$
191: }
192:
193: /**
194: * The /Version field in the document catalog.
195: *
196: * @return The /Version field in the document catalog.
197: */
198: public String getVersion() {
199: return getFieldString(DK_Version, cosGetDoc().stGetDoc()
200: .getVersion());
201: }
202:
203: /*
204: * (non-Javadoc)
205: *
206: * @see de.intarsys.pdf.cos.COSBasedObject#initializeFromScratch()
207: */
208: protected void initializeFromScratch() {
209: super .initializeFromScratch();
210: cosSetField(DK_Type, CN_Type_Catalog.copyShallow());
211: cosSetField(DK_Version, CN_Version_1_4.copyShallow());
212: }
213:
214: /**
215: * Set the /PageMode field in the document catalog.
216: *
217: */
218: public void setPageMode(String value) {
219: setFieldName(DK_PageMode, value);
220: }
221:
222: /**
223: * Set the /Version field in the document catalog.
224: *
225: */
226: public void setVersion(String value) {
227: setFieldName(DK_Version, value);
228: }
229:
230: /**
231: * Set the /Dests field in the document catalog.
232: *
233: */
234: public COSDictionary cosSetDests(COSDictionary pDests) {
235: return cosSetField(DK_Dests, pDests).asDictionary();
236: }
237: }
|