Author: alg
Date: Fri Oct 10 15:52:52 2014
New Revision: 1630928
URL: http://svn.apache.org/r1630928
Log:
i125325 added code to handle block comments in Css style definitions
Modified:
openoffice/trunk/main/svgio/inc/svgio/svgreader/svgtools.hxx
openoffice/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx
openoffice/trunk/main/svgio/source/svgreader/svgtools.cxx
Modified: openoffice/trunk/main/svgio/inc/svgio/svgreader/svgtools.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/inc/svgio/svgreader/svgtools.hxx?rev=1630928&r1=1630927&r2=1630928&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/inc/svgio/svgreader/svgtools.hxx (original)
+++ openoffice/trunk/main/svgio/inc/svgio/svgreader/svgtools.hxx Fri Oct 10
15:52:52 2014
@@ -236,6 +236,10 @@ namespace svgio
rtl::OUString whiteSpaceHandlingDefault(const rtl::OUString&
rCandidate);
rtl::OUString whiteSpaceHandlingPreserve(const rtl::OUString&
rCandidate);
+ // #125325# removes block comment of the general form '/* ... */',
returns
+ // an adapted string or the original if no comments included
+ rtl::OUString removeBlockComments(const rtl::OUString& rCandidate);
+
} // end of namespace svgreader
} // end of namespace svgio
Modified: openoffice/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx?rev=1630928&r1=1630927&r2=1630928&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx
(original)
+++ openoffice/trunk/main/svgio/source/svgreader/svgdocumenthandler.cxx Fri Oct
10 15:52:52 2014
@@ -512,7 +512,16 @@ namespace svgio
if(maCssContents.size())
{
// need to interpret css styles and remember them as
StyleSheets
- pCssStyle->addCssStyleSheet(*(maCssContents.end() -
1));
+ // #125325# Caution! the Css content may contain block
comments
+ // (see
http://www.w3.org/wiki/CSS_basics#CSS_comments). These need
+ // to be removed first
+ const rtl::OUString
aCommentFreeSource(removeBlockComments(*(maCssContents.end() - 1)));
+
+ if(aCommentFreeSource.getLength())
+ {
+ pCssStyle->addCssStyleSheet(aCommentFreeSource);
+ }
+
maCssContents.pop_back();
}
else
Modified: openoffice/trunk/main/svgio/source/svgreader/svgtools.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svgio/source/svgreader/svgtools.cxx?rev=1630928&r1=1630927&r2=1630928&view=diff
==============================================================================
--- openoffice/trunk/main/svgio/source/svgreader/svgtools.cxx (original)
+++ openoffice/trunk/main/svgio/source/svgreader/svgtools.cxx Fri Oct 10
15:52:52 2014
@@ -1538,6 +1538,57 @@ namespace svgio
return rCandidate;
}
+ // #125325#
+ rtl::OUString removeBlockComments(const rtl::OUString& rCandidate)
+ {
+ const sal_Int32 nLen(rCandidate.getLength());
+
+ if(nLen)
+ {
+ sal_Int32 nPos(0);
+ rtl::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;
+ }
+
rtl::OUString consolidateContiguosSpace(const rtl::OUString&
rCandidate)
{
const sal_Int32 nLen(rCandidate.getLength());