Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Raphael Nestler
poppler
Commits
acd903c5
Commit
acd903c5
authored
May 21, 2017
by
Carlos Garcia Campos
Browse files
annots: Use std::unique_ptr instead of new/delete
parent
4a4393c0
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
glib/poppler-annot.cc
View file @
acd903c5
...
...
@@ -267,25 +267,20 @@ _poppler_annot_text_markup_new (Annot *annot)
static
AnnotQuadrilaterals
*
create_annot_quads_from_poppler_quads
(
GArray
*
quads
)
{
AnnotQuadrilaterals
::
AnnotQuadrilateral
**
quads_array
;
g_assert
(
quads
->
len
>
0
);
quads_array
=
(
AnnotQuadrilaterals
::
AnnotQuadrilateral
**
)
g_malloc0_n
(
sizeof
(
AnnotQuadrilaterals
::
AnnotQuadrilateral
*
),
quads
->
len
);
auto
quads_array
=
std
::
make_unique
<
AnnotQuadrilaterals
::
AnnotQuadrilateral
[]
>
(
quads
->
len
);
for
(
guint
i
=
0
;
i
<
quads
->
len
;
i
++
)
{
PopplerQuadrilateral
*
quadrilateral
=
&
g_array_index
(
quads
,
PopplerQuadrilateral
,
i
);
quads_array
[
i
]
=
new
AnnotQuadrilaterals
::
AnnotQuadrilateral
(
quads_array
[
i
]
=
AnnotQuadrilaterals
::
AnnotQuadrilateral
(
quadrilateral
->
p1
.
x
,
quadrilateral
->
p1
.
y
,
quadrilateral
->
p2
.
x
,
quadrilateral
->
p2
.
y
,
quadrilateral
->
p3
.
x
,
quadrilateral
->
p3
.
y
,
quadrilateral
->
p4
.
x
,
quadrilateral
->
p4
.
y
);
}
return
new
AnnotQuadrilaterals
(
quads_array
,
quads
->
len
);
return
new
AnnotQuadrilaterals
(
std
::
move
(
quads_array
)
,
quads
->
len
);
}
static
GArray
*
...
...
@@ -947,15 +942,15 @@ create_poppler_color_from_annot_color (AnnotColor *color)
return
poppler_color
;
}
static
AnnotColor
*
static
std
::
unique_ptr
<
AnnotColor
>
create_annot_color_from_poppler_color
(
PopplerColor
*
poppler_color
)
{
if
(
!
poppler_color
)
return
NULL
;
return
nullptr
;
return
new
AnnotColor
((
double
)
poppler_color
->
red
/
65535
,
(
double
)
poppler_color
->
green
/
65535
,
(
double
)
poppler_color
->
blue
/
65535
);
return
std
::
make_unique
<
AnnotColor
>
((
double
)
poppler_color
->
red
/
65535
,
(
double
)
poppler_color
->
green
/
65535
,
(
double
)
poppler_color
->
blue
/
65535
);
}
/**
...
...
@@ -988,7 +983,6 @@ void
poppler_annot_set_color
(
PopplerAnnot
*
poppler_annot
,
PopplerColor
*
poppler_color
)
{
/* Annot takes ownership of the color */
poppler_annot
->
annot
->
setColor
(
create_annot_color_from_poppler_color
(
poppler_color
));
}
...
...
@@ -1150,15 +1144,13 @@ poppler_annot_markup_set_popup (PopplerAnnotMarkup *poppler_annot,
PopplerRectangle
*
popup_rect
)
{
AnnotMarkup
*
annot
;
AnnotPopup
*
popup
;
PDFRectangle
pdf_rect
(
popup_rect
->
x1
,
popup_rect
->
y1
,
popup_rect
->
x2
,
popup_rect
->
y2
);
g_return_if_fail
(
POPPLER_IS_ANNOT_MARKUP
(
poppler_annot
));
annot
=
static_cast
<
AnnotMarkup
*>
(
POPPLER_ANNOT
(
poppler_annot
)
->
annot
);
popup
=
new
AnnotPopup
(
annot
->
getDoc
(),
&
pdf_rect
);
annot
->
setPopup
(
popup
);
annot
->
setPopup
(
std
::
make_unique
<
AnnotPopup
>
(
annot
->
getDoc
(),
&
pdf_rect
));
}
/**
...
...
@@ -1946,7 +1938,6 @@ poppler_annot_geometry_set_interior_color (PopplerAnnot *poppler_annot,
annot
=
static_cast
<
AnnotGeometry
*>
(
POPPLER_ANNOT
(
poppler_annot
)
->
annot
);
/* Annot takes ownership of the color */
annot
->
setInteriorColor
(
create_annot_color_from_poppler_color
(
poppler_color
));
}
...
...
poppler/Annot.cc
View file @
acd903c5
This diff is collapsed.
Click to expand it.
poppler/Annot.h
View file @
acd903c5
This diff is collapsed.
Click to expand it.
qt4/src/poppler-annotation-helper.h
View file @
acd903c5
...
...
@@ -176,6 +176,6 @@ void XPDFReader::invTransform( double * M, const QPointF &p, double &x, double &
}
QColor
convertAnnotColor
(
AnnotColor
*
color
);
AnnotColor
*
convertQColor
(
const
QColor
&
color
);
std
::
unique_ptr
<
AnnotColor
>
convertQColor
(
const
QColor
&
color
);
}
qt4/src/poppler-annotation.cc
View file @
acd903c5
...
...
@@ -350,7 +350,7 @@ PDFRectangle AnnotationPrivate::boundaryToPdfRectangle(const QRectF &r, int flag
AnnotPath
*
AnnotationPrivate
::
toAnnotPath
(
const
QLinkedList
<
QPointF
>
&
list
)
const
{
const
int
count
=
list
.
size
();
AnnotCoord
**
ac
=
(
AnnotCoord
**
)
gmallocn
(
count
,
sizeof
(
AnnotCoord
*
)
);
auto
ac
=
std
::
make_unique
<
AnnotCoord
[]
>
(
count
);
double
MTX
[
6
];
fillTransformationMTX
(
MTX
);
...
...
@@ -360,10 +360,10 @@ AnnotPath * AnnotationPrivate::toAnnotPath(const QLinkedList<QPointF> &list) con
{
double
x
,
y
;
XPDFReader
::
invTransform
(
MTX
,
p
,
x
,
y
);
ac
[
pos
++
]
=
new
AnnotCoord
(
x
,
y
);
ac
[
pos
++
]
=
AnnotCoord
(
x
,
y
);
}
return
new
AnnotPath
(
ac
,
count
);
return
new
AnnotPath
(
std
::
move
(
ac
)
,
count
);
}
QList
<
Annotation
*>
AnnotationPrivate
::
findAnnotations
(
::
Page
*
pdfPage
,
DocumentData
*
doc
,
const
QSet
<
Annotation
::
SubType
>
&
subtypes
,
int
parentID
)
...
...
@@ -1653,11 +1653,11 @@ void Annotation::setStyle( const Annotation::Style& style )
if
(
markupann
)
markupann
->
setOpacity
(
style
.
opacity
()
);
AnnotBorderArray
*
border
=
new
AnnotBorderArray
();
auto
border
=
std
::
make_unique
<
AnnotBorderArray
>
();
border
->
setWidth
(
style
.
width
()
);
border
->
setHorizontalCorner
(
style
.
xCorners
()
);
border
->
setVerticalCorner
(
style
.
yCorners
()
);
d
->
pdfAnnot
->
setBorder
(
border
);
d
->
pdfAnnot
->
setBorder
(
std
::
move
(
border
)
)
;
}
Annotation
::
Popup
Annotation
::
popup
()
const
...
...
@@ -2721,17 +2721,17 @@ void LineAnnotation::setLineInnerColor( const QColor &color )
return
;
}
AnnotColor
*
c
=
convertQColor
(
color
);
auto
c
=
convertQColor
(
color
);
if
(
d
->
pdfAnnot
->
getType
()
==
Annot
::
typeLine
)
{
AnnotLine
*
lineann
=
static_cast
<
AnnotLine
*>
(
d
->
pdfAnnot
);
lineann
->
setInteriorColor
(
c
);
lineann
->
setInteriorColor
(
std
::
move
(
c
)
);
}
else
{
AnnotPolygon
*
polyann
=
static_cast
<
AnnotPolygon
*>
(
d
->
pdfAnnot
);
polyann
->
setInteriorColor
(
c
);
polyann
->
setInteriorColor
(
std
::
move
(
c
)
);
}
}
...
...
@@ -5077,12 +5077,12 @@ QColor convertAnnotColor( AnnotColor *color )
return
newcolor
;
}
AnnotColor
*
convertQColor
(
const
QColor
&
c
)
std
::
unique_ptr
<
AnnotColor
>
convertQColor
(
const
QColor
&
c
)
{
if
(
!
c
.
isValid
()
||
c
.
alpha
()
==
0
)
return
new
AnnotColor
();
// Transparent
return
std
::
make_unique
<
AnnotColor
>
();
// Transparent
else
return
new
AnnotColor
(
c
.
redF
(),
c
.
greenF
(),
c
.
blueF
());
return
std
::
make_unique
<
AnnotColor
>
(
c
.
redF
(),
c
.
greenF
(),
c
.
blueF
());
}
//END utility annotation functions
...
...
qt5/src/poppler-annotation-helper.h
View file @
acd903c5
...
...
@@ -176,6 +176,6 @@ void XPDFReader::invTransform( double * M, const QPointF &p, double &x, double &
}
QColor
convertAnnotColor
(
AnnotColor
*
color
);
AnnotColor
*
convertQColor
(
const
QColor
&
color
);
std
::
unique_ptr
<
AnnotColor
>
convertQColor
(
const
QColor
&
color
);
}
qt5/src/poppler-annotation.cc
View file @
acd903c5
...
...
@@ -350,7 +350,7 @@ PDFRectangle AnnotationPrivate::boundaryToPdfRectangle(const QRectF &r, int flag
AnnotPath
*
AnnotationPrivate
::
toAnnotPath
(
const
QLinkedList
<
QPointF
>
&
list
)
const
{
const
int
count
=
list
.
size
();
AnnotCoord
**
ac
=
(
AnnotCoord
**
)
gmallocn
(
count
,
sizeof
(
AnnotCoord
*
)
);
auto
ac
=
std
::
make_unique
<
AnnotCoord
[]
>
(
count
);
double
MTX
[
6
];
fillTransformationMTX
(
MTX
);
...
...
@@ -360,10 +360,10 @@ AnnotPath * AnnotationPrivate::toAnnotPath(const QLinkedList<QPointF> &list) con
{
double
x
,
y
;
XPDFReader
::
invTransform
(
MTX
,
p
,
x
,
y
);
ac
[
pos
++
]
=
new
AnnotCoord
(
x
,
y
);
ac
[
pos
++
]
=
AnnotCoord
(
x
,
y
);
}
return
new
AnnotPath
(
ac
,
count
);
return
new
AnnotPath
(
std
::
move
(
ac
)
,
count
);
}
QList
<
Annotation
*>
AnnotationPrivate
::
findAnnotations
(
::
Page
*
pdfPage
,
DocumentData
*
doc
,
const
QSet
<
Annotation
::
SubType
>
&
subtypes
,
int
parentID
)
...
...
@@ -1650,11 +1650,11 @@ void Annotation::setStyle( const Annotation::Style& style )
if
(
markupann
)
markupann
->
setOpacity
(
style
.
opacity
()
);
AnnotBorderArray
*
border
=
new
AnnotBorderArray
();
auto
border
=
std
::
make_unique
<
AnnotBorderArray
>
();
border
->
setWidth
(
style
.
width
()
);
border
->
setHorizontalCorner
(
style
.
xCorners
()
);
border
->
setVerticalCorner
(
style
.
yCorners
()
);
d
->
pdfAnnot
->
setBorder
(
border
);
d
->
pdfAnnot
->
setBorder
(
std
::
move
(
border
)
)
;
}
Annotation
::
Popup
Annotation
::
popup
()
const
...
...
@@ -2708,17 +2708,17 @@ void LineAnnotation::setLineInnerColor( const QColor &color )
return
;
}
AnnotColor
*
c
=
convertQColor
(
color
);
auto
c
=
convertQColor
(
color
);
if
(
d
->
pdfAnnot
->
getType
()
==
Annot
::
typeLine
)
{
AnnotLine
*
lineann
=
static_cast
<
AnnotLine
*>
(
d
->
pdfAnnot
);
lineann
->
setInteriorColor
(
c
);
lineann
->
setInteriorColor
(
std
::
move
(
c
)
);
}
else
{
AnnotPolygon
*
polyann
=
static_cast
<
AnnotPolygon
*>
(
d
->
pdfAnnot
);
polyann
->
setInteriorColor
(
c
);
polyann
->
setInteriorColor
(
std
::
move
(
c
)
);
}
}
...
...
@@ -5065,12 +5065,12 @@ QColor convertAnnotColor( AnnotColor *color )
return
newcolor
;
}
AnnotColor
*
convertQColor
(
const
QColor
&
c
)
std
::
unique_ptr
<
AnnotColor
>
convertQColor
(
const
QColor
&
c
)
{
if
(
!
c
.
isValid
()
||
c
.
alpha
()
==
0
)
return
new
AnnotColor
();
// Transparent
return
std
::
make_unique
<
AnnotColor
>
();
// Transparent
else
return
new
AnnotColor
(
c
.
redF
(),
c
.
greenF
(),
c
.
blueF
());
return
std
::
make_unique
<
AnnotColor
>
(
c
.
redF
(),
c
.
greenF
(),
c
.
blueF
());
}
//END utility annotation functions
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment