Kaydet (Commit) f8d1dcc6 authored tarafından Chr. Rossmanith's avatar Chr. Rossmanith Kaydeden (comit) Noel Power

fdo#43460: Use isEmpty() instead of getLength() in svgio

Change-Id: I31298a08408a14e1ae0d43b474681e6336b08003
Reviewed-on: https://gerrit.libreoffice.org/4340Reviewed-by: 's avatarNoel Power <noel.power@suse.com>
Tested-by: 's avatarNoel Power <noel.power@suse.com>
üst 0b67caf4
......@@ -50,7 +50,7 @@ namespace svgio
{
case SVGTokenX:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
SvgNumberVector aVector;
......@@ -63,7 +63,7 @@ namespace svgio
}
case SVGTokenY:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
SvgNumberVector aVector;
......@@ -76,7 +76,7 @@ namespace svgio
}
case SVGTokenDx:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
SvgNumberVector aVector;
......@@ -89,7 +89,7 @@ namespace svgio
}
case SVGTokenDy:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
SvgNumberVector aVector;
......@@ -102,7 +102,7 @@ namespace svgio
}
case SVGTokenRotate:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
SvgNumberVector aVector;
......@@ -128,7 +128,7 @@ namespace svgio
}
case SVGTokenLengthAdjust:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrSpacing(OUString::createFromAscii("spacing"));
static OUString aStrSpacingAndGlyphs(OUString::createFromAscii("spacingAndGlyphs"));
......@@ -572,7 +572,7 @@ namespace svgio
void SvgCharacterNode::decomposeText(drawinglayer::primitive2d::Primitive2DSequence& rTarget, SvgTextPosition& rSvgTextPosition) const
{
if(getText().getLength())
if(!getText().isEmpty())
{
const SvgStyleAttributes* pSvgStyleAttributes = getSvgStyleAttributes();
......
......@@ -79,7 +79,7 @@ namespace svgio
}
case SVGTokenClipPathUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......
......@@ -51,7 +51,7 @@ namespace svgio
void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode)
{
if(rStr.getLength())
if(!rStr.isEmpty())
{
maIdTokenMapperList.insert(IdTokenValueType(rStr, &rNode));
}
......@@ -59,7 +59,7 @@ namespace svgio
void SvgDocument::removeSvgNodeFromMapper(const OUString& rStr)
{
if(rStr.getLength())
if(!rStr.isEmpty())
{
maIdTokenMapperList.erase(rStr);
}
......@@ -81,7 +81,7 @@ namespace svgio
void SvgDocument::addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes)
{
if(rStr.getLength())
if(!rStr.isEmpty())
{
maIdStyleTokenMapperList.insert(IdStyleTokenValueType(rStr, &rSvgStyleAttributes));
}
......
......@@ -76,7 +76,7 @@ namespace
// pCharNode may have lost all text. If that's the case, ignore
// as invalid character node
if(pCharNode->getText().getLength())
if(!pCharNode->getText().isEmpty())
{
if(pLast)
{
......@@ -171,7 +171,7 @@ namespace svgio
void SvgDocHdl::startElement( const OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
{
if(aName.getLength())
if(!aName.isEmpty())
{
const SVGToken aSVGToken(StrToSVGToken(aName));
......@@ -385,7 +385,7 @@ namespace svgio
void SvgDocHdl::endElement( const OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException)
{
if(aName.getLength())
if(!aName.isEmpty())
{
const SVGToken aSVGToken(StrToSVGToken(aName));
SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
......@@ -471,7 +471,7 @@ namespace svgio
{
const OUString aText(pSvgTitleDescNode->getText());
if(aText.getLength())
if(!aText.isEmpty())
{
if(SVGTokenTitle == aSVGToken)
{
......@@ -551,7 +551,7 @@ namespace svgio
{
const OUString aTrimmedChars(aChars.trim());
if(aTrimmedChars.getLength())
if(!aTrimmedChars.isEmpty())
{
std::vector< OUString >::iterator aString(maCssContents.end() - 1);
(*aString) += aTrimmedChars;
......
......@@ -29,7 +29,7 @@ namespace svgio
{
void SvgGradientNode::tryToFindLink()
{
if(!mpXLink && maXLink.getLength())
if(!mpXLink && !maXLink.isEmpty())
{
mpXLink = dynamic_cast< const SvgGradientNode* >(getDocument().findSvgNodeById(maXLink));
}
......@@ -180,7 +180,7 @@ namespace svgio
}
case SVGTokenGradientUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......@@ -195,7 +195,7 @@ namespace svgio
}
case SVGTokenSpreadMethod:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrPad(OUString::createFromAscii("pad"));
static OUString aStrReflect(OUString::createFromAscii("reflect"));
......
......@@ -212,7 +212,7 @@ namespace svgio
const basegfx::B2DRange aTarget(fX, fY, fX + fWidth, fY + fHeight);
basegfx::B2DRange aViewBox(aTarget);
if(maMimeType.getLength() && maData.getLength())
if(!maMimeType.isEmpty() && !maData.isEmpty())
{
// use embedded base64 encoded data
::com::sun::star::uno::Sequence< sal_Int8 > aPass;
......@@ -232,12 +232,12 @@ namespace svgio
}
}
}
else if(maUrl.getLength())
else if(!maUrl.isEmpty())
{
const OUString& rPath = getDocument().getAbsolutePath();
const OUString aAbsUrl(rtl::Uri::convertRelToAbs(rPath, maUrl));
if(aAbsUrl.getLength())
if(!aAbsUrl.isEmpty())
{
SvFileStream aStream(aAbsUrl, STREAM_STD_READ);
Graphic aGraphic;
......@@ -251,7 +251,7 @@ namespace svgio
}
}
}
else if(maXLink.getLength())
else if(!maXLink.isEmpty())
{
const SvgNode* mpXLink = getDocument().findSvgNodeById(maXLink);
......
......@@ -107,7 +107,7 @@ namespace svgio
}
case SVGTokenMarkerUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrStrokeWidth(OUString::createFromAscii("strokeWidth"));
......
......@@ -132,7 +132,7 @@ namespace svgio
}
case SVGTokenMaskUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......@@ -147,7 +147,7 @@ namespace svgio
}
case SVGTokenMaskContentUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......
......@@ -67,7 +67,7 @@ namespace svgio
aId = aId + aOUTokenValue;
pNew = rDocument.findSvgStyleAttributesById(aId);
if(!pNew && rClassStr.getLength())
if(!pNew && !rClassStr.isEmpty())
{
// look for CSS style common to class.token
aId = rClassStr + aId;
......@@ -93,7 +93,7 @@ namespace svgio
}
}
if(maCssStyleVector.empty() && rClassStr.getLength())
if(maCssStyleVector.empty() && !rClassStr.isEmpty())
{
// if none found, search for CSS style equal to class type
const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
......@@ -326,7 +326,7 @@ namespace svgio
{
case SVGTokenId:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
setId(&aContent);
}
......@@ -334,7 +334,7 @@ namespace svgio
}
case SVGTokenClass:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
setClass(&aContent);
}
......@@ -342,7 +342,7 @@ namespace svgio
}
case SVGTokenXmlSpace:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrDefault(OUString::createFromAscii("default"));
static OUString aStrPreserve(OUString::createFromAscii("preserve"));
......@@ -443,7 +443,7 @@ namespace svgio
const OUString& rTitle = pStyles->getTitle();
const OUString& rDesc = pStyles->getDesc();
if(rTitle.getLength() || rDesc.getLength())
if(!rTitle.isEmpty() || !rDesc.isEmpty())
{
// default object name is empty
OUString aObjectName;
......@@ -453,7 +453,7 @@ namespace svgio
{
aObjectName = getDocument().getAbsolutePath();
if(aObjectName.getLength())
if(!aObjectName.isEmpty())
{
INetURLObject aURL(aObjectName);
......
......@@ -28,7 +28,7 @@ namespace svgio
{
void SvgPatternNode::tryToFindLink()
{
if(!mpXLink && maXLink.getLength())
if(!mpXLink && !maXLink.isEmpty())
{
mpXLink = dynamic_cast< const SvgPatternNode* >(getDocument().findSvgNodeById(maXLink));
}
......@@ -147,7 +147,7 @@ namespace svgio
}
case SVGTokenPatternUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......@@ -162,7 +162,7 @@ namespace svgio
}
case SVGTokenPatternContentUnits:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
......@@ -274,7 +274,7 @@ namespace svgio
decomposeSvgNode(const_cast< SvgPatternNode* >(this)->aPrimitives, true);
}
if(!aPrimitives.hasElements() && maXLink.getLength())
if(!aPrimitives.hasElements() && !maXLink.isEmpty())
{
const_cast< SvgPatternNode* >(this)->tryToFindLink();
......
......@@ -183,7 +183,7 @@ namespace svgio
OUStringBuffer aTokenName;
copyString(rCandidate, nPos, aTokenName, nLen);
if(aTokenName.getLength())
if(!aTokenName.isEmpty())
{
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
OUStringBuffer aTokenValue;
......@@ -1085,7 +1085,7 @@ namespace svgio
aSource = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
}
if(getClipPathXLink().getLength())
if(!getClipPathXLink().isEmpty())
{
// try to access linked ClipPath
const SvgClipPathNode* mpClip = dynamic_cast< const SvgClipPathNode* >(mrOwner.getDocument().findSvgNodeById(getClipPathXLink()));
......@@ -1098,7 +1098,7 @@ namespace svgio
if(aSource.hasElements()) // test again, applied clipPath may have lead to empty geometry
{
if(getMaskXLink().getLength())
if(!getMaskXLink().isEmpty())
{
// try to access linked Mask
const SvgMaskNode* mpMask = dynamic_cast< const SvgMaskNode* >(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
......@@ -1193,7 +1193,7 @@ namespace svgio
{
setFill(aSvgPaint);
}
else if(aURL.getLength())
else if(!aURL.isEmpty())
{
const SvgNode* pNode = mrOwner.getDocument().findSvgNodeById(aURL);
......@@ -1226,7 +1226,7 @@ namespace svgio
}
case SVGTokenFillRule:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrNonzero))
{
......@@ -1248,7 +1248,7 @@ namespace svgio
{
setStroke(aSvgPaint);
}
else if(aURL.getLength())
else if(!aURL.isEmpty())
{
const SvgNode* pNode = mrOwner.getDocument().findSvgNodeById(aURL);
......@@ -1268,7 +1268,7 @@ namespace svgio
}
case SVGTokenStrokeDasharray:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
SvgNumberVector aVector;
......@@ -1303,7 +1303,7 @@ namespace svgio
}
case SVGTokenStrokeLinecap:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrButt(OUString::createFromAscii("butt"));
static OUString aStrRound(OUString::createFromAscii("round"));
......@@ -1326,7 +1326,7 @@ namespace svgio
}
case SVGTokenStrokeLinejoin:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrMiter(OUString::createFromAscii("miter"));
static OUString aStrRound(OUString::createFromAscii("round"));
......@@ -1440,7 +1440,7 @@ namespace svgio
}
case SVGTokenFontStretch:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrNormal(OUString::createFromAscii("normal"));
static OUString aStrWider(OUString::createFromAscii("wider"));
......@@ -1503,7 +1503,7 @@ namespace svgio
}
case SVGTokenFontStyle:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrNormal(OUString::createFromAscii("normal"));
static OUString aStrItalic(OUString::createFromAscii("italic"));
......@@ -1526,7 +1526,7 @@ namespace svgio
}
case SVGTokenFontVariant:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrNormal(OUString::createFromAscii("normal"));
static OUString aStrSmallCaps(OUString::createFromAscii("small-caps"));
......@@ -1544,7 +1544,7 @@ namespace svgio
}
case SVGTokenFontWeight:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrNormal(OUString::createFromAscii("normal"));
static OUString aStrBold(OUString::createFromAscii("bold"));
......@@ -1617,7 +1617,7 @@ namespace svgio
}
case SVGTokenTextDecoration:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrNone(OUString::createFromAscii("none"));
static OUString aStrUnderline(OUString::createFromAscii("underline"));
......@@ -1658,7 +1658,7 @@ namespace svgio
}
case SVGTokenTextAnchor:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrStart(OUString::createFromAscii("start"));
static OUString aStrMiddle(OUString::createFromAscii("middle"));
......@@ -1681,7 +1681,7 @@ namespace svgio
}
case SVGTokenTextAlign:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrLeft(OUString::createFromAscii("left"));
static OUString aStrRight(OUString::createFromAscii("right"));
......@@ -1750,7 +1750,7 @@ namespace svgio
}
case SVGTokenClipRule:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
if(aContent.match(commonStrings::aStrNonzero))
{
......@@ -2426,7 +2426,7 @@ namespace svgio
OUString SvgStyleAttributes::getMarkerStartXLink() const
{
if(maMarkerStartXLink.getLength())
if(!maMarkerStartXLink.isEmpty())
{
return maMarkerStartXLink;
}
......@@ -2447,7 +2447,7 @@ namespace svgio
{
const OUString aMarker(getMarkerStartXLink());
if(aMarker.getLength())
if(!aMarker.isEmpty())
{
const_cast< SvgStyleAttributes* >(this)->mpMarkerStartXLink = dynamic_cast< const SvgMarkerNode* >(mrOwner.getDocument().findSvgNodeById(getMarkerStartXLink()));
}
......@@ -2458,7 +2458,7 @@ namespace svgio
OUString SvgStyleAttributes::getMarkerMidXLink() const
{
if(maMarkerMidXLink.getLength())
if(!maMarkerMidXLink.isEmpty())
{
return maMarkerMidXLink;
}
......@@ -2479,7 +2479,7 @@ namespace svgio
{
const OUString aMarker(getMarkerMidXLink());
if(aMarker.getLength())
if(!aMarker.isEmpty())
{
const_cast< SvgStyleAttributes* >(this)->mpMarkerMidXLink = dynamic_cast< const SvgMarkerNode* >(mrOwner.getDocument().findSvgNodeById(getMarkerMidXLink()));
}
......@@ -2490,7 +2490,7 @@ namespace svgio
OUString SvgStyleAttributes::getMarkerEndXLink() const
{
if(maMarkerEndXLink.getLength())
if(!maMarkerEndXLink.isEmpty())
{
return maMarkerEndXLink;
}
......@@ -2511,7 +2511,7 @@ namespace svgio
{
const OUString aMarker(getMarkerEndXLink());
if(aMarker.getLength())
if(!aMarker.isEmpty())
{
const_cast< SvgStyleAttributes* >(this)->mpMarkerEndXLink = dynamic_cast< const SvgMarkerNode* >(mrOwner.getDocument().findSvgNodeById(getMarkerEndXLink()));
}
......
......@@ -54,7 +54,7 @@ namespace svgio
{
case SVGTokenType:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrTextCss(OUString::createFromAscii("text/css"));
......@@ -88,14 +88,14 @@ namespace svgio
copyToLimiter(aContent, sal_Unicode('{'), nPos, aTokenValue, nLen);
const OUString aStyleName = aTokenValue.makeStringAndClear().trim();
if(aStyleName.getLength() && nPos < nLen)
if(!aStyleName.isEmpty() && nPos < nLen)
{
skip_char(aContent, sal_Unicode(' '), sal_Unicode('{'), nPos, nLen);
copyToLimiter(aContent, sal_Unicode('}'), nPos, aTokenValue, nLen);
skip_char(aContent, sal_Unicode(' '), sal_Unicode('}'), nPos, nLen);
const OUString aStyleContent = aTokenValue.makeStringAndClear().trim();
if(aStyleContent.getLength())
if(!aStyleContent.isEmpty())
{
// create new style
SvgStyleAttributes* pNewStyle = new SvgStyleAttributes(*this);
......
......@@ -159,7 +159,7 @@ namespace svgio
const OUString aTrimmedChars(aText.copy(nIndex, nLength).trim());
const double fEndPos(mfPosition + fSnippetWidth);
if(aTrimmedChars.getLength() && (mfPosition < mfBasegfxPathLength || fEndPos > 0.0))
if(!aTrimmedChars.isEmpty() && (mfPosition < mfBasegfxPathLength || fEndPos > 0.0))
{
const double fHalfSnippetWidth(fSnippetWidth * 0.5);
......@@ -300,7 +300,7 @@ namespace svgio
}
case SVGTokenMethod:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrAlign(OUString::createFromAscii("align"));
static OUString aStrStretch(OUString::createFromAscii("stretch"));
......@@ -318,7 +318,7 @@ namespace svgio
}
case SVGTokenSpacing:
{
if(aContent.getLength())
if(!aContent.isEmpty())
{
static OUString aStrAuto(OUString::createFromAscii("auto"));
static OUString aStrExact(OUString::createFromAscii("exact"));
......
......@@ -384,7 +384,7 @@ namespace svgio
}
}
if(aNum.getLength())
if(!aNum.isEmpty())
{
rtl_math_ConversionStatus eStatus;
......@@ -1248,7 +1248,7 @@ namespace svgio
OUStringBuffer aTokenName;
copyString(rCandidate, nPos, aTokenName, nLen);
if(aTokenName.getLength())
if(!aTokenName.isEmpty())
{
switch(StrToSVGToken(aTokenName.makeStringAndClear()))
{
......@@ -1370,7 +1370,7 @@ namespace svgio
skip_char(rCandidate, sal_Unicode(','), sal_Unicode(' '), nPos, nLen);
const OUString aString = aTokenValue.makeStringAndClear();
if(aString.getLength())
if(!aString.isEmpty())
{
rSvgStringVector.push_back(aString);
}
......@@ -1406,7 +1406,7 @@ namespace svgio
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
rMimeType = aBuffer.makeStringAndClear();
if(rMimeType.getLength() && nPos < nLen)
if(!rMimeType.isEmpty() && nPos < nLen)
{
static OUString aStrImage(OUString::createFromAscii("image"));
......
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