[poppler] 4 commits - poppler/GfxState.cc poppler/TextOutputDev.cc poppler/TextOutputDev.h qt4/src qt5/src
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Sep 8 08:52:08 PDT 2015
poppler/GfxState.cc | 14
poppler/TextOutputDev.cc | 4
poppler/TextOutputDev.h | 6
qt4/src/poppler-annotation.cc | 4
qt4/src/poppler-document.cc | 3
qt4/src/poppler-fontinfo.cc | 3
qt4/src/poppler-form.cc | 3
qt4/src/poppler-optcontent.cc | 2
qt4/src/poppler-page.cc | 1
qt5/src/poppler-annotation.cc | 612 +++++++++++++++++++++---------------------
qt5/src/poppler-document.cc | 3
qt5/src/poppler-fontinfo.cc | 3
qt5/src/poppler-form.cc | 3
qt5/src/poppler-optcontent.cc | 2
qt5/src/poppler-page.cc | 1
qt5/src/poppler-private.cc | 18 -
16 files changed, 348 insertions(+), 334 deletions(-)
New commits:
commit fc69a5e7dab48636946282e5d4b7be77e650023c
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Sep 8 17:48:49 2015 +0200
Qt5: Minor optimizations
Call reserve on containers
Use QStringLiteral/QLatin1String
diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index 1de4903..5457ef5 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -1,5 +1,5 @@
/* poppler-annotation.cc: qt interface to poppler
- * Copyright (C) 2006, 2009, 2012-2014 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2009, 2012-2015 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006, 2008, 2010 Pino Toscano <pino at kde.org>
* Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
* Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso at hotmail.it>
@@ -58,12 +58,12 @@ namespace Poppler {
Annotation * AnnotationUtils::createAnnotation( const QDomElement & annElement )
{
// safety check on annotation element
- if ( !annElement.hasAttribute( "type" ) )
+ if ( !annElement.hasAttribute( QStringLiteral("type") ) )
return 0;
// build annotation of given type
Annotation * annotation = 0;
- int typeNumber = annElement.attribute( "type" ).toInt();
+ int typeNumber = annElement.attribute( QStringLiteral("type") ).toInt();
switch ( typeNumber )
{
case Annotation::AText:
@@ -97,7 +97,7 @@ void AnnotationUtils::storeAnnotation( const Annotation * ann, QDomElement & ann
QDomDocument & document )
{
// save annotation's type as element's attribute
- annElement.setAttribute( "type", (uint)ann->subType() );
+ annElement.setAttribute( QStringLiteral("type"), (uint)ann->subType() );
// append all annotation data as children of this node
ann->store( annElement, document );
@@ -1073,7 +1073,7 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
Q_D( Annotation );
// get the [base] element of the annotation node
- QDomElement e = AnnotationUtils::findChildElement( annNode, "base" );
+ QDomElement e = AnnotationUtils::findChildElement( annNode, QStringLiteral("base") );
if ( e.isNull() )
return;
@@ -1081,24 +1081,24 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
Popup w;
// parse -contents- attributes
- if ( e.hasAttribute( "author" ) )
- setAuthor(e.attribute( "author" ));
- if ( e.hasAttribute( "contents" ) )
- setContents(e.attribute( "contents" ));
- if ( e.hasAttribute( "uniqueName" ) )
- setUniqueName(e.attribute( "uniqueName" ));
- if ( e.hasAttribute( "modifyDate" ) )
- setModificationDate(QDateTime::fromString( e.attribute( "modifyDate" ) ));
- if ( e.hasAttribute( "creationDate" ) )
- setCreationDate(QDateTime::fromString( e.attribute( "creationDate" ) ));
+ if ( e.hasAttribute( QStringLiteral("author") ) )
+ setAuthor(e.attribute( QStringLiteral("author") ));
+ if ( e.hasAttribute( QStringLiteral("contents") ) )
+ setContents(e.attribute( QStringLiteral("contents") ));
+ if ( e.hasAttribute( QStringLiteral("uniqueName") ) )
+ setUniqueName(e.attribute( QStringLiteral("uniqueName") ));
+ if ( e.hasAttribute( QStringLiteral("modifyDate") ) )
+ setModificationDate(QDateTime::fromString( e.attribute( QStringLiteral("modifyDate") ) ));
+ if ( e.hasAttribute( QStringLiteral("creationDate") ) )
+ setCreationDate(QDateTime::fromString( e.attribute( QStringLiteral("creationDate") ) ));
// parse -other- attributes
- if ( e.hasAttribute( "flags" ) )
- setFlags(e.attribute( "flags" ).toInt());
- if ( e.hasAttribute( "color" ) )
- s.setColor(QColor( e.attribute( "color" ) ));
- if ( e.hasAttribute( "opacity" ) )
- s.setOpacity(e.attribute( "opacity" ).toDouble());
+ if ( e.hasAttribute( QStringLiteral("flags") ) )
+ setFlags(e.attribute( QStringLiteral("flags") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("color") ) )
+ s.setColor(QColor( e.attribute( QStringLiteral("color") ) ));
+ if ( e.hasAttribute( QStringLiteral("opacity") ) )
+ s.setOpacity(e.attribute( QStringLiteral("opacity") ).toDouble());
// parse -the-subnodes- (describing Style, Window, Revision(s) structures)
// Note: all subnodes if present must be 'attributes complete'
@@ -1109,22 +1109,22 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
eSubNode = eSubNode.nextSibling();
// parse boundary
- if ( ee.tagName() == "boundary" )
+ if ( ee.tagName() == QLatin1String("boundary") )
{
QRectF brect;
- brect.setLeft(ee.attribute( "l" ).toDouble());
- brect.setTop(ee.attribute( "t" ).toDouble());
- brect.setRight(ee.attribute( "r" ).toDouble());
- brect.setBottom(ee.attribute( "b" ).toDouble());
+ brect.setLeft(ee.attribute( QStringLiteral("l") ).toDouble());
+ brect.setTop(ee.attribute( QStringLiteral("t") ).toDouble());
+ brect.setRight(ee.attribute( QStringLiteral("r") ).toDouble());
+ brect.setBottom(ee.attribute( QStringLiteral("b") ).toDouble());
setBoundary(brect);
}
// parse penStyle if not default
- else if ( ee.tagName() == "penStyle" )
+ else if ( ee.tagName() == QLatin1String("penStyle") )
{
- s.setWidth(ee.attribute( "width" ).toDouble());
- s.setLineStyle((LineStyle)ee.attribute( "style" ).toInt());
- s.setXCorners(ee.attribute( "xcr" ).toDouble());
- s.setYCorners(ee.attribute( "ycr" ).toDouble());
+ s.setWidth(ee.attribute( QStringLiteral("width") ).toDouble());
+ s.setLineStyle((LineStyle)ee.attribute( QStringLiteral("style") ).toInt());
+ s.setXCorners(ee.attribute( QStringLiteral("xcr") ).toDouble());
+ s.setYCorners(ee.attribute( QStringLiteral("ycr") ).toDouble());
// Try to parse dash array (new format)
QVector<double> dashArray;
@@ -1135,55 +1135,55 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
QDomElement eee = eeSubNode.toElement();
eeSubNode = eeSubNode.nextSibling();
- if ( eee.tagName() != "dashsegm" )
+ if ( eee.tagName() != QLatin1String("dashsegm") )
continue;
- dashArray.append(eee.attribute( "len" ).toDouble());
+ dashArray.append(eee.attribute( QStringLiteral("len") ).toDouble());
}
// If no segments were found use marks/spaces (old format)
if ( dashArray.size() == 0 )
{
- dashArray.append(ee.attribute( "marks" ).toDouble());
- dashArray.append(ee.attribute( "spaces" ).toDouble());
+ dashArray.append(ee.attribute( QStringLiteral("marks") ).toDouble());
+ dashArray.append(ee.attribute( QStringLiteral("spaces") ).toDouble());
}
s.setDashArray(dashArray);
}
// parse effectStyle if not default
- else if ( ee.tagName() == "penEffect" )
+ else if ( ee.tagName() == QLatin1String("penEffect") )
{
- s.setLineEffect((LineEffect)ee.attribute( "effect" ).toInt());
- s.setEffectIntensity(ee.attribute( "intensity" ).toDouble());
+ s.setLineEffect((LineEffect)ee.attribute( QStringLiteral("effect") ).toInt());
+ s.setEffectIntensity(ee.attribute( QStringLiteral("intensity") ).toDouble());
}
// parse window if present
- else if ( ee.tagName() == "window" )
+ else if ( ee.tagName() == QLatin1String("window") )
{
QRectF geom;
- geom.setX(ee.attribute( "top" ).toDouble());
- geom.setY(ee.attribute( "left" ).toDouble());
+ geom.setX(ee.attribute( QStringLiteral("top") ).toDouble());
+ geom.setY(ee.attribute( QStringLiteral("left") ).toDouble());
- if (ee.hasAttribute("widthDouble"))
- geom.setWidth(ee.attribute( "widthDouble" ).toDouble());
+ if (ee.hasAttribute(QStringLiteral("widthDouble")))
+ geom.setWidth(ee.attribute( QStringLiteral("widthDouble") ).toDouble());
else
- geom.setWidth(ee.attribute( "width" ).toDouble());
+ geom.setWidth(ee.attribute( QStringLiteral("width") ).toDouble());
- if (ee.hasAttribute("widthDouble"))
- geom.setHeight(ee.attribute( "heightDouble" ).toDouble());
+ if (ee.hasAttribute(QStringLiteral("widthDouble")))
+ geom.setHeight(ee.attribute( QStringLiteral("heightDouble") ).toDouble());
else
- geom.setHeight(ee.attribute( "height" ).toDouble());
+ geom.setHeight(ee.attribute( QStringLiteral("height") ).toDouble());
w.setGeometry(geom);
- w.setFlags(ee.attribute( "flags" ).toInt());
- w.setTitle(ee.attribute( "title" ));
- w.setSummary(ee.attribute( "summary" ));
+ w.setFlags(ee.attribute( QStringLiteral("flags") ).toInt());
+ w.setTitle(ee.attribute( QStringLiteral("title") ));
+ w.setSummary(ee.attribute( QStringLiteral("summary") ));
// parse window subnodes
QDomNode winNode = ee.firstChild();
for ( ; winNode.isElement(); winNode = winNode.nextSibling() )
{
QDomElement winElement = winNode.toElement();
- if ( winElement.tagName() == "text" )
+ if ( winElement.tagName() == QLatin1String("text") )
w.setText(winElement.firstChild().toCDATASection().data());
}
}
@@ -1197,15 +1197,15 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
for ( ; revNode.isElement(); revNode = revNode.nextSibling() )
{
QDomElement revElement = revNode.toElement();
- if ( revElement.tagName() != "revision" )
+ if ( revElement.tagName() != QLatin1String("revision") )
continue;
Annotation *reply = AnnotationUtils::createAnnotation( revElement );
if (reply) // if annotation is valid, add as a revision of this annotation
{
- RevScope scope = (RevScope)revElement.attribute( "revScope" ).toInt();
- RevType type = (RevType)revElement.attribute( "revType" ).toInt();
+ RevScope scope = (RevScope)revElement.attribute( QStringLiteral("revScope") ).toInt();
+ RevType type = (RevType)revElement.attribute( QStringLiteral("revType") ).toInt();
d->addRevision(reply, scope, type);
delete reply;
}
@@ -1215,7 +1215,7 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
void Annotation::storeBaseAnnotationProperties( QDomNode & annNode, QDomDocument & document ) const
{
// create [base] element of the annotation node
- QDomElement e = document.createElement( "base" );
+ QDomElement e = document.createElement( QStringLiteral("base") );
annNode.appendChild( e );
const Style s = style();
@@ -1223,44 +1223,44 @@ void Annotation::storeBaseAnnotationProperties( QDomNode & annNode, QDomDocument
// store -contents- attributes
if ( !author().isEmpty() )
- e.setAttribute( "author", author() );
+ e.setAttribute( QStringLiteral("author"), author() );
if ( !contents().isEmpty() )
- e.setAttribute( "contents", contents() );
+ e.setAttribute( QStringLiteral("contents"), contents() );
if ( !uniqueName().isEmpty() )
- e.setAttribute( "uniqueName", uniqueName() );
+ e.setAttribute( QStringLiteral("uniqueName"), uniqueName() );
if ( modificationDate().isValid() )
- e.setAttribute( "modifyDate", modificationDate().toString() );
+ e.setAttribute( QStringLiteral("modifyDate"), modificationDate().toString() );
if ( creationDate().isValid() )
- e.setAttribute( "creationDate", creationDate().toString() );
+ e.setAttribute( QStringLiteral("creationDate"), creationDate().toString() );
// store -other- attributes
if ( flags() )
- e.setAttribute( "flags", flags() );
+ e.setAttribute( QStringLiteral("flags"), flags() );
if ( s.color().isValid() )
- e.setAttribute( "color", s.color().name() );
+ e.setAttribute( QStringLiteral("color"), s.color().name() );
if ( s.opacity() != 1.0 )
- e.setAttribute( "opacity", QString::number( s.opacity() ) );
+ e.setAttribute( QStringLiteral("opacity"), QString::number( s.opacity() ) );
// Sub-Node-1 - boundary
const QRectF brect = boundary();
- QDomElement bE = document.createElement( "boundary" );
+ QDomElement bE = document.createElement( QStringLiteral("boundary") );
e.appendChild( bE );
- bE.setAttribute( "l", QString::number( (double)brect.left() ) );
- bE.setAttribute( "t", QString::number( (double)brect.top() ) );
- bE.setAttribute( "r", QString::number( (double)brect.right() ) );
- bE.setAttribute( "b", QString::number( (double)brect.bottom() ) );
+ bE.setAttribute( QStringLiteral("l"), QString::number( (double)brect.left() ) );
+ bE.setAttribute( QStringLiteral("t"), QString::number( (double)brect.top() ) );
+ bE.setAttribute( QStringLiteral("r"), QString::number( (double)brect.right() ) );
+ bE.setAttribute( QStringLiteral("b"), QString::number( (double)brect.bottom() ) );
// Sub-Node-2 - penStyle
const QVector<double> dashArray = s.dashArray();
if ( s.width() != 1 || s.lineStyle() != Solid || s.xCorners() != 0 ||
s.yCorners() != 0.0 || dashArray.size() != 1 || dashArray[0] != 3 )
{
- QDomElement psE = document.createElement( "penStyle" );
+ QDomElement psE = document.createElement( QStringLiteral("penStyle") );
e.appendChild( psE );
- psE.setAttribute( "width", QString::number( s.width() ) );
- psE.setAttribute( "style", (int)s.lineStyle() );
- psE.setAttribute( "xcr", QString::number( s.xCorners() ) );
- psE.setAttribute( "ycr", QString::number( s.yCorners() ) );
+ psE.setAttribute( QStringLiteral("width"), QString::number( s.width() ) );
+ psE.setAttribute( QStringLiteral("style"), (int)s.lineStyle() );
+ psE.setAttribute( QStringLiteral("xcr"), QString::number( s.xCorners() ) );
+ psE.setAttribute( QStringLiteral("ycr"), QString::number( s.yCorners() ) );
int marks = 3, spaces = 0; // Do not break code relying on marks/spaces
if (dashArray.size() != 0)
@@ -1268,13 +1268,13 @@ void Annotation::storeBaseAnnotationProperties( QDomNode & annNode, QDomDocument
if (dashArray.size() > 1)
spaces = (int)dashArray[1];
- psE.setAttribute( "marks", marks );
- psE.setAttribute( "spaces", spaces );
+ psE.setAttribute( QStringLiteral("marks"), marks );
+ psE.setAttribute( QStringLiteral("spaces"), spaces );
foreach (double segm, dashArray)
{
- QDomElement pattE = document.createElement( "dashsegm" );
- pattE.setAttribute( "len", QString::number( segm ) );
+ QDomElement pattE = document.createElement( QStringLiteral("dashsegm") );
+ pattE.setAttribute( QStringLiteral("len"), QString::number( segm ) );
psE.appendChild(pattE);
}
}
@@ -1282,32 +1282,32 @@ void Annotation::storeBaseAnnotationProperties( QDomNode & annNode, QDomDocument
// Sub-Node-3 - penEffect
if ( s.lineEffect() != NoEffect || s.effectIntensity() != 1.0 )
{
- QDomElement peE = document.createElement( "penEffect" );
+ QDomElement peE = document.createElement( QStringLiteral("penEffect") );
e.appendChild( peE );
- peE.setAttribute( "effect", (int)s.lineEffect() );
- peE.setAttribute( "intensity", QString::number( s.effectIntensity() ) );
+ peE.setAttribute( QStringLiteral("effect"), (int)s.lineEffect() );
+ peE.setAttribute( QStringLiteral("intensity"), QString::number( s.effectIntensity() ) );
}
// Sub-Node-4 - window
if ( w.flags() != -1 || !w.title().isEmpty() || !w.summary().isEmpty() ||
!w.text().isEmpty() )
{
- QDomElement wE = document.createElement( "window" );
+ QDomElement wE = document.createElement( QStringLiteral("window") );
const QRectF geom = w.geometry();
e.appendChild( wE );
- wE.setAttribute( "flags", w.flags() );
- wE.setAttribute( "top", QString::number( geom.x() ) );
- wE.setAttribute( "left", QString::number( geom.y() ) );
- wE.setAttribute( "width", (int)geom.width() );
- wE.setAttribute( "height", (int)geom.height() );
- wE.setAttribute( "widthDouble", QString::number( geom.width() ) );
- wE.setAttribute( "heightDouble", QString::number( geom.height() ) );
- wE.setAttribute( "title", w.title() );
- wE.setAttribute( "summary", w.summary() );
+ wE.setAttribute( QStringLiteral("flags"), w.flags() );
+ wE.setAttribute( QStringLiteral("top"), QString::number( geom.x() ) );
+ wE.setAttribute( QStringLiteral("left"), QString::number( geom.y() ) );
+ wE.setAttribute( QStringLiteral("width"), (int)geom.width() );
+ wE.setAttribute( QStringLiteral("height"), (int)geom.height() );
+ wE.setAttribute( QStringLiteral("widthDouble"), QString::number( geom.width() ) );
+ wE.setAttribute( QStringLiteral("heightDouble"), QString::number( geom.height() ) );
+ wE.setAttribute( QStringLiteral("title"), w.title() );
+ wE.setAttribute( QStringLiteral("summary"), w.summary() );
// store window.text as a subnode, because we need escaped data
if ( !w.text().isEmpty() )
{
- QDomElement escapedText = document.createElement( "text" );
+ QDomElement escapedText = document.createElement( QStringLiteral("text") );
wE.appendChild( escapedText );
QDomCDATASection textCData = document.createCDATASection( w.text() );
escapedText.appendChild( textCData );
@@ -1323,11 +1323,11 @@ void Annotation::storeBaseAnnotationProperties( QDomNode & annNode, QDomDocument
// add all revisions as children of revisions element
foreach (const Annotation *rev, revs)
{
- QDomElement r = document.createElement( "revision" );
+ QDomElement r = document.createElement( QStringLiteral("revision") );
annNode.appendChild( r );
// set element attributes
- r.setAttribute( "revScope", (int)rev->revisionScope() );
- r.setAttribute( "revType", (int)rev->revisionType() );
+ r.setAttribute( QStringLiteral("revScope"), (int)rev->revisionScope() );
+ r.setAttribute( QStringLiteral("revType"), (int)rev->revisionType() );
// use revision as the annotation element, so fill it up
AnnotationUtils::storeAnnotation( rev, r, document );
delete rev;
@@ -1840,7 +1840,7 @@ class TextAnnotationPrivate : public AnnotationPrivate
TextAnnotationPrivate::TextAnnotationPrivate()
: AnnotationPrivate(), textType( TextAnnotation::Linked ),
- textIcon( "Note" ), inplaceAlign( 0 ),
+ textIcon( QStringLiteral("Note") ), inplaceAlign( 0 ),
inplaceIntent( TextAnnotation::Unknown )
{
}
@@ -1912,24 +1912,24 @@ TextAnnotation::TextAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "text" )
+ if ( e.tagName() != QLatin1String("text") )
continue;
// parse the attributes
- if ( e.hasAttribute( "type" ) )
- setTextType((TextAnnotation::TextType)e.attribute( "type" ).toInt());
- if ( e.hasAttribute( "icon" ) )
- setTextIcon(e.attribute( "icon" ));
- if ( e.hasAttribute( "font" ) )
+ if ( e.hasAttribute( QStringLiteral("type") ) )
+ setTextType((TextAnnotation::TextType)e.attribute( QStringLiteral("type") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("icon") ) )
+ setTextIcon(e.attribute( QStringLiteral("icon") ));
+ if ( e.hasAttribute( QStringLiteral("font") ) )
{
QFont font;
- font.fromString( e.attribute( "font" ) );
+ font.fromString( e.attribute( QStringLiteral("font") ) );
setTextFont(font);
}
- if ( e.hasAttribute( "align" ) )
- setInplaceAlign(e.attribute( "align" ).toInt());
- if ( e.hasAttribute( "intent" ) )
- setInplaceIntent((TextAnnotation::InplaceIntent)e.attribute( "intent" ).toInt());
+ if ( e.hasAttribute( QStringLiteral("align") ) )
+ setInplaceAlign(e.attribute( QStringLiteral("align") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("intent") ) )
+ setInplaceIntent((TextAnnotation::InplaceIntent)e.attribute( QStringLiteral("intent") ).toInt());
// parse the subnodes
QDomNode eSubNode = e.firstChild();
@@ -1938,19 +1938,19 @@ TextAnnotation::TextAnnotation( const QDomNode & node )
QDomElement ee = eSubNode.toElement();
eSubNode = eSubNode.nextSibling();
- if ( ee.tagName() == "escapedText" )
+ if ( ee.tagName() == QLatin1String("escapedText") )
{
setContents(ee.firstChild().toCDATASection().data());
}
- else if ( ee.tagName() == "callout" )
+ else if ( ee.tagName() == QLatin1String("callout") )
{
QVector<QPointF> points(3);
- points[0] = QPointF(ee.attribute( "ax" ).toDouble(),
- ee.attribute( "ay" ).toDouble());
- points[1] = QPointF(ee.attribute( "bx" ).toDouble(),
- ee.attribute( "by" ).toDouble());
- points[2] = QPointF(ee.attribute( "cx" ).toDouble(),
- ee.attribute( "cy" ).toDouble());
+ points[0] = QPointF(ee.attribute( QStringLiteral("ax") ).toDouble(),
+ ee.attribute( QStringLiteral("ay") ).toDouble());
+ points[1] = QPointF(ee.attribute( QStringLiteral("bx") ).toDouble(),
+ ee.attribute( QStringLiteral("by") ).toDouble());
+ points[2] = QPointF(ee.attribute( QStringLiteral("cx") ).toDouble(),
+ ee.attribute( QStringLiteral("cy") ).toDouble());
setCalloutPoints(points);
}
}
@@ -1970,25 +1970,25 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [text] element
- QDomElement textElement = document.createElement( "text" );
+ QDomElement textElement = document.createElement( QStringLiteral("text") );
node.appendChild( textElement );
// store the optional attributes
if ( textType() != Linked )
- textElement.setAttribute( "type", (int)textType() );
- if ( textIcon() != "Note" )
- textElement.setAttribute( "icon", textIcon() );
+ textElement.setAttribute( QStringLiteral("type"), (int)textType() );
+ if ( textIcon() != QLatin1String("Note") )
+ textElement.setAttribute( QStringLiteral("icon"), textIcon() );
if ( inplaceAlign() )
- textElement.setAttribute( "align", inplaceAlign() );
+ textElement.setAttribute( QStringLiteral("align"), inplaceAlign() );
if ( inplaceIntent() != Unknown )
- textElement.setAttribute( "intent", (int)inplaceIntent() );
+ textElement.setAttribute( QStringLiteral("intent"), (int)inplaceIntent() );
- textElement.setAttribute( "font", textFont().toString() );
+ textElement.setAttribute( QStringLiteral("font"), textFont().toString() );
// Sub-Node-1 - escapedText
if ( !contents().isEmpty() )
{
- QDomElement escapedText = document.createElement( "escapedText" );
+ QDomElement escapedText = document.createElement( QStringLiteral("escapedText") );
textElement.appendChild( escapedText );
QDomCDATASection textCData = document.createCDATASection( contents() );
escapedText.appendChild( textCData );
@@ -1997,14 +1997,14 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
// Sub-Node-2 - callout
if ( calloutPoint(0).x() != 0.0 )
{
- QDomElement calloutElement = document.createElement( "callout" );
+ QDomElement calloutElement = document.createElement( QStringLiteral("callout") );
textElement.appendChild( calloutElement );
- calloutElement.setAttribute( "ax", QString::number( calloutPoint(0).x() ) );
- calloutElement.setAttribute( "ay", QString::number( calloutPoint(0).y() ) );
- calloutElement.setAttribute( "bx", QString::number( calloutPoint(1).x() ) );
- calloutElement.setAttribute( "by", QString::number( calloutPoint(1).y() ) );
- calloutElement.setAttribute( "cx", QString::number( calloutPoint(2).x() ) );
- calloutElement.setAttribute( "cy", QString::number( calloutPoint(2).y() ) );
+ calloutElement.setAttribute( QStringLiteral("ax"), QString::number( calloutPoint(0).x() ) );
+ calloutElement.setAttribute( QStringLiteral("ay"), QString::number( calloutPoint(0).y() ) );
+ calloutElement.setAttribute( QStringLiteral("bx"), QString::number( calloutPoint(1).x() ) );
+ calloutElement.setAttribute( QStringLiteral("by"), QString::number( calloutPoint(1).y() ) );
+ calloutElement.setAttribute( QStringLiteral("cx"), QString::number( calloutPoint(2).x() ) );
+ calloutElement.setAttribute( QStringLiteral("cy"), QString::number( calloutPoint(2).y() ) );
}
}
@@ -2089,7 +2089,7 @@ QFont TextAnnotation::textFont() const
{
// At the moment, only font size is parsed
QString style = QString::fromLatin1( da->getCString() );
- QRegExp rx("(\\d+)(\\.\\d*)? Tf");
+ QRegExp rx(QStringLiteral("(\\d+)(\\.\\d*)? Tf"));
if (rx.indexIn(style) != -1)
font.setPointSize( rx.cap(1).toInt() );
// TODO: Other properties
@@ -2363,26 +2363,26 @@ LineAnnotation::LineAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "line" )
+ if ( e.tagName() != QLatin1String("line") )
continue;
// parse the attributes
- if ( e.hasAttribute( "startStyle" ) )
- setLineStartStyle((LineAnnotation::TermStyle)e.attribute( "startStyle" ).toInt());
- if ( e.hasAttribute( "endStyle" ) )
- setLineEndStyle((LineAnnotation::TermStyle)e.attribute( "endStyle" ).toInt());
- if ( e.hasAttribute( "closed" ) )
- setLineClosed(e.attribute( "closed" ).toInt());
- if ( e.hasAttribute( "innerColor" ) )
- setLineInnerColor(QColor( e.attribute( "innerColor" ) ));
- if ( e.hasAttribute( "leadFwd" ) )
- setLineLeadingForwardPoint(e.attribute( "leadFwd" ).toDouble());
- if ( e.hasAttribute( "leadBack" ) )
- setLineLeadingBackPoint(e.attribute( "leadBack" ).toDouble());
- if ( e.hasAttribute( "showCaption" ) )
- setLineShowCaption(e.attribute( "showCaption" ).toInt());
- if ( e.hasAttribute( "intent" ) )
- setLineIntent((LineAnnotation::LineIntent)e.attribute( "intent" ).toInt());
+ if ( e.hasAttribute( QStringLiteral("startStyle") ) )
+ setLineStartStyle((LineAnnotation::TermStyle)e.attribute( QStringLiteral("startStyle") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("endStyle") ) )
+ setLineEndStyle((LineAnnotation::TermStyle)e.attribute( QStringLiteral("endStyle") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("closed") ) )
+ setLineClosed(e.attribute( QStringLiteral("closed") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("innerColor") ) )
+ setLineInnerColor(QColor( e.attribute( QStringLiteral("innerColor") ) ));
+ if ( e.hasAttribute( QStringLiteral("leadFwd") ) )
+ setLineLeadingForwardPoint(e.attribute( QStringLiteral("leadFwd") ).toDouble());
+ if ( e.hasAttribute( QStringLiteral("leadBack") ) )
+ setLineLeadingBackPoint(e.attribute( QStringLiteral("leadBack") ).toDouble());
+ if ( e.hasAttribute( QStringLiteral("showCaption") ) )
+ setLineShowCaption(e.attribute( QStringLiteral("showCaption") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("intent") ) )
+ setLineIntent((LineAnnotation::LineIntent)e.attribute( QStringLiteral("intent") ).toInt());
// parse all 'point' subnodes
QLinkedList<QPointF> points;
@@ -2392,10 +2392,10 @@ LineAnnotation::LineAnnotation( const QDomNode & node )
QDomElement pe = pointNode.toElement();
pointNode = pointNode.nextSibling();
- if ( pe.tagName() != "point" )
+ if ( pe.tagName() != QLatin1String("point") )
continue;
- QPointF p(pe.attribute( "x", "0.0" ).toDouble(), pe.attribute( "y", "0.0" ).toDouble());
+ QPointF p(pe.attribute( QStringLiteral("x"), QStringLiteral("0.0") ).toDouble(), pe.attribute( QStringLiteral("y"), QStringLiteral("0.0") ).toDouble());
points.append( p );
}
setLinePoints(points);
@@ -2416,26 +2416,26 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [line] element
- QDomElement lineElement = document.createElement( "line" );
+ QDomElement lineElement = document.createElement( QStringLiteral("line") );
node.appendChild( lineElement );
// store the attributes
if ( lineStartStyle() != None )
- lineElement.setAttribute( "startStyle", (int)lineStartStyle() );
+ lineElement.setAttribute( QStringLiteral("startStyle"), (int)lineStartStyle() );
if ( lineEndStyle() != None )
- lineElement.setAttribute( "endStyle", (int)lineEndStyle() );
+ lineElement.setAttribute( QStringLiteral("endStyle"), (int)lineEndStyle() );
if ( isLineClosed() )
- lineElement.setAttribute( "closed", isLineClosed() );
+ lineElement.setAttribute( QStringLiteral("closed"), isLineClosed() );
if ( lineInnerColor().isValid() )
- lineElement.setAttribute( "innerColor", lineInnerColor().name() );
+ lineElement.setAttribute( QStringLiteral("innerColor"), lineInnerColor().name() );
if ( lineLeadingForwardPoint() != 0.0 )
- lineElement.setAttribute( "leadFwd", QString::number( lineLeadingForwardPoint() ) );
+ lineElement.setAttribute( QStringLiteral("leadFwd"), QString::number( lineLeadingForwardPoint() ) );
if ( lineLeadingBackPoint() != 0.0 )
- lineElement.setAttribute( "leadBack", QString::number( lineLeadingBackPoint() ) );
+ lineElement.setAttribute( QStringLiteral("leadBack"), QString::number( lineLeadingBackPoint() ) );
if ( lineShowCaption() )
- lineElement.setAttribute( "showCaption", lineShowCaption() );
+ lineElement.setAttribute( QStringLiteral("showCaption"), lineShowCaption() );
if ( lineIntent() != Unknown )
- lineElement.setAttribute( "intent", lineIntent() );
+ lineElement.setAttribute( QStringLiteral("intent"), lineIntent() );
// append the list of points
const QLinkedList<QPointF> points = linePoints();
@@ -2445,10 +2445,10 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
while ( it != end )
{
const QPointF & p = *it;
- QDomElement pElement = document.createElement( "point" );
+ QDomElement pElement = document.createElement( QStringLiteral("point") );
lineElement.appendChild( pElement );
- pElement.setAttribute( "x", QString::number( p.x() ) );
- pElement.setAttribute( "y", QString::number( p.y() ) );
+ pElement.setAttribute( QStringLiteral("x"), QString::number( p.x() ) );
+ pElement.setAttribute( QStringLiteral("y"), QString::number( p.y() ) );
++it;
}
}
@@ -2944,14 +2944,14 @@ GeomAnnotation::GeomAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "geom" )
+ if ( e.tagName() != QLatin1String("geom") )
continue;
// parse the attributes
- if ( e.hasAttribute( "type" ) )
- setGeomType((GeomAnnotation::GeomType)e.attribute( "type" ).toInt());
- if ( e.hasAttribute( "color" ) )
- setGeomInnerColor(QColor( e.attribute( "color" ) ));
+ if ( e.hasAttribute( QStringLiteral("type") ) )
+ setGeomType((GeomAnnotation::GeomType)e.attribute( QStringLiteral("type") ).toInt());
+ if ( e.hasAttribute( QStringLiteral("color") ) )
+ setGeomInnerColor(QColor( e.attribute( QStringLiteral("color") ) ));
// loading complete
break;
@@ -2968,14 +2968,14 @@ void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [geom] element
- QDomElement geomElement = document.createElement( "geom" );
+ QDomElement geomElement = document.createElement( QStringLiteral("geom") );
node.appendChild( geomElement );
// append the optional attributes
if ( geomType() != InscribedSquare )
- geomElement.setAttribute( "type", (int)geomType() );
+ geomElement.setAttribute( QStringLiteral("type"), (int)geomType() );
if ( geomInnerColor().isValid() )
- geomElement.setAttribute( "color", geomInnerColor().name() );
+ geomElement.setAttribute( QStringLiteral("color"), geomInnerColor().name() );
}
Annotation::SubType GeomAnnotation::subType() const
@@ -3093,6 +3093,7 @@ QList< HighlightAnnotation::Quad > HighlightAnnotationPrivate::fromQuadrilateral
double MTX[6];
fillTransformationMTX(MTX);
+ quads.reserve(quadsCount);
for (int q = 0; q < quadsCount; ++q)
{
HighlightAnnotation::Quad quad;
@@ -3181,12 +3182,12 @@ HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "hl" )
+ if ( e.tagName() != QLatin1String("hl") )
continue;
// parse the attributes
- if ( e.hasAttribute( "type" ) )
- setHighlightType((HighlightAnnotation::HighlightType)e.attribute( "type" ).toInt());
+ if ( e.hasAttribute( QStringLiteral("type") ) )
+ setHighlightType((HighlightAnnotation::HighlightType)e.attribute( QStringLiteral("type") ).toInt());
// parse all 'quad' subnodes
QList<HighlightAnnotation::Quad> quads;
@@ -3194,21 +3195,21 @@ HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
{
QDomElement qe = quadNode.toElement();
- if ( qe.tagName() != "quad" )
+ if ( qe.tagName() != QLatin1String("quad") )
continue;
Quad q;
- q.points[0].setX(qe.attribute( "ax", "0.0" ).toDouble());
- q.points[0].setY(qe.attribute( "ay", "0.0" ).toDouble());
- q.points[1].setX(qe.attribute( "bx", "0.0" ).toDouble());
- q.points[1].setY(qe.attribute( "by", "0.0" ).toDouble());
- q.points[2].setX(qe.attribute( "cx", "0.0" ).toDouble());
- q.points[2].setY(qe.attribute( "cy", "0.0" ).toDouble());
- q.points[3].setX(qe.attribute( "dx", "0.0" ).toDouble());
- q.points[3].setY(qe.attribute( "dy", "0.0" ).toDouble());
- q.capStart = qe.hasAttribute( "start" );
- q.capEnd = qe.hasAttribute( "end" );
- q.feather = qe.attribute( "feather", "0.1" ).toDouble();
+ q.points[0].setX(qe.attribute( QStringLiteral("ax"), QStringLiteral("0.0") ).toDouble());
+ q.points[0].setY(qe.attribute( QStringLiteral("ay"), QStringLiteral("0.0") ).toDouble());
+ q.points[1].setX(qe.attribute( QStringLiteral("bx"), QStringLiteral("0.0") ).toDouble());
+ q.points[1].setY(qe.attribute( QStringLiteral("by"), QStringLiteral("0.0") ).toDouble());
+ q.points[2].setX(qe.attribute( QStringLiteral("cx"), QStringLiteral("0.0") ).toDouble());
+ q.points[2].setY(qe.attribute( QStringLiteral("cy"), QStringLiteral("0.0") ).toDouble());
+ q.points[3].setX(qe.attribute( QStringLiteral("dx"), QStringLiteral("0.0") ).toDouble());
+ q.points[3].setY(qe.attribute( QStringLiteral("dy"), QStringLiteral("0.0") ).toDouble());
+ q.capStart = qe.hasAttribute( QStringLiteral("start") );
+ q.capEnd = qe.hasAttribute( QStringLiteral("end") );
+ q.feather = qe.attribute( QStringLiteral("feather"), QStringLiteral("0.1") ).toDouble();
quads.append( q );
}
setHighlightQuads(quads);
@@ -3228,12 +3229,12 @@ void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) cons
storeBaseAnnotationProperties( node, document );
// create [hl] element
- QDomElement hlElement = document.createElement( "hl" );
+ QDomElement hlElement = document.createElement( QStringLiteral("hl") );
node.appendChild( hlElement );
// append the optional attributes
if ( highlightType() != Highlight )
- hlElement.setAttribute( "type", (int)highlightType() );
+ hlElement.setAttribute( QStringLiteral("type"), (int)highlightType() );
const QList<HighlightAnnotation::Quad> quads = highlightQuads();
if ( quads.count() < 1 )
@@ -3242,22 +3243,22 @@ void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) cons
QList< HighlightAnnotation::Quad >::const_iterator it = quads.begin(), end = quads.end();
for ( ; it != end; ++it )
{
- QDomElement quadElement = document.createElement( "quad" );
+ QDomElement quadElement = document.createElement( QStringLiteral("quad") );
hlElement.appendChild( quadElement );
const Quad & q = *it;
- quadElement.setAttribute( "ax", QString::number( q.points[0].x() ) );
- quadElement.setAttribute( "ay", QString::number( q.points[0].y() ) );
- quadElement.setAttribute( "bx", QString::number( q.points[1].x() ) );
- quadElement.setAttribute( "by", QString::number( q.points[1].y() ) );
- quadElement.setAttribute( "cx", QString::number( q.points[2].x() ) );
- quadElement.setAttribute( "cy", QString::number( q.points[2].y() ) );
- quadElement.setAttribute( "dx", QString::number( q.points[3].x() ) );
- quadElement.setAttribute( "dy", QString::number( q.points[3].y() ) );
+ quadElement.setAttribute( QStringLiteral("ax"), QString::number( q.points[0].x() ) );
+ quadElement.setAttribute( QStringLiteral("ay"), QString::number( q.points[0].y() ) );
+ quadElement.setAttribute( QStringLiteral("bx"), QString::number( q.points[1].x() ) );
+ quadElement.setAttribute( QStringLiteral("by"), QString::number( q.points[1].y() ) );
+ quadElement.setAttribute( QStringLiteral("cx"), QString::number( q.points[2].x() ) );
+ quadElement.setAttribute( QStringLiteral("cy"), QString::number( q.points[2].y() ) );
+ quadElement.setAttribute( QStringLiteral("dx"), QString::number( q.points[3].x() ) );
+ quadElement.setAttribute( QStringLiteral("dy"), QString::number( q.points[3].y() ) );
if ( q.capStart )
- quadElement.setAttribute( "start", 1 );
+ quadElement.setAttribute( QStringLiteral("start"), 1 );
if ( q.capEnd )
- quadElement.setAttribute( "end", 1 );
- quadElement.setAttribute( "feather", QString::number( q.feather ) );
+ quadElement.setAttribute( QStringLiteral("end"), 1 );
+ quadElement.setAttribute( QStringLiteral("feather"), QString::number( q.feather ) );
}
}
@@ -3340,7 +3341,7 @@ class StampAnnotationPrivate : public AnnotationPrivate
};
StampAnnotationPrivate::StampAnnotationPrivate()
- : AnnotationPrivate(), stampIconName( "Draft" )
+ : AnnotationPrivate(), stampIconName( QStringLiteral("Draft") )
{
}
@@ -3389,12 +3390,12 @@ StampAnnotation::StampAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "stamp" )
+ if ( e.tagName() != QLatin1String("stamp") )
continue;
// parse the attributes
- if ( e.hasAttribute( "icon" ) )
- setStampIconName(e.attribute( "icon" ));
+ if ( e.hasAttribute( QStringLiteral("icon") ) )
+ setStampIconName(e.attribute( QStringLiteral("icon") ));
// loading complete
break;
@@ -3411,12 +3412,12 @@ void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [stamp] element
- QDomElement stampElement = document.createElement( "stamp" );
+ QDomElement stampElement = document.createElement( QStringLiteral("stamp") );
node.appendChild( stampElement );
// append the optional attributes
- if ( stampIconName() != "Draft" )
- stampElement.setAttribute( "icon", stampIconName() );
+ if ( stampIconName() != QLatin1String("Draft") )
+ stampElement.setAttribute( QStringLiteral("icon"), stampIconName() );
}
Annotation::SubType StampAnnotation::subType() const
@@ -3527,7 +3528,7 @@ InkAnnotation::InkAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "ink" )
+ if ( e.tagName() != QLatin1String("ink") )
continue;
// parse the 'path' subnodes
@@ -3538,7 +3539,7 @@ InkAnnotation::InkAnnotation( const QDomNode & node )
QDomElement pathElement = pathNode.toElement();
pathNode = pathNode.nextSibling();
- if ( pathElement.tagName() != "path" )
+ if ( pathElement.tagName() != QLatin1String("path") )
continue;
// build each path parsing 'point' subnodes
@@ -3549,10 +3550,10 @@ InkAnnotation::InkAnnotation( const QDomNode & node )
QDomElement pointElement = pointNode.toElement();
pointNode = pointNode.nextSibling();
- if ( pointElement.tagName() != "point" )
+ if ( pointElement.tagName() != QLatin1String("point") )
continue;
- QPointF p(pointElement.attribute( "x", "0.0" ).toDouble(), pointElement.attribute( "y", "0.0" ).toDouble());
+ QPointF p(pointElement.attribute( QStringLiteral("x"), QStringLiteral("0.0") ).toDouble(), pointElement.attribute( QStringLiteral("y"), QStringLiteral("0.0") ).toDouble());
path.append( p );
}
@@ -3577,7 +3578,7 @@ void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [ink] element
- QDomElement inkElement = document.createElement( "ink" );
+ QDomElement inkElement = document.createElement( QStringLiteral("ink") );
node.appendChild( inkElement );
// append the optional attributes
@@ -3587,17 +3588,17 @@ void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
QList< QLinkedList<QPointF> >::const_iterator pIt = paths.begin(), pEnd = paths.end();
for ( ; pIt != pEnd; ++pIt )
{
- QDomElement pathElement = document.createElement( "path" );
+ QDomElement pathElement = document.createElement( QStringLiteral("path") );
inkElement.appendChild( pathElement );
const QLinkedList<QPointF> & path = *pIt;
QLinkedList<QPointF>::const_iterator iIt = path.begin(), iEnd = path.end();
for ( ; iIt != iEnd; ++iIt )
{
const QPointF & point = *iIt;
- QDomElement pointElement = document.createElement( "point" );
+ QDomElement pointElement = document.createElement( QStringLiteral("point") );
pathElement.appendChild( pointElement );
- pointElement.setAttribute( "x", QString::number( point.x() ) );
- pointElement.setAttribute( "y", QString::number( point.y() ) );
+ pointElement.setAttribute( QStringLiteral("x"), QString::number( point.x() ) );
+ pointElement.setAttribute( QStringLiteral("y"), QString::number( point.y() ) );
}
}
}
@@ -3625,6 +3626,7 @@ QList< QLinkedList<QPointF> > InkAnnotation::inkPaths() const
const int pathsNumber = inkann->getInkListLength();
QList< QLinkedList<QPointF> > inkPaths;
+ inkPaths.reserve(pathsNumber);
for (int m = 0; m < pathsNumber; ++m)
{
// transform each path in a list of normalized points ..
@@ -3716,77 +3718,77 @@ LinkAnnotation::LinkAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "link" )
+ if ( e.tagName() != QLatin1String("link") )
continue;
// parse the attributes
- if ( e.hasAttribute( "hlmode" ) )
- setLinkHighlightMode((LinkAnnotation::HighlightMode)e.attribute( "hlmode" ).toInt());
+ if ( e.hasAttribute( QStringLiteral("hlmode") ) )
+ setLinkHighlightMode((LinkAnnotation::HighlightMode)e.attribute( QStringLiteral("hlmode") ).toInt());
// parse all 'quad' subnodes
QDomNode quadNode = e.firstChild();
for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
{
QDomElement qe = quadNode.toElement();
- if ( qe.tagName() == "quad" )
+ if ( qe.tagName() == QLatin1String("quad") )
{
- setLinkRegionPoint(0, QPointF(qe.attribute( "ax", "0.0" ).toDouble(),
- qe.attribute( "ay", "0.0" ).toDouble()));
- setLinkRegionPoint(1, QPointF(qe.attribute( "bx", "0.0" ).toDouble(),
- qe.attribute( "by", "0.0" ).toDouble()));
- setLinkRegionPoint(2, QPointF(qe.attribute( "cx", "0.0" ).toDouble(),
- qe.attribute( "cy", "0.0" ).toDouble()));
- setLinkRegionPoint(3, QPointF(qe.attribute( "dx", "0.0" ).toDouble(),
- qe.attribute( "dy", "0.0" ).toDouble()));
+ setLinkRegionPoint(0, QPointF(qe.attribute( QStringLiteral("ax"), QStringLiteral("0.0") ).toDouble(),
+ qe.attribute( QStringLiteral("ay"), QStringLiteral("0.0") ).toDouble()));
+ setLinkRegionPoint(1, QPointF(qe.attribute( QStringLiteral("bx"), QStringLiteral("0.0") ).toDouble(),
+ qe.attribute( QStringLiteral("by"), QStringLiteral("0.0") ).toDouble()));
+ setLinkRegionPoint(2, QPointF(qe.attribute( QStringLiteral("cx"), QStringLiteral("0.0") ).toDouble(),
+ qe.attribute( QStringLiteral("cy"), QStringLiteral("0.0") ).toDouble()));
+ setLinkRegionPoint(3, QPointF(qe.attribute( QStringLiteral("dx"), QStringLiteral("0.0") ).toDouble(),
+ qe.attribute( QStringLiteral("dy"), QStringLiteral("0.0") ).toDouble()));
}
- else if ( qe.tagName() == "link" )
+ else if ( qe.tagName() == QLatin1String("link") )
{
- QString type = qe.attribute( "type" );
- if ( type == "GoTo" )
+ QString type = qe.attribute( QStringLiteral("type") );
+ if ( type == QLatin1String("GoTo") )
{
- Poppler::LinkGoto * go = new Poppler::LinkGoto( QRect(), qe.attribute( "filename" ), LinkDestination( qe.attribute( "destination" ) ) );
+ Poppler::LinkGoto * go = new Poppler::LinkGoto( QRect(), qe.attribute( QStringLiteral("filename") ), LinkDestination( qe.attribute( QStringLiteral("destination") ) ) );
setLinkDestination(go);
}
- else if ( type == "Exec" )
+ else if ( type == QLatin1String("Exec") )
{
- Poppler::LinkExecute * exec = new Poppler::LinkExecute( QRect(), qe.attribute( "filename" ), qe.attribute( "parameters" ) );
+ Poppler::LinkExecute * exec = new Poppler::LinkExecute( QRect(), qe.attribute( QStringLiteral("filename") ), qe.attribute( QStringLiteral("parameters") ) );
setLinkDestination(exec);
}
- else if ( type == "Browse" )
+ else if ( type == QLatin1String("Browse") )
{
- Poppler::LinkBrowse * browse = new Poppler::LinkBrowse( QRect(), qe.attribute( "url" ) );
+ Poppler::LinkBrowse * browse = new Poppler::LinkBrowse( QRect(), qe.attribute( QStringLiteral("url") ) );
setLinkDestination(browse);
}
- else if ( type == "Action" )
+ else if ( type == QLatin1String("Action") )
{
Poppler::LinkAction::ActionType act;
- QString actString = qe.attribute( "action" );
+ QString actString = qe.attribute( QStringLiteral("action") );
bool found = true;
- if ( actString == "PageFirst" )
+ if ( actString == QLatin1String("PageFirst") )
act = Poppler::LinkAction::PageFirst;
- else if ( actString == "PagePrev" )
+ else if ( actString == QLatin1String("PagePrev") )
act = Poppler::LinkAction::PagePrev;
- else if ( actString == "PageNext" )
+ else if ( actString == QLatin1String("PageNext") )
act = Poppler::LinkAction::PageNext;
- else if ( actString == "PageLast" )
+ else if ( actString == QLatin1String("PageLast") )
act = Poppler::LinkAction::PageLast;
- else if ( actString == "HistoryBack" )
+ else if ( actString == QLatin1String("HistoryBack") )
act = Poppler::LinkAction::HistoryBack;
- else if ( actString == "HistoryForward" )
+ else if ( actString == QLatin1String("HistoryForward") )
act = Poppler::LinkAction::HistoryForward;
- else if ( actString == "Quit" )
+ else if ( actString == QLatin1String("Quit") )
act = Poppler::LinkAction::Quit;
- else if ( actString == "Presentation" )
+ else if ( actString == QLatin1String("Presentation") )
act = Poppler::LinkAction::Presentation;
- else if ( actString == "EndPresentation" )
+ else if ( actString == QLatin1String("EndPresentation") )
act = Poppler::LinkAction::EndPresentation;
- else if ( actString == "Find" )
+ else if ( actString == QLatin1String("Find") )
act = Poppler::LinkAction::Find;
- else if ( actString == "GoToPage" )
+ else if ( actString == QLatin1String("GoToPage") )
act = Poppler::LinkAction::GoToPage;
- else if ( actString == "Close" )
+ else if ( actString == QLatin1String("Close") )
act = Poppler::LinkAction::Close;
- else if ( actString == "Print" )
+ else if ( actString == QLatin1String("Print") )
act = Poppler::LinkAction::Print;
else
found = false;
@@ -3821,27 +3823,27 @@ void LinkAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [hl] element
- QDomElement linkElement = document.createElement( "link" );
+ QDomElement linkElement = document.createElement( QStringLiteral("link") );
node.appendChild( linkElement );
// append the optional attributes
if ( linkHighlightMode() != Invert )
- linkElement.setAttribute( "hlmode", (int)linkHighlightMode() );
+ linkElement.setAttribute( QStringLiteral("hlmode"), (int)linkHighlightMode() );
// saving region
- QDomElement quadElement = document.createElement( "quad" );
+ QDomElement quadElement = document.createElement( QStringLiteral("quad") );
linkElement.appendChild( quadElement );
- quadElement.setAttribute( "ax", QString::number( linkRegionPoint(0).x() ) );
- quadElement.setAttribute( "ay", QString::number( linkRegionPoint(0).y() ) );
- quadElement.setAttribute( "bx", QString::number( linkRegionPoint(1).x() ) );
- quadElement.setAttribute( "by", QString::number( linkRegionPoint(1).y() ) );
- quadElement.setAttribute( "cx", QString::number( linkRegionPoint(2).x() ) );
- quadElement.setAttribute( "cy", QString::number( linkRegionPoint(2).y() ) );
- quadElement.setAttribute( "dx", QString::number( linkRegionPoint(3).x() ) );
- quadElement.setAttribute( "dy", QString::number( linkRegionPoint(3).y() ) );
+ quadElement.setAttribute( QStringLiteral("ax"), QString::number( linkRegionPoint(0).x() ) );
+ quadElement.setAttribute( QStringLiteral("ay"), QString::number( linkRegionPoint(0).y() ) );
+ quadElement.setAttribute( QStringLiteral("bx"), QString::number( linkRegionPoint(1).x() ) );
+ quadElement.setAttribute( QStringLiteral("by"), QString::number( linkRegionPoint(1).y() ) );
+ quadElement.setAttribute( QStringLiteral("cx"), QString::number( linkRegionPoint(2).x() ) );
+ quadElement.setAttribute( QStringLiteral("cy"), QString::number( linkRegionPoint(2).y() ) );
+ quadElement.setAttribute( QStringLiteral("dx"), QString::number( linkRegionPoint(3).x() ) );
+ quadElement.setAttribute( QStringLiteral("dy"), QString::number( linkRegionPoint(3).y() ) );
// saving link
- QDomElement hyperlinkElement = document.createElement( "link" );
+ QDomElement hyperlinkElement = document.createElement( QStringLiteral("link") );
linkElement.appendChild( hyperlinkElement );
if ( linkDestination() )
{
@@ -3850,83 +3852,83 @@ void LinkAnnotation::store( QDomNode & node, QDomDocument & document ) const
case Poppler::Link::Goto:
{
Poppler::LinkGoto * go = static_cast< Poppler::LinkGoto * >( linkDestination() );
- hyperlinkElement.setAttribute( "type", "GoTo" );
- hyperlinkElement.setAttribute( "filename", go->fileName() );
- hyperlinkElement.setAttribute( "destionation", go->destination().toString() ); // TODO remove for poppler 0.28
- hyperlinkElement.setAttribute( "destination", go->destination().toString() );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("GoTo") );
+ hyperlinkElement.setAttribute( QStringLiteral("filename"), go->fileName() );
+ hyperlinkElement.setAttribute( QStringLiteral("destionation"), go->destination().toString() ); // TODO remove for poppler 0.28
+ hyperlinkElement.setAttribute( QStringLiteral("destination"), go->destination().toString() );
break;
}
case Poppler::Link::Execute:
{
Poppler::LinkExecute * exec = static_cast< Poppler::LinkExecute * >( linkDestination() );
- hyperlinkElement.setAttribute( "type", "Exec" );
- hyperlinkElement.setAttribute( "filename", exec->fileName() );
- hyperlinkElement.setAttribute( "parameters", exec->parameters() );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("Exec") );
+ hyperlinkElement.setAttribute( QStringLiteral("filename"), exec->fileName() );
+ hyperlinkElement.setAttribute( QStringLiteral("parameters"), exec->parameters() );
break;
}
case Poppler::Link::Browse:
{
Poppler::LinkBrowse * browse = static_cast< Poppler::LinkBrowse * >( linkDestination() );
- hyperlinkElement.setAttribute( "type", "Browse" );
- hyperlinkElement.setAttribute( "url", browse->url() );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("Browse") );
+ hyperlinkElement.setAttribute( QStringLiteral("url"), browse->url() );
break;
}
case Poppler::Link::Action:
{
Poppler::LinkAction * action = static_cast< Poppler::LinkAction * >( linkDestination() );
- hyperlinkElement.setAttribute( "type", "Action" );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("Action") );
switch ( action->actionType() )
{
case Poppler::LinkAction::PageFirst:
- hyperlinkElement.setAttribute( "action", "PageFirst" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("PageFirst") );
break;
case Poppler::LinkAction::PagePrev:
- hyperlinkElement.setAttribute( "action", "PagePrev" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("PagePrev") );
break;
case Poppler::LinkAction::PageNext:
- hyperlinkElement.setAttribute( "action", "PageNext" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("PageNext") );
break;
case Poppler::LinkAction::PageLast:
- hyperlinkElement.setAttribute( "action", "PageLast" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("PageLast") );
break;
case Poppler::LinkAction::HistoryBack:
- hyperlinkElement.setAttribute( "action", "HistoryBack" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("HistoryBack") );
break;
case Poppler::LinkAction::HistoryForward:
- hyperlinkElement.setAttribute( "action", "HistoryForward" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("HistoryForward") );
break;
case Poppler::LinkAction::Quit:
- hyperlinkElement.setAttribute( "action", "Quit" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("Quit") );
break;
case Poppler::LinkAction::Presentation:
- hyperlinkElement.setAttribute( "action", "Presentation" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("Presentation") );
break;
case Poppler::LinkAction::EndPresentation:
- hyperlinkElement.setAttribute( "action", "EndPresentation" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("EndPresentation") );
break;
case Poppler::LinkAction::Find:
- hyperlinkElement.setAttribute( "action", "Find" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("Find") );
break;
case Poppler::LinkAction::GoToPage:
- hyperlinkElement.setAttribute( "action", "GoToPage" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("GoToPage") );
break;
case Poppler::LinkAction::Close:
- hyperlinkElement.setAttribute( "action", "Close" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("Close") );
break;
case Poppler::LinkAction::Print:
- hyperlinkElement.setAttribute( "action", "Print" );
+ hyperlinkElement.setAttribute( QStringLiteral("action"), QStringLiteral("Print") );
break;
}
break;
}
case Poppler::Link::Movie:
{
- hyperlinkElement.setAttribute( "type", "Movie" );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("Movie") );
break;
}
case Poppler::Link::Rendition:
{
- hyperlinkElement.setAttribute( "type", "Rendition" );
+ hyperlinkElement.setAttribute( QStringLiteral("type"), QStringLiteral("Rendition") );
break;
}
case Poppler::Link::Sound:
@@ -4005,9 +4007,9 @@ static QString caretSymbolToString( CaretAnnotation::CaretSymbol symbol )
switch ( symbol )
{
case CaretAnnotation::None:
- return QString::fromLatin1( "None" );
+ return QStringLiteral("None");
case CaretAnnotation::P:
- return QString::fromLatin1( "P" );
+ return QStringLiteral("P");
}
return QString();
}
@@ -4071,12 +4073,12 @@ CaretAnnotation::CaretAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "caret" )
+ if ( e.tagName() != QLatin1String("caret") )
continue;
// parse the attributes
- if ( e.hasAttribute( "symbol" ) )
- setCaretSymbol(caretSymbolFromString( e.attribute( "symbol" ) ));
+ if ( e.hasAttribute( QStringLiteral("symbol") ) )
+ setCaretSymbol(caretSymbolFromString( e.attribute( QStringLiteral("symbol") ) ));
// loading complete
break;
@@ -4093,12 +4095,12 @@ void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [caret] element
- QDomElement caretElement = document.createElement( "caret" );
+ QDomElement caretElement = document.createElement( QStringLiteral("caret") );
node.appendChild( caretElement );
// append the optional attributes
if ( caretSymbol() != CaretAnnotation::None )
- caretElement.setAttribute( "symbol", caretSymbolToString( caretSymbol() ) );
+ caretElement.setAttribute( QStringLiteral("symbol"), caretSymbolToString( caretSymbol() ) );
}
Annotation::SubType CaretAnnotation::subType() const
@@ -4146,7 +4148,7 @@ class FileAttachmentAnnotationPrivate : public AnnotationPrivate
};
FileAttachmentAnnotationPrivate::FileAttachmentAnnotationPrivate()
- : AnnotationPrivate(), icon( "PushPin" ), embfile( 0 )
+ : AnnotationPrivate(), icon( QStringLiteral("PushPin") ), embfile( 0 )
{
}
@@ -4184,7 +4186,7 @@ FileAttachmentAnnotation::FileAttachmentAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "fileattachment" )
+ if ( e.tagName() != QLatin1String("fileattachment") )
continue;
// loading complete
@@ -4202,7 +4204,7 @@ void FileAttachmentAnnotation::store( QDomNode & node, QDomDocument & document )
storeBaseAnnotationProperties( node, document );
// create [fileattachment] element
- QDomElement fileAttachmentElement = document.createElement( "fileattachment" );
+ QDomElement fileAttachmentElement = document.createElement( QStringLiteral("fileattachment") );
node.appendChild( fileAttachmentElement );
}
@@ -4250,7 +4252,7 @@ class SoundAnnotationPrivate : public AnnotationPrivate
};
SoundAnnotationPrivate::SoundAnnotationPrivate()
- : AnnotationPrivate(), icon( "Speaker" ), sound( 0 )
+ : AnnotationPrivate(), icon( QStringLiteral("Speaker") ), sound( 0 )
{
}
@@ -4288,7 +4290,7 @@ SoundAnnotation::SoundAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "sound" )
+ if ( e.tagName() != QLatin1String("sound") )
continue;
// loading complete
@@ -4306,7 +4308,7 @@ void SoundAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [sound] element
- QDomElement soundElement = document.createElement( "sound" );
+ QDomElement soundElement = document.createElement( QStringLiteral("sound") );
node.appendChild( soundElement );
}
@@ -4392,7 +4394,7 @@ MovieAnnotation::MovieAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "movie" )
+ if ( e.tagName() != QLatin1String("movie") )
continue;
// loading complete
@@ -4410,7 +4412,7 @@ void MovieAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [movie] element
- QDomElement movieElement = document.createElement( "movie" );
+ QDomElement movieElement = document.createElement( QStringLiteral("movie") );
node.appendChild( movieElement );
}
@@ -4496,7 +4498,7 @@ void ScreenAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [screen] element
- QDomElement screenElement = document.createElement( "screen" );
+ QDomElement screenElement = document.createElement( QStringLiteral("screen") );
node.appendChild( screenElement );
}
@@ -4572,7 +4574,7 @@ void WidgetAnnotation::store( QDomNode & node, QDomDocument & document ) const
storeBaseAnnotationProperties( node, document );
// create [widget] element
- QDomElement widgetElement = document.createElement( "widget" );
+ QDomElement widgetElement = document.createElement( QStringLiteral("widget") );
node.appendChild( widgetElement );
}
@@ -4979,7 +4981,7 @@ RichMediaAnnotation::RichMediaAnnotation( const QDomNode & node )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
- if ( e.tagName() != "richMedia" )
+ if ( e.tagName() != QLatin1String("richMedia") )
continue;
// loading complete
@@ -4997,7 +4999,7 @@ void RichMediaAnnotation::store( QDomNode & node, QDomDocument & document ) cons
storeBaseAnnotationProperties( node, document );
// create [richMedia] element
- QDomElement richMediaElement = document.createElement( "richMedia" );
+ QDomElement richMediaElement = document.createElement( QStringLiteral("richMedia") );
node.appendChild( richMediaElement );
}
diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index d5d9a6d..537dca3 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -1,7 +1,7 @@
/* poppler-document.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, 2008, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2010, 2012, 2013, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2010, 2012, 2013, 2015, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006-2010, Pino Toscano <pino at kde.org>
* Copyright (C) 2010, 2011 Hib Eris <hib at hiberis.nl>
* Copyright (C) 2012 Koji Otani <sho at bbr.jp>
@@ -314,6 +314,7 @@ namespace Poppler {
Dict *infoDict = info.getDict();
// somehow iterate over keys in infoDict
+ keys.reserve(infoDict->getLength());
for( int i=0; i < infoDict->getLength(); ++i ) {
keys.append( QString::fromLatin1(infoDict->getKey(i)) );
}
diff --git a/qt5/src/poppler-fontinfo.cc b/qt5/src/poppler-fontinfo.cc
index f2a5579..dbc5292 100644
--- a/qt5/src/poppler-fontinfo.cc
+++ b/qt5/src/poppler-fontinfo.cc
@@ -2,7 +2,7 @@
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, Tobias Koening <tokoe at kde.org>
* Copyright (C) 2005, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2008, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2008, 2015, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2008, 2009, Pino Toscano <pino at kde.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -129,6 +129,7 @@ QList<FontInfo> FontIterator::next()
GooList *items = d->fontInfoScanner.scan( 1 );
if ( !items )
return fonts;
+ fonts.reserve( items->getLength() );
for ( int i = 0; i < items->getLength(); ++i ) {
fonts.append( FontInfo( FontInfoData( ( ::FontInfo* )items->get( i ) ) ) );
}
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 4be0482..ba3dafd 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1,6 +1,6 @@
/* poppler-form.h: qt interface to poppler
* Copyright (C) 2007-2008, 2011, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, 2011, 2012 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2011, 2012, 2015 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
*
@@ -342,6 +342,7 @@ QStringList FormFieldChoice::choices() const
FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm);
QStringList ret;
int num = fwc->getNumChoices();
+ ret.reserve(num);
for (int i = 0; i < num; ++i)
{
ret.append(UnicodeParsedString(fwc->getChoice(i)));
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index 7c0513b..e2fd66e 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -3,6 +3,7 @@
* Copyright (C) 2007, Brad Hards <bradh at kde.org>
* Copyright (C) 2008, 2014, Pino Toscano <pino at kde.org>
* Copyright (C) 2008, Carlos Garcia Campos <carlosgc at gnome.org>
+ * Copyright (C) 2015, Albert Astals Cid <aacid at kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,7 @@ namespace Poppler
RadioButtonGroup::RadioButtonGroup( OptContentModelPrivate *ocModel, Array *rbarray )
{
+ itemsInGroup.reserve(rbarray->getLength());
for (int i = 0; i < rbarray->getLength(); ++i) {
Object ref;
rbarray->getNF( i, &ref );
diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index 3832861..42a342d 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -584,6 +584,7 @@ QList<TextBox*> Page::textList(Rotation rotate) const
QHash<TextWord *, TextBox*> wordBoxMap;
+ output_list.reserve(word_list->getLength());
for (int i = 0; i < word_list->getLength(); i++) {
TextWord *word = word_list->get(i);
GooString *gooWord = word->getText();
diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 51395a2..86855fd 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -62,11 +62,11 @@ namespace Debug {
if (pos >= 0)
{
- emsg = QString::fromLatin1("Error (%1): ").arg(pos);
+ emsg = QStringLiteral("Error (%1): ").arg(pos);
}
else
{
- emsg = QString::fromLatin1("Error: ");
+ emsg = QStringLiteral("Error: ");
}
emsg += QString::fromLatin1(msg);
(*Debug::debugFunction)(emsg, Debug::debugClosure);
@@ -174,13 +174,13 @@ namespace Debug {
QChar *charArray = new QChar[s->getLength()];
for (int i = 0; i < s->getLength(); ++i) charArray[i] = QChar(s->getCString()[i]);
QString aux(charArray, s->getLength());
- e->setAttribute( "DestinationName", aux );
+ e->setAttribute( QStringLiteral("DestinationName"), aux );
delete[] charArray;
}
else if ( destination && destination->isOk() )
{
LinkDestinationData ldd(destination, NULL, doc, false);
- e->setAttribute( "Destination", LinkDestination(ldd).toString() );
+ e->setAttribute( QStringLiteral("Destination"), LinkDestination(ldd).toString() );
}
break;
}
@@ -198,21 +198,21 @@ namespace Debug {
QChar *charArray = new QChar[s->getLength()];
for (int i = 0; i < s->getLength(); ++i) charArray[i] = QChar(s->getCString()[i]);
QString aux(charArray, s->getLength());
- e->setAttribute( "DestinationName", aux );
+ e->setAttribute( QStringLiteral("DestinationName"), aux );
delete[] charArray;
}
else if ( destination && destination->isOk() )
{
LinkDestinationData ldd(destination, NULL, doc, g->getFileName() != 0);
- e->setAttribute( "Destination", LinkDestination(ldd).toString() );
+ e->setAttribute( QStringLiteral("Destination"), LinkDestination(ldd).toString() );
}
- e->setAttribute( "ExternalFileName", g->getFileName()->getCString() );
+ e->setAttribute( QStringLiteral("ExternalFileName"), g->getFileName()->getCString() );
break;
}
case actionURI:
{
LinkURI * u = static_cast< LinkURI * >( a );
- e->setAttribute( "DestinationURI", u->getURI()->getCString() );
+ e->setAttribute( QStringLiteral("DestinationURI"), u->getURI()->getCString() );
}
default: ;
}
@@ -272,7 +272,7 @@ namespace Debug {
::LinkAction * a = outlineItem->getAction();
linkActionToTocItem( a, this, &item );
- item.setAttribute( "Open", QVariant( (bool)outlineItem->isOpen() ).toString() );
+ item.setAttribute( QStringLiteral("Open"), QVariant( (bool)outlineItem->isOpen() ).toString() );
// 3. recursively descend over children
outlineItem->open();
commit 9b4e908d86e78535cced9fb7ccac1f3f0e1fc5c1
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Sep 8 17:48:16 2015 +0200
Qt4: Minor optimization
Call reserve on containers upfront
diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index f026d6f..8a7f60b 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -1,5 +1,5 @@
/* poppler-annotation.cc: qt interface to poppler
- * Copyright (C) 2006, 2009, 2012-2014 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2009, 2012-2015 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006, 2008, 2010 Pino Toscano <pino at kde.org>
* Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
* Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso at hotmail.it>
@@ -3106,6 +3106,7 @@ QList< HighlightAnnotation::Quad > HighlightAnnotationPrivate::fromQuadrilateral
double MTX[6];
fillTransformationMTX(MTX);
+ quads.reserve(quadsCount);
for (int q = 0; q < quadsCount; ++q)
{
HighlightAnnotation::Quad quad;
@@ -3638,6 +3639,7 @@ QList< QLinkedList<QPointF> > InkAnnotation::inkPaths() const
const int pathsNumber = inkann->getInkListLength();
QList< QLinkedList<QPointF> > inkPaths;
+ inkPaths.reserve(pathsNumber);
for (int m = 0; m < pathsNumber; ++m)
{
// transform each path in a list of normalized points ..
diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index e1266e8..94f997d 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -1,7 +1,7 @@
/* poppler-document.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, 2008, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2010, 2012, 2013, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2010, 2012, 2013, 2015, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006-2010, Pino Toscano <pino at kde.org>
* Copyright (C) 2010, 2011 Hib Eris <hib at hiberis.nl>
* Copyright (C) 2012 Koji Otani <sho at bbr.jp>
@@ -328,6 +328,7 @@ namespace Poppler {
Dict *infoDict = info.getDict();
// somehow iterate over keys in infoDict
+ keys.reserve( infoDict->getLength() );
for( int i=0; i < infoDict->getLength(); ++i ) {
keys.append( QString::fromAscii(infoDict->getKey(i)) );
}
diff --git a/qt4/src/poppler-fontinfo.cc b/qt4/src/poppler-fontinfo.cc
index 81aed71..5bb9e3a 100644
--- a/qt4/src/poppler-fontinfo.cc
+++ b/qt4/src/poppler-fontinfo.cc
@@ -2,7 +2,7 @@
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, Tobias Koening <tokoe at kde.org>
* Copyright (C) 2005, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2008, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2008, 2015, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2008, 2009, Pino Toscano <pino at kde.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -129,6 +129,7 @@ QList<FontInfo> FontIterator::next()
GooList *items = d->fontInfoScanner.scan( 1 );
if ( !items )
return fonts;
+ fonts.reserve( items->getLength() );
for ( int i = 0; i < items->getLength(); ++i ) {
fonts.append( FontInfo( FontInfoData( ( ::FontInfo* )items->get( i ) ) ) );
}
diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc
index a5e5adf..12aa329 100644
--- a/qt4/src/poppler-form.cc
+++ b/qt4/src/poppler-form.cc
@@ -1,6 +1,6 @@
/* poppler-form.h: qt4 interface to poppler
* Copyright (C) 2007-2008, 2011, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, 2011, 2012 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2011, 2012, 2015, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
* Copyright (C) 2012, Adam Reichold <adamreichold at myopera.com>
*
@@ -342,6 +342,7 @@ QStringList FormFieldChoice::choices() const
FormWidgetChoice* fwc = static_cast<FormWidgetChoice*>(m_formData->fm);
QStringList ret;
int num = fwc->getNumChoices();
+ ret.reserve(num);
for (int i = 0; i < num; ++i)
{
ret.append(UnicodeParsedString(fwc->getChoice(i)));
diff --git a/qt4/src/poppler-optcontent.cc b/qt4/src/poppler-optcontent.cc
index 1a0be68..431f0ee 100644
--- a/qt4/src/poppler-optcontent.cc
+++ b/qt4/src/poppler-optcontent.cc
@@ -3,6 +3,7 @@
* Copyright (C) 2007, Brad Hards <bradh at kde.org>
* Copyright (C) 2008, 2014, Pino Toscano <pino at kde.org>
* Copyright (C) 2008, Carlos Garcia Campos <carlosgc at gnome.org>
+ * Copyright (C) 2015, Albert Astals Cid <aacid at kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,7 @@ namespace Poppler
RadioButtonGroup::RadioButtonGroup( OptContentModelPrivate *ocModel, Array *rbarray )
{
+ itemsInGroup.reserve( rbarray->getLength() );
for (int i = 0; i < rbarray->getLength(); ++i) {
Object ref;
rbarray->getNF( i, &ref );
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 16a18f1..83bcf4a 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -602,6 +602,7 @@ QList<TextBox*> Page::textList(Rotation rotate) const
QHash<TextWord *, TextBox*> wordBoxMap;
+ output_list.reserve(word_list->getLength());
for (int i = 0; i < word_list->getLength(); i++) {
TextWord *word = word_list->get(i);
GooString *gooWord = word->getText();
commit f8182694909c989bd65b7317f9df439c5bfabe95
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Sep 8 17:13:07 2015 +0200
renderingIntent is always non null
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 3e9cac4..cacccad 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -6833,14 +6833,12 @@ GfxColorTransform *GfxState::getXYZ2DisplayTransform() {
GfxColorTransform *transform;
transform = XYZ2DisplayTransformRelCol;
- if (renderingIntent != NULL) {
- if (strcmp(renderingIntent, "AbsoluteColorimetric") == 0) {
- transform = XYZ2DisplayTransformAbsCol;
- } else if (strcmp(renderingIntent, "Saturation") == 0) {
- transform = XYZ2DisplayTransformSat;
- } else if (strcmp(renderingIntent, "Perceptual") == 0) {
- transform = XYZ2DisplayTransformPerc;
- }
+ if (strcmp(renderingIntent, "AbsoluteColorimetric") == 0) {
+ transform = XYZ2DisplayTransformAbsCol;
+ } else if (strcmp(renderingIntent, "Saturation") == 0) {
+ transform = XYZ2DisplayTransformSat;
+ } else if (strcmp(renderingIntent, "Perceptual") == 0) {
+ transform = XYZ2DisplayTransformPerc;
}
if (transform == NULL) {
transform = XYZ2DisplayTransform;
commit 6f69e2e35b8fe7a347367074ce36959d47fd8635
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Sep 8 09:44:30 2015 +0200
Matrix is 48 bytes, pass it by ref instead of by value
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 16f099f..bbb371a 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -298,7 +298,7 @@ TextWord::~TextWord() {
void TextWord::addChar(GfxState *state, TextFontInfo *fontA, double x, double y,
double dx, double dy, int charPosA, int charLen,
- CharCode c, Unicode u, Matrix textMatA) {
+ CharCode c, Unicode u, const Matrix &textMatA) {
ensureCapacity(len+1);
text[len] = u;
charcode[len] = c;
@@ -486,7 +486,7 @@ Unicode getCombiningChar(Unicode u) {
GBool TextWord::addCombining(GfxState *state, TextFontInfo *fontA, double fontSizeA, double x, double y,
double dx, double dy, int charPosA, int charLen,
- CharCode c, Unicode u, Matrix textMatA) {
+ CharCode c, Unicode u, const Matrix &textMatA) {
if (len == 0 || wMode != 0 || fontA->getWMode() != 0)
return gFalse;
diff --git a/poppler/TextOutputDev.h b/poppler/TextOutputDev.h
index a0aa6f8..2aab94f 100644
--- a/poppler/TextOutputDev.h
+++ b/poppler/TextOutputDev.h
@@ -17,7 +17,7 @@
// Copyright (C) 2006 Ed Catmur <ed at catmur.co.uk>
// Copyright (C) 2007, 2008, 2011, 2013 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright (C) 2007 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2008, 2010 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2010, 2015 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2010 Brian Ewins <brian.ewins at gmail.com>
// Copyright (C) 2012, 2013, 2015 Jason Crain <jason at aquaticape.us>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
@@ -132,7 +132,7 @@ public:
// Add a character to the word.
void addChar(GfxState *state, TextFontInfo *fontA, double x, double y,
double dx, double dy, int charPosA, int charLen,
- CharCode c, Unicode u, Matrix textMatA);
+ CharCode c, Unicode u, const Matrix &textMatA);
// Attempt to add a character to the word as a combining character.
// Either character u or the last character in the word must be an
@@ -140,7 +140,7 @@ public:
// the character was added.
GBool addCombining(GfxState *state, TextFontInfo *fontA, double fontSizeA, double x, double y,
double dx, double dy, int charPosA, int charLen,
- CharCode c, Unicode u, Matrix textMatA);
+ CharCode c, Unicode u, const Matrix &textMatA);
// Merge <word> onto the end of <this>.
void merge(TextWord *word);
More information about the poppler
mailing list