Commit fc555c75 authored by Albert Astals Cid's avatar Albert Astals Cid

Object: Add constructor that takes a const Ref

makes it easier to not have to unbox the Ref for no reason
parent 5f6ff67b
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2007-2013, 2015-2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007-2013, 2015-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007-2013, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
......@@ -1439,8 +1439,8 @@ void Annot::setPage(int pageIndex, bool updateP) {
Object obj1(objNull);
if (pageobj) {
Ref pageRef = pageobj->getRef();
obj1 = Object(pageRef.num, pageRef.gen);
const Ref pageRef = pageobj->getRef();
obj1 = Object(pageRef);
page = pageIndex;
} else {
page = 0;
......@@ -1881,7 +1881,7 @@ void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) {
void AnnotPopup::setParent(Annot *parentA) {
const Ref parentRef = parentA->getRef();
update ("Parent", Object(parentRef.num, parentRef.gen));
update ("Parent", Object(parentRef));
}
void AnnotPopup::setOpen(bool openA) {
......@@ -1994,7 +1994,7 @@ void AnnotMarkup::setPopup(std::unique_ptr<AnnotPopup> &&new_popup) {
if (new_popup) {
const Ref popupRef = new_popup->getRef();
update ("Popup", Object(popupRef.num, popupRef.gen));
update ("Popup", Object(popupRef));
new_popup->setParent(this);
popup = std::move(new_popup);
......@@ -4920,7 +4920,7 @@ void AnnotWidget::updateAppearanceStream()
// Write the AP dictionary
obj1 = Object(new Dict(xref));
obj1.dictAdd("N", Object(updatedAppearanceStream.num, updatedAppearanceStream.gen));
obj1.dictAdd("N", Object(updatedAppearanceStream));
// Update our internal pointers to the appearance dictionary
appearStreams = std::make_unique<AnnotAppearance>(doc, &obj1);
......
......@@ -112,7 +112,7 @@ void FormWidget::createWidgetAnnotation() {
if (widget)
return;
Object obj1(ref.num, ref.gen);
Object obj1(ref);
widget = new AnnotWidget(doc, &obj, &obj1, field);
}
......
......@@ -407,7 +407,7 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) {
t = fontUnknownType;
if (embID->num >= 0) {
Object obj3(embID->num, embID->gen);
Object obj3(*embID);
Object obj4 = obj3.fetch(xref);
if (obj4.isStream()) {
obj4.streamReset();
......@@ -603,7 +603,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) {
//----- embedded font
if (embFontID.num >= 0) {
embed = true;
Object refObj(embFontID.num, embFontID.gen);
Object refObj(embFontID);
Object embFontObj = refObj.fetch(xref);
if (!embFontObj.isStream()) {
error(errSyntaxError, -1, "Embedded font object is wrong type");
......@@ -819,7 +819,7 @@ char *GfxFont::readEmbFontFile(XRef *xref, int *len) {
char *buf;
Stream *str;
Object obj1(embFontID.num, embFontID.gen);
Object obj1(embFontID);
Object obj2 = obj1.fetch(xref);
if (!obj2.isStream()) {
error(errSyntaxError, -1, "Embedded font file is not a stream");
......
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2008 Kees Cook <kees@outflux.net>
// Copyright (C) 2008, 2010, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008, 2010, 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Jakub Wilk <jwilk@jwilk.net>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
......@@ -174,6 +174,8 @@ public:
{ assert(streamA); type = objStream; stream = streamA; }
Object(int numA, int genA)
{ type = objRef; ref.num = numA; ref.gen = genA; }
Object(const Ref r)
{ type = objRef; ref.num = r.num; ref.gen = r.gen; }
template<typename T> Object(T) = delete;
......
......@@ -1583,7 +1583,7 @@ Object PDFDoc::createTrailerDict(int uxrefSize, bool incrUpdate, Goffset startxR
trailerDict->set("ID", Object(array));
}
trailerDict->set("Root", Object(root->num, root->gen));
trailerDict->set("Root", Object(*root));
if (incrUpdate) {
trailerDict->set("Prev", Object(startxRef));
......
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006-2009, 2011-2013, 2015-2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006-2009, 2011-2013, 2015-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org>
// Copyright (C) 2008, 2009 Koji Otani <sho@bbr.jp>
......@@ -2119,7 +2119,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
// get the font stream and info
Object obj1, obj2, obj3;
Object refObj(id->num, id->gen);
Object refObj(*id);
Object strObj = refObj.fetch(xref);
if (!strObj.isStream()) {
error(errSyntaxError, -1, "Embedded font file object is not a stream");
......
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005-2013, 2016-2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005-2013, 2016-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006-2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
......@@ -366,7 +366,7 @@ Annots *Page::getAnnots(XRef *xrefA) {
}
void Page::addAnnot(Annot *annot) {
Ref annotRef = annot->getRef ();
const Ref annotRef = annot->getRef ();
// Make sure we have annots before adding the new one
// even if it's an empty list so that we can safely
......@@ -380,16 +380,16 @@ void Page::addAnnot(Annot *annot) {
// we have to create it
Object obj1 = Object(new Array(xref));
obj1.arrayAdd(Object(annotRef.num, annotRef.gen));
obj1.arrayAdd(Object(annotRef));
annotsRef = xref->addIndirectObject (&obj1);
annotsObj = Object(annotsRef.num, annotsRef.gen);
pageObj.dictSet ("Annots", Object(annotsRef.num, annotsRef.gen));
annotsObj = Object(annotsRef);
pageObj.dictSet ("Annots", Object(annotsRef));
xref->setModifiedObject (&pageObj, pageRef);
} else {
Object obj1 = getAnnotsObject();
if (obj1.isArray()) {
obj1.arrayAdd (Object(annotRef.num, annotRef.gen));
obj1.arrayAdd (Object(annotRef));
if (annotsObj.isRef())
xref->setModifiedObject (&obj1, annotsObj.getRef());
else
......
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2005 Dan Sheridan <dan.sheridan@postman.org.uk>
// Copyright (C) 2005 Brad Hards <bradh@frogmouth.net>
// Copyright (C) 2006, 2008, 2010, 2012-2014, 2016-2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2008, 2010, 2012-2014, 2016-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009, 2010 Ilya Gorenbein <igorenbein@finjan.com>
......@@ -1206,7 +1206,7 @@ Object XRef::createDocInfoIfNoneExists() {
obj = Object(new Dict(this));
const Ref ref = addIndirectObject(&obj);
trailerDict.dictSet("Info", Object(ref.num, ref.gen));
trailerDict.dictSet("Info", Object(ref));
return obj;
}
......
/* poppler-document.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, 2008, Brad Hards <bradh@frogmouth.net>
* Copyright (C) 2005-2010, 2012, 2013, 2015, 2017, 2018, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2005-2010, 2012, 2013, 2015, 2017-2019, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2006-2010, Pino Toscano <pino@kde.org>
* Copyright (C) 2010, 2011 Hib Eris <hib@hiberis.nl>
* Copyright (C) 2012 Koji Otani <sho@bbr.jp>
......@@ -246,7 +246,7 @@ namespace Poppler {
{
XRef *xref = m_doc->doc->getXRef()->copy();
Object refObj(fi.m_data->embRef.num, fi.m_data->embRef.gen);
Object refObj(fi.m_data->embRef);
Object strObj = refObj.fetch(xref);
if (strObj.isStream())
{
......
......@@ -7,7 +7,7 @@
// Copyright (C) 2011-2015, 2017 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2012, 2014, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012, 2014, 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2013 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2015 Arthur Stavisky <vovodroid@gmail.com>
......@@ -68,7 +68,7 @@ static void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldR
}
}
newNameArray->add(Object(new GooString(key.getString()->c_str())));
newNameArray->add(Object(value.getRef().num, value.getRef().gen));
newNameArray->add(Object(value.getRef()));
}
}
while (j < mergeNameArray.arrayGetLength() - 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment