diff options
Diffstat (limited to 'svgio/source/svgreader/svgtools.cxx')
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index f3faa470a679..a4d594a3d437 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -1513,6 +1513,57 @@ namespace svgio return rCandidate; } + // #i125325# + OUString removeBlockComments(const OUString& rCandidate) + { + const sal_Int32 nLen(rCandidate.getLength()); + + if(nLen) + { + sal_Int32 nPos(0); + OUStringBuffer aBuffer; + bool bChanged(false); + sal_Int32 nInsideComment(0); + const sal_Unicode aCommentSlash('/'); + const sal_Unicode aCommentStar('*'); + + while(nPos < nLen) + { + const sal_Unicode aChar(rCandidate[nPos]); + const bool bStart(aCommentSlash == aChar && nPos + 1 < nLen && aCommentStar == rCandidate[nPos + 1]); + const bool bEnd(aCommentStar == aChar && nPos + 1 < nLen && aCommentSlash == rCandidate[nPos + 1]); + + if(bStart) + { + nPos += 2; + nInsideComment++; + bChanged = true; + } + else if(bEnd) + { + nPos += 2; + nInsideComment--; + } + else + { + if(!nInsideComment) + { + aBuffer.append(aChar); + } + + nPos++; + } + } + + if(bChanged) + { + return aBuffer.makeStringAndClear(); + } + } + + return rCandidate; + } + OUString consolidateContiguosSpace(const OUString& rCandidate) { const sal_Int32 nLen(rCandidate.getLength()); |