...
 
Commits (1)
......@@ -183,7 +183,7 @@ static AnnotExternalDataType parseAnnotExternalData(Dict* dict) {
return type;
}
static std::unique_ptr<PDFRectangle> parseDiffRectangle(Array *array, PDFRectangle *rect) {
static std::unique_ptr<PDFRectangle> parseDiffRectangle(const Array *array, PDFRectangle *rect) {
if (array->getLength() == 4) {
// deltas
Object obj1;
......@@ -283,7 +283,7 @@ AnnotBorderEffect::AnnotBorderEffect(Dict *dict) {
AnnotPath::AnnotPath() = default;
AnnotPath::AnnotPath(Array *array) {
AnnotPath::AnnotPath(const Array *array) {
parsePathArray(array);
}
......@@ -311,7 +311,7 @@ AnnotCoord *AnnotPath::getCoord(int coord) {
return nullptr;
}
void AnnotPath::parsePathArray(Array *array) {
void AnnotPath::parsePathArray(const Array *array) {
if (array->getLength() % 2) {
error(errSyntaxError, -1, "Bad Annot Path");
return;
......@@ -364,7 +364,7 @@ AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2,
// AnnotQuadrilateral
//------------------------------------------------------------------------
AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
AnnotQuadrilaterals::AnnotQuadrilaterals(const Array *array, PDFRectangle *rect) {
int arrayLength = array->getLength();
int quadsLength = 0;
double quadArray[8];
......@@ -514,7 +514,7 @@ AnnotBorderArray::AnnotBorderArray() {
verticalCorner = 0;
}
AnnotBorderArray::AnnotBorderArray(Array *array) {
AnnotBorderArray::AnnotBorderArray(const Array *array) {
Object obj1;
int arrayLength = array->getLength();
......@@ -692,7 +692,7 @@ AnnotColor::AnnotColor(double c, double m, double y, double k) {
// If <adjust> is +1, color is brightened;
// if <adjust> is -1, color is darkened;
// otherwise color is not modified.
AnnotColor::AnnotColor(Array *array, int adjust) {
AnnotColor::AnnotColor(const Array *array, int adjust) {
int i;
length = array->getLength();
......@@ -1036,7 +1036,7 @@ AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) {
obj1 = dict->lookup("BC");
if (obj1.isArray()) {
Array *colorComponents = obj1.getArray();
const Array *colorComponents = obj1.getArray();
if (colorComponents->getLength() > 0) {
borderColor = std::make_unique<AnnotColor>(colorComponents);
}
......@@ -1044,7 +1044,7 @@ AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) {
obj1 = dict->lookup("BG");
if (obj1.isArray()) {
Array *colorComponents = obj1.getArray();
const Array *colorComponents = obj1.getArray();
if (colorComponents->getLength() > 0) {
backColor = std::make_unique<AnnotColor>(colorComponents);
}
......@@ -5823,7 +5823,7 @@ void AnnotInk::writeInkList(AnnotPath **paths, int n_paths, Array *dest_array) {
}
}
void AnnotInk::parseInkList(Array *array) {
void AnnotInk::parseInkList(const Array *array) {
inkListLength = array->getLength();
inkList = (AnnotPath **) gmallocn ((inkListLength), sizeof(AnnotPath *));
memset(inkList, 0, inkListLength * sizeof(AnnotPath *));
......
......@@ -110,7 +110,7 @@ protected:
class AnnotPath {
public:
AnnotPath();
AnnotPath(Array *array);
AnnotPath(const Array *array);
AnnotPath(std::vector<AnnotCoord> &&coords);
~AnnotPath();
......@@ -124,7 +124,7 @@ public:
protected:
std::vector<AnnotCoord> coords;
void parsePathArray(Array *array);
void parsePathArray(const Array *array);
};
//------------------------------------------------------------------------
......@@ -206,7 +206,7 @@ public:
AnnotCoord coord1, coord2, coord3, coord4;
};
AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
AnnotQuadrilaterals(const Array *array, PDFRectangle *rect);
AnnotQuadrilaterals(std::unique_ptr<AnnotQuadrilateral[]> &&quads, int quadsLength);
~AnnotQuadrilaterals();
......@@ -282,7 +282,7 @@ protected:
class AnnotBorderArray: public AnnotBorder {
public:
AnnotBorderArray();
AnnotBorderArray(Array *array);
AnnotBorderArray(const Array *array);
void setHorizontalCorner(double hc) { horizontalCorner = hc; }
void setVerticalCorner(double vc) { verticalCorner = vc; }
......@@ -338,7 +338,7 @@ public:
AnnotColor(double gray);
AnnotColor(double r, double g, double b);
AnnotColor(double c, double m, double y, double k);
AnnotColor(Array *array, int adjust = 0);
AnnotColor(const Array *array, int adjust = 0);
void adjustColor(int adjust);
......@@ -1314,7 +1314,7 @@ private:
void initialize(PDFDoc *docA, Dict *dict);
void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array);
void parseInkList(Array *src_array);
void parseInkList(const Array *src_array);
void freeInkList();
// required
......
......@@ -36,33 +36,29 @@
// Array
//------------------------------------------------------------------------
#define arrayLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
Array::Array(XRef *xrefA) {
xref = xrefA;
ref = 1;
}
Array::~Array() {
}
Array::~Array() = default;
Object Array::copy(XRef *xrefA) const {
arrayLocker();
Array *Array::copy(XRef *xrefA) const {
Array *a = new Array(xrefA);
a->elems.reserve(elems.size());
for (const auto& elem : elems) {
a->elems.push_back(elem.copy());
}
return Object(a);
return a;
}
void Array::add(Object &&elem) {
arrayLocker();
assert(ref.load() == 1);
elems.push_back(std::move(elem));
}
void Array::remove(int i) {
arrayLocker();
assert(ref.load() == 1);
if (i < 0 || std::size_t(i) >= elems.size()) {
assert(i >= 0 && std::size_t(i) < elems.size());
return;
......
......@@ -29,7 +29,6 @@
#define ARRAY_H
#include <atomic>
#include <mutex>
#include <vector>
#include "poppler-config.h"
......@@ -56,8 +55,10 @@ public:
// Get number of elements.
int getLength() const { return elems.size(); }
Array *copy() const { return copy(xref); }
// Copy array with new xref
Object copy(XRef *xrefA) const;
Array *copy(XRef *xrefA) const;
// Add an element
// elem becomes a dead object after this call
......@@ -73,16 +74,11 @@ public:
bool getString(int i, GooString *string) const;
private:
friend class Object; // for incRef/decRef
// Reference counting.
int incRef() { return ++ref; }
int decRef() { return --ref; }
friend class Object;
XRef *xref; // the xref table for this PDF file
std::vector<Object> elems; // array of elements
std::atomic_int ref; // reference count
mutable std::recursive_mutex mutex;
};
#endif
......@@ -629,7 +629,7 @@ NameTree::~NameTree()
gfree(entries);
}
NameTree::Entry::Entry(Array *array, int index) {
NameTree::Entry::Entry(const Array *array, int index) {
if (!array->getString(index, &name)) {
Object aux = array->get(index);
if (aux.isString())
......
......@@ -79,7 +79,7 @@ public:
private:
struct Entry {
Entry(Array *array, int index);
Entry(const Array *array, int index);
~Entry();
GooString name;
Object value;
......
......@@ -1824,7 +1824,7 @@ Form::Form(PDFDoc *docA, Object* acroFormA)
obj1 = acroForm->dictLookup("Fields");
if (obj1.isArray()) {
Array *array = obj1.getArray();
const Array *array = obj1.getArray();
for(int i=0; i<array->getLength(); i++) {
Object obj2 = array->get(i);
const Object &oref = array->getNF(i);
......@@ -1853,7 +1853,7 @@ Form::Form(PDFDoc *docA, Object* acroFormA)
obj1 = acroForm->dictLookup("CO");
if (obj1.isArray()) {
Array *array = obj1.getArray();
const Array *array = obj1.getArray();
calculateOrder.reserve(array->getLength());
for(int i=0; i<array->getLength(); i++) {
const Object &oref = array->getNF(i);
......
......@@ -940,7 +940,7 @@ void Gfx::opConcat(Object args[], int numArgs) {
}
void Gfx::opSetDash(Object args[], int numArgs) {
Array *a;
const Array *a;
int length;
double *dash;
int i;
......@@ -3826,7 +3826,7 @@ void Gfx::opMoveSetShowText(Object args[], int numArgs) {
}
void Gfx::opShowSpaceText(Object args[], int numArgs) {
Array *a;
const Array *a;
int wMode;
int i;
......
......@@ -784,7 +784,7 @@ static const double xyzrgb[3][3] = {
{ 0.055643, -0.204026, 1.057229 }
};
GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr, GfxState *state) {
GfxColorSpace *GfxCalGrayColorSpace::parse(const Array *arr, GfxState *state) {
GfxCalGrayColorSpace *cs;
Object obj1, obj2;
......@@ -1153,7 +1153,7 @@ GfxColorSpace *GfxCalRGBColorSpace::copy() {
return cs;
}
GfxColorSpace *GfxCalRGBColorSpace::parse(Array *arr, GfxState *state) {
GfxColorSpace *GfxCalRGBColorSpace::parse(const Array *arr, GfxState *state) {
GfxCalRGBColorSpace *cs;
Object obj1, obj2;
int i;
......@@ -1524,7 +1524,7 @@ GfxColorSpace *GfxLabColorSpace::copy() {
return cs;
}
GfxColorSpace *GfxLabColorSpace::parse(Array *arr, GfxState *state) {
GfxColorSpace *GfxLabColorSpace::parse(const Array *arr, GfxState *state) {
GfxLabColorSpace *cs;
Object obj1, obj2;
......@@ -1813,7 +1813,7 @@ GfxColorSpace *GfxICCBasedColorSpace::copy() {
return cs;
}
GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *GfxICCBasedColorSpace::parse(const Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxICCBasedColorSpace *cs;
Ref iccProfileStreamA;
int nCompsA;
......@@ -2453,7 +2453,7 @@ GfxColorSpace *GfxIndexedColorSpace::copy() {
return cs;
}
GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *baseA;
int indexHighA;
Object obj1;
......@@ -2712,7 +2712,7 @@ GfxColorSpace *GfxSeparationColorSpace::copy() {
}
//~ handle the 'All' and 'None' colorants
GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxSeparationColorSpace *cs;
GooString *nameA;
GfxColorSpace *altA;
......@@ -3003,7 +3003,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
}
//~ handle the 'None' colorant
GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion) {
int nCompsA;
GooString *namesA[gfxColorMaxComps];
GfxColorSpace *altA;
......@@ -3260,7 +3260,7 @@ GfxColorSpace *GfxPatternColorSpace::copy() {
nullptr);
}
GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion) {
GfxPatternColorSpace *cs;
GfxColorSpace *underA;
Object obj1;
......
......@@ -333,7 +333,7 @@ public:
GfxColorSpaceMode getMode() override { return csCalGray; }
// Construct a CalGray color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
static GfxColorSpace *parse(const Array *arr, GfxState *state);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -411,7 +411,7 @@ public:
GfxColorSpaceMode getMode() override { return csCalRGB; }
// Construct a CalRGB color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
static GfxColorSpace *parse(const Array *arr, GfxState *state);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -490,7 +490,7 @@ public:
GfxColorSpaceMode getMode() override { return csLab; }
// Construct a Lab color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(Array *arr, GfxState *state);
static GfxColorSpace *parse(const Array *arr, GfxState *state);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -540,7 +540,7 @@ public:
GfxColorSpaceMode getMode() override { return csICCBased; }
// Construct an ICCBased color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion);
static GfxColorSpace *parse(const Array *arr, OutputDev *out, GfxState *state, int recursion);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -591,7 +591,7 @@ public:
GfxColorSpaceMode getMode() override { return csIndexed; }
// Construct an Indexed color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
static GfxColorSpace *parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -644,7 +644,7 @@ public:
GfxColorSpaceMode getMode() override { return csSeparation; }
// Construct a Separation color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
static GfxColorSpace *parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -689,7 +689,7 @@ public:
GfxColorSpaceMode getMode() override { return csDeviceN; }
// Construct a DeviceN color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
static GfxColorSpace *parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......@@ -736,7 +736,7 @@ public:
GfxColorSpaceMode getMode() override { return csPattern; }
// Construct a Pattern color space. Returns nullptr if unsuccessful.
static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion);
static GfxColorSpace *parse(GfxResources *res, const Array *arr, OutputDev *out, GfxState *state, int recursion);
void getGray(const GfxColor *color, GfxGray *gray) const override;
void getRGB(const GfxColor *color, GfxRGB *rgb) const override;
......
......@@ -70,10 +70,9 @@ Lexer::Lexer(XRef *xrefA, Stream *str) {
xref = xrefA;
curStr = Object(str);
streams = new Array(xref);
streams->add(curStr.copy());
streams = Object{new Array(xref)};
streams.arrayAdd(curStr.copy());
strPtr = 0;
freeArray = true;
curStr.streamReset();
}
......@@ -82,16 +81,14 @@ Lexer::Lexer(XRef *xrefA, Object *obj) {
xref = xrefA;
if (obj->isStream()) {
streams = new Array(xref);
freeArray = true;
streams->add(obj->copy());
streams = Object{new Array(xref)};
streams.arrayAdd(obj->copy());
} else {
streams = obj->getArray();
freeArray = false;
streams = obj->copy();
}
strPtr = 0;
if (streams->getLength() > 0) {
curStr = streams->get(strPtr);
if (streams.arrayGetLength() > 0) {
curStr = streams.arrayGet(strPtr);
if (curStr.isStream()) {
curStr.streamReset();
}
......@@ -102,9 +99,6 @@ Lexer::~Lexer() {
if (curStr.isStream()) {
curStr.streamClose();
}
if (freeArray) {
delete streams;
}
}
int Lexer::getChar(bool comesFromLook) {
......@@ -124,8 +118,8 @@ int Lexer::getChar(bool comesFromLook) {
curStr.streamClose();
curStr = Object();
++strPtr;
if (strPtr < streams->getLength()) {
curStr = streams->get(strPtr);
if (strPtr < streams.arrayGetLength()) {
curStr = streams.arrayGet(strPtr);
if (curStr.isStream()) {
curStr.streamReset();
}
......
......@@ -100,10 +100,9 @@ private:
int getChar(bool comesFromLook = false);
int lookChar();
Array *streams; // array of input streams
Object streams; // array of input streams
int strPtr; // index of current stream
Object curStr; // current stream
bool freeArray; // should lexer free the streams array?
char tokBuf[tokBufSize]; // temporary token buffer
XRef *xref;
......
......@@ -70,7 +70,7 @@ Object Object::copy() const {
obj.cString = copyString(cString);
break;
case objArray:
array->incRef();
array->ref.fetch_add(1);
break;
case objDict:
dict->incRef();
......@@ -102,7 +102,7 @@ void Object::free() {
gfree(cString);
break;
case objArray:
if (!array->decRef()) {
if (array->ref.fetch_sub(1) == 1) {
delete array;
}
break;
......@@ -122,6 +122,17 @@ void Object::free() {
type = objNone;
}
void Object::detachArray() {
assert(type == objArray);
if (array->ref.load() == 1)
return;
auto *newArray = array->copy();
array->ref.fetch_sub(1);
array = newArray;
}
const char *Object::getTypeName() const {
return objTypeNames[type];
}
......
......@@ -260,7 +260,7 @@ public:
// After takeString() the only method that should be called for the object is free().
GooString *takeString() { OBJECT_TYPE_CHECK(objString); type = objDead; return string; }
const char *getName() const { OBJECT_TYPE_CHECK(objName); return cString; }
Array *getArray() const { OBJECT_TYPE_CHECK(objArray); return array; }
const Array *getArray() const { OBJECT_TYPE_CHECK(objArray); return array; }
Dict *getDict() const { OBJECT_TYPE_CHECK(objDict); return dict; }
Stream *getStream() const { OBJECT_TYPE_CHECK(objStream); return stream; }
Ref getRef() const { OBJECT_TYPE_CHECK(objRef); return ref; }
......@@ -311,6 +311,8 @@ private:
// Free object contents.
void free();
void detachArray();
ObjType type; // object type
union { // value for each type:
bool booln; // boolean
......@@ -336,10 +338,10 @@ inline int Object::arrayGetLength() const
{ OBJECT_TYPE_CHECK(objArray); return array->getLength(); }
inline void Object::arrayAdd(Object &&elem)
{ OBJECT_TYPE_CHECK(objArray); array->add(std::move(elem)); }
{ OBJECT_TYPE_CHECK(objArray); detachArray(); array->add(std::move(elem)); }
inline void Object::arrayRemove(int i)
{ OBJECT_TYPE_CHECK(objArray); array->remove(i); }
{ OBJECT_TYPE_CHECK(objArray); detachArray(); array->remove(i); }
inline Object Object::arrayGet(int i, int recursion = 0) const
{ OBJECT_TYPE_CHECK(objArray); return array->get(i, recursion); }
......
......@@ -244,7 +244,7 @@ bool OCGs::evalOCVisibilityExpr(const Object *expr, int recursion) {
return ret;
}
bool OCGs::allOn( Array *ocgArray )
bool OCGs::allOn( const Array *ocgArray )
{
for (int i = 0; i < ocgArray->getLength(); ++i) {
const Object &ocgItem = ocgArray->getNF(i);
......@@ -258,7 +258,7 @@ bool OCGs::allOn( Array *ocgArray )
return true;
}
bool OCGs::allOff( Array *ocgArray )
bool OCGs::allOff( const Array *ocgArray )
{
for (int i = 0; i < ocgArray->getLength(); ++i) {
const Object &ocgItem = ocgArray->getNF(i);
......@@ -272,7 +272,7 @@ bool OCGs::allOff( Array *ocgArray )
return true;
}
bool OCGs::anyOn( Array *ocgArray )
bool OCGs::anyOn( const Array *ocgArray )
{
for (int i = 0; i < ocgArray->getLength(); ++i) {
const Object &ocgItem = ocgArray->getNF(i);
......@@ -286,7 +286,7 @@ bool OCGs::anyOn( Array *ocgArray )
return false;
}
bool OCGs::anyOff( Array *ocgArray )
bool OCGs::anyOff(const Array *ocgArray )
{
for (int i = 0; i < ocgArray->getLength(); ++i) {
const Object &ocgItem = ocgArray->getNF(i);
......
......@@ -48,9 +48,9 @@ public:
// (which does not necessarily include all of the OCGs).
OCDisplayNode *getDisplayRoot();
Array* getOrderArray()
const Array* getOrderArray() const
{ return (order.isArray() && order.arrayGetLength() > 0) ? order.getArray() : nullptr; }
Array* getRBGroupsArray()
const Array* getRBGroupsArray() const
{ return (rbgroups.isArray() && rbgroups.arrayGetLength()) ? rbgroups.getArray() : nullptr; }
bool optContentIsVisible( const Object *dictRef );
......@@ -59,10 +59,10 @@ private:
bool ok;
bool evalOCVisibilityExpr(const Object *expr, int recursion);
bool allOn( Array *ocgArray );
bool allOff( Array *ocgArray );
bool anyOn( Array *ocgArray );
bool anyOff( Array *ocgArray );
bool allOn(const Array *ocgArray );
bool allOff( const Array *ocgArray );
bool anyOn( const Array *ocgArray );
bool anyOff( const Array *ocgArray );
std::unordered_map< Ref, std::unique_ptr< OptionalContentGroup > > optionalContentGroups;
......
......@@ -1366,7 +1366,7 @@ Goffset PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr)
void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, unsigned int numOffset, unsigned char *fileKey,
CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts)
{
Array *array;
const Array *array;
switch (obj->getType()) {
case objBool:
......@@ -1696,7 +1696,7 @@ void PDFDoc::markDictionnary (Dict* dict, XRef * xRef, XRef *countRef, unsigned
void PDFDoc::markObject (Object* obj, XRef *xRef, XRef *countRef, unsigned int numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts)
{
Array *array;
const Array *array;
switch (obj->getType()) {
case objArray:
......@@ -1806,9 +1806,8 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
bool modified = false;
Object annots = annotsObj->fetch(getXRef());
if (annots.isArray()) {
Array *array = annots.getArray();
for (int i=array->getLength() - 1; i >= 0; i--) {
Object obj1 = array->get(i);
for (int i=annots.arrayGetLength() - 1; i >= 0; i--) {
Object obj1 = annots.arrayGet(i);
if (obj1.isDict()) {
Dict *dict = obj1.getDict();
Object type = dict->lookup("Type");
......@@ -1816,7 +1815,7 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
const Object &obj2 = dict->lookupNF("P");
if (obj2.isRef()) {
if (obj2.getRef().num == oldPageNum) {
const Object &obj3 = array->getNF(i);
const Object &obj3 = annots.arrayGetNF(i);
if (obj3.isRef()) {
Ref r;
r.num = newPageNum;
......@@ -1835,7 +1834,7 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
continue;
}
}
array->remove(i);
annots.arrayRemove(i);
modified = true;
continue;
}
......@@ -1843,7 +1842,7 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
}
markPageObjects(dict, xRef, countRef, numOffset, oldPageNum, newPageNum, alreadyMarkedDicts);
}
obj1 = array->getNF(i).copy();
obj1 = annots.arrayGetNF(i).copy();
if (obj1.isRef()) {
if (obj1.getRef().num + (int) numOffset >= xRef->getNumObjects() || xRef->getEntry(obj1.getRef().num + numOffset)->type == xrefEntryFree) {
if (getXRef()->getEntry(obj1.getRef().num)->type == xrefEntryFree) {
......
......@@ -345,7 +345,7 @@ void Page::replaceXRef(XRef *xrefA) {
contents = pageDict->lookupNF("Contents").copy();
if (contents.isArray()) {
obj1 = pageDict->lookupNF("Contents").copy();
contents = obj1.getArray()->copy(xrefA);
contents = Object{obj1.getArray()->copy(xrefA)};
}
thumb = pageDict->lookupNF("Thumb").copy();
actions = pageDict->lookupNF("AA").copy();
......
......@@ -1607,7 +1607,7 @@ void XRef::markUnencrypted(Object *obj) {
switch (obj->getType()) {
case objArray:
{
Array *array = obj->getArray();
const Array *array = obj->getArray();
for (int i = 0; i < array->getLength(); i++) {
obj1 = array->getNF(i).copy();
markUnencrypted(&obj1);
......