use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStructureElement method removeAttribute.
/**
* Removes an attribute object.
*
* @param attributeObject the attribute object
*/
public void removeAttribute(PDAttributeObject attributeObject) {
COSName key = COSName.A;
COSBase a = this.getCOSObject().getDictionaryObject(key);
if (a instanceof COSArray) {
COSArray array = (COSArray) a;
array.remove(attributeObject.getCOSObject());
if ((array.size() == 2) && (array.getInt(1) == 0)) {
this.getCOSObject().setItem(key, array.getObject(0));
}
} else {
COSBase directA = a;
if (a instanceof COSObject) {
directA = ((COSObject) a).getObject();
}
if (attributeObject.getCOSObject().equals(directA)) {
this.getCOSObject().setItem(key, null);
}
}
attributeObject.setStructureElement(null);
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStructureElement method removeClassName.
/**
* Removes a class name.
*
* @param className the class name
*/
public void removeClassName(String className) {
if (className == null) {
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSObject().getDictionaryObject(key);
COSName name = COSName.getPDFName(className);
if (c instanceof COSArray) {
COSArray array = (COSArray) c;
array.remove(name);
if ((array.size() == 2) && (array.getInt(1) == 0)) {
this.getCOSObject().setItem(key, array.getObject(0));
}
} else {
COSBase directC = c;
if (c instanceof COSObject) {
directC = ((COSObject) c).getObject();
}
if (name.equals(directC)) {
this.getCOSObject().setItem(key, null);
}
}
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStructureElement method addClassName.
/**
* Adds a class name.
*
* @param className the class name
*/
public void addClassName(String className) {
if (className == null) {
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSObject().getDictionaryObject(key);
COSArray array;
if (c instanceof COSArray) {
array = (COSArray) c;
} else {
array = new COSArray();
if (c != null) {
array.add(c);
array.add(COSInteger.get(0));
}
}
this.getCOSObject().setItem(key, array);
array.add(COSName.getPDFName(className));
array.add(COSInteger.get(this.getRevisionNumber()));
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStructureElement method attributeChanged.
/**
* Updates the revision number for the given attribute object.
*
* @param attributeObject the attribute object
*/
public void attributeChanged(PDAttributeObject attributeObject) {
COSName key = COSName.A;
COSBase a = this.getCOSObject().getDictionaryObject(key);
if (a instanceof COSArray) {
COSArray array = (COSArray) a;
for (int i = 0; i < array.size(); i++) {
COSBase entry = array.getObject(i);
if (entry.equals(attributeObject.getCOSObject())) {
COSBase next = array.get(i + 1);
if (next instanceof COSInteger) {
array.set(i + 1, COSInteger.get(this.getRevisionNumber()));
}
}
}
} else {
COSArray array = new COSArray();
array.add(a);
array.add(COSInteger.get(this.getRevisionNumber()));
this.getCOSObject().setItem(key, array);
}
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDFourColours method getColourByIndex.
/**
* Gets the colour by edge index.
*
* @param index edge index
* @return the colour
*/
private PDGamma getColourByIndex(int index) {
PDGamma retval = null;
COSBase item = this.array.getObject(index);
if (item instanceof COSArray) {
retval = new PDGamma((COSArray) item);
}
return retval;
}
Aggregations