[Libreoffice-commits] core.git: 2 commits - svgio/inc svgio/source
Caolán McNamara
caolanm at redhat.com
Sat Jul 26 06:52:12 PDT 2014
svgio/inc/svgio/svgreader/svgnode.hxx | 22 ++
svgio/source/svgreader/svgcirclenode.cxx | 2
svgio/source/svgreader/svgclippathnode.cxx | 2
svgio/source/svgreader/svgellipsenode.cxx | 2
svgio/source/svgreader/svggnode.cxx | 2
svgio/source/svgreader/svggradientnode.cxx | 9
svgio/source/svgreader/svggradientstopnode.cxx | 6
svgio/source/svgreader/svgimagenode.cxx | 2
svgio/source/svgreader/svglinenode.cxx | 2
svgio/source/svgreader/svgmarkernode.cxx | 2
svgio/source/svgreader/svgmasknode.cxx | 2
svgio/source/svgreader/svgnode.cxx | 236 ++++++++++++++-----------
svgio/source/svgreader/svgpathnode.cxx | 2
svgio/source/svgreader/svgpatternnode.cxx | 2
svgio/source/svgreader/svgpolynode.cxx | 2
svgio/source/svgreader/svgrectnode.cxx | 2
svgio/source/svgreader/svgstyleattributes.cxx | 34 +++
svgio/source/svgreader/svgstylenode.cxx | 53 ++++-
svgio/source/svgreader/svgsvgnode.cxx | 21 +-
svgio/source/svgreader/svgsymbolnode.cxx | 2
svgio/source/svgreader/svgtextnode.cxx | 2
svgio/source/svgreader/svgtextpathnode.cxx | 2
svgio/source/svgreader/svgtrefnode.cxx | 2
svgio/source/svgreader/svgtspannode.cxx | 2
svgio/source/svgreader/svgusenode.cxx | 2
25 files changed, 280 insertions(+), 137 deletions(-)
New commits:
commit 7eba2d637334f67ab8a6e7883d9aecb1c3c31e93
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 26 14:50:59 2014 +0100
drop rtl:: and statics
Change-Id: I6108efad77cf1c21dea3826ae149f3750552b0ed
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index 6a5217c..4793ddf 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -82,7 +82,7 @@ namespace svgio
// helper to convert a string associated with a token of type SVGTokenDisplay
// to the enum Display. Empty trings return the default 'Display_inline' with
// which members should be initialized
- Display getDisplayFromContent(const rtl::OUString& aContent);
+ Display getDisplayFromContent(const OUString& aContent);
class SvgNode : private boost::noncopyable, public InfoProvider
{
@@ -122,10 +122,10 @@ namespace svgio
protected:
/// helper to evtl. link to css style
- const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+ const SvgStyleAttributes* checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
/// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
- void fillCssStyleVector(const rtl::OUString& rClassStr);
+ void fillCssStyleVector(const OUString& rClassStr);
public:
SvgNode(
@@ -135,7 +135,7 @@ namespace svgio
virtual ~SvgNode();
/// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
- void readLocalCssStyle(const rtl::OUString& aContent);
+ void readLocalCssStyle(const OUString& aContent);
/// style helpers
void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 92ea5b5..d31979b 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -65,8 +65,8 @@ namespace svgio
const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
{
- static rtl::OUString aClassStrA(rtl::OUString::createFromAscii("linearGradient"));
- static rtl::OUString aClassStrB(rtl::OUString::createFromAscii("radialGradient"));
+ OUString aClassStrA("linearGradient");
+ OUString aClassStrB("radialGradient");
return checkForCssStyle(
SVGTokenLinearGradient == getType() ? aClassStrA : aClassStrB,
diff --git a/svgio/source/svgreader/svggradientstopnode.cxx b/svgio/source/svgreader/svggradientstopnode.cxx
index 6c6d758..a1ce201 100644
--- a/svgio/source/svgreader/svggradientstopnode.cxx
+++ b/svgio/source/svgreader/svggradientstopnode.cxx
@@ -38,7 +38,7 @@ namespace svgio
const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
{
- static rtl::OUString aClassStr(rtl::OUString::createFromAscii("stop"));
+ OUString aClassStr("stop");
return checkForCssStyle(aClassStr, maSvgStyleAttributes);
}
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 24decd3..1652a25 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -40,7 +40,7 @@ namespace svgio
return 0;
}
- void SvgNode::fillCssStyleVector(const rtl::OUString& rClassStr)
+ void SvgNode::fillCssStyleVector(const OUString& rClassStr)
{
OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?");
mbCssStyleVectorBuilt = true;
@@ -75,7 +75,7 @@ namespace svgio
{
// concatenate combined style name during search for CSS style equal to Id
// when travelling over node parents
- rtl::OUString aConcatenatedStyleName;
+ OUString aConcatenatedStyleName;
const SvgNode* pCurrent = this;
const SvgStyleAttributes* pNew = 0;
@@ -104,7 +104,7 @@ namespace svgio
if(getClass())
{
// find all referenced CSS styles (a list of entries is allowed)
- const rtl::OUString* pClassList = getClass();
+ const OUString* pClassList = getClass();
const sal_Int32 nLen(pClassList->getLength());
sal_Int32 nPos(0);
const SvgStyleAttributes* pNew = 0;
@@ -113,13 +113,13 @@ namespace svgio
while(nPos < nLen)
{
- rtl::OUStringBuffer aTokenValue;
+ OUStringBuffer aTokenValue;
copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
- rtl::OUString aId(rtl::OUString::createFromAscii("."));
- const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ OUString aId(OUString::createFromAscii("."));
+ const OUString aOUTokenValue(aTokenValue.makeStringAndClear());
// look for CSS style common to token
aId = aId + aOUTokenValue;
@@ -154,7 +154,7 @@ namespace svgio
}
}
- const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+ const SvgStyleAttributes* SvgNode::checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
{
if(!mbCssStyleVectorBuilt)
{
@@ -266,7 +266,7 @@ namespace svgio
}
}
- void SvgNode::readLocalCssStyle(const rtl::OUString& aContent)
+ void SvgNode::readLocalCssStyle(const OUString& aContent)
{
if(!mpLocalCssStyle)
{
@@ -306,7 +306,7 @@ namespace svgio
}
}
- Display getDisplayFromContent(const rtl::OUString& aContent)
+ Display getDisplayFromContent(const OUString& aContent)
{
if(aContent.getLength())
{
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index b48431d..82104ae 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -184,21 +184,21 @@ namespace svgio
if(!aTokenName.isEmpty())
{
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
- rtl::OUStringBuffer aTokenValue;
+ OUStringBuffer aTokenValue;
copyToLimiter(rCandidate, sal_Unicode(';'), nPos, aTokenValue, nLen);
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
- const rtl::OUString aOUTokenName(aTokenName.makeStringAndClear());
- rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ const OUString aOUTokenName(aTokenName.makeStringAndClear());
+ OUString aOUTokenValue(aTokenValue.makeStringAndClear());
// check for '!important' CssStyle mark, currently not supported
// but neds to be extracted for correct parsing
- static rtl::OUString aTokenImportant(RTL_CONSTASCII_USTRINGPARAM("!important"));
+ OUString aTokenImportant("!important");
const sal_Int32 nIndexTokenImportant(aOUTokenValue.indexOf(aTokenImportant));
if(-1 != nIndexTokenImportant)
{
// if there currently just remove it and remove spaces to have the value only
- rtl::OUString aNewOUTokenValue;
+ OUString aNewOUTokenValue;
if(nIndexTokenImportant > 0)
{
diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx
index b17c528..e5b965f 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -98,15 +98,15 @@ namespace svgio
copyToLimiter(aContent, sal_Unicode('{'), nPos, aTokenValue, nLen);
skip_char(aContent, sal_Unicode(' '), sal_Unicode('{'), nPos, nLen);
- const rtl::OUString aStyleName(aTokenValue.makeStringAndClear().trim());
+ const OUString aStyleName(aTokenValue.makeStringAndClear().trim());
const sal_Int32 nLen2(aStyleName.getLength());
- std::vector< rtl::OUString > aStyleNames;
+ std::vector< OUString > aStyleNames;
if(nLen2)
{
// extract names
sal_Int32 nPos2(0);
- rtl::OUStringBuffer aSingleName;
+ OUStringBuffer aSingleName;
while(nPos2 < nLen2)
{
@@ -114,7 +114,7 @@ namespace svgio
copyToLimiter(aStyleName, sal_Unicode(' '), nPos2, aSingleName, nLen2);
skip_char(aStyleName, sal_Unicode(' '), nPos2, nLen2);
- const rtl::OUString aOUSingleName(aSingleName.makeStringAndClear().trim());
+ const OUString aOUSingleName(aSingleName.makeStringAndClear().trim());
if(aOUSingleName.getLength())
{
@@ -127,7 +127,7 @@ namespace svgio
{
copyToLimiter(aContent, sal_Unicode('}'), nPos, aTokenValue, nLen);
skip_char(aContent, sal_Unicode(' '), sal_Unicode('}'), nPos, nLen);
- const rtl::OUString aStyleContent(aTokenValue.makeStringAndClear().trim());
+ const OUString aStyleContent(aTokenValue.makeStringAndClear().trim());
if(!aStyleContent.isEmpty())
{
@@ -139,7 +139,7 @@ namespace svgio
pNewStyle->readStyle(aStyleContent);
// concatenate combined style name
- rtl::OUString aConcatenatedStyleName;
+ OUString aConcatenatedStyleName;
for(sal_uInt32 a(0); a < aStyleNames.size(); a++)
{
commit 0347e5c77d281e4a25f79660aafb625691c4f883
Author: Armin Le Grand <alg at apache.org>
Date: Fri Jul 25 15:38:47 2014 +0000
Related: #i125293# Further corrections for CssStyle handling in SVG importer
(cherry picked from commit f00d6d2ea3e73e687edb1da4c32c0960eaf5010b)
Conflicts:
svgio/source/svgreader/svgnode.cxx
svgio/source/svgreader/svgstyleattributes.cxx
svgio/source/svgreader/svgstylenode.cxx
svgio/source/svgreader/svgsvgnode.cxx
Change-Id: I335b292fcdf1ebac925c9fd76ad624efb923447d
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index cc88b26..6a5217c 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -108,13 +108,25 @@ namespace svgio
/// Display value #i121656#
Display maDisplay;
- /// CSS styles
+ // CSS style vector chain, used in decompose phase and built up once per node.
+ // It contains the StyleHierarchy for the local node. INdependent from the
+ // node hierarchy itself which also needs to be used in style entry solving
SvgStyleAttributeVector maCssStyleVector;
+ /// possibbe local CssStyle, e.g. style="fill:red; stroke:red;"
+ SvgStyleAttributes* mpLocalCssStyle;
+
+ /// bitfield
+ // flag if maCssStyleVector is already computed (done only once)
+ bool mbCssStyleVectorBuilt : 1;
+
protected:
/// helper to evtl. link to css style
const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+ /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
+ void fillCssStyleVector(const rtl::OUString& rClassStr);
+
public:
SvgNode(
SVGToken aType,
@@ -122,6 +134,10 @@ namespace svgio
SvgNode* pParent);
virtual ~SvgNode();
+ /// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
+ void readLocalCssStyle(const rtl::OUString& aContent);
+
+ /// style helpers
void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent);
diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx
index 38daca1..db75fde 100644
--- a/svgio/source/svgreader/svgcirclenode.cxx
+++ b/svgio/source/svgreader/svgcirclenode.cxx
@@ -60,7 +60,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenCx:
diff --git a/svgio/source/svgreader/svgclippathnode.cxx b/svgio/source/svgreader/svgclippathnode.cxx
index 0a7f0f4..7b65f94 100644
--- a/svgio/source/svgreader/svgclippathnode.cxx
+++ b/svgio/source/svgreader/svgclippathnode.cxx
@@ -63,7 +63,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
diff --git a/svgio/source/svgreader/svgellipsenode.cxx b/svgio/source/svgreader/svgellipsenode.cxx
index 5818a1c..03a5f6f 100644
--- a/svgio/source/svgreader/svgellipsenode.cxx
+++ b/svgio/source/svgreader/svgellipsenode.cxx
@@ -61,7 +61,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenCx:
diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx
index c3957c7..85a97bd 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -68,7 +68,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 893ff96..92ea5b5 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -65,7 +65,12 @@ namespace svgio
const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
{
- return &maSvgStyleAttributes;
+ static rtl::OUString aClassStrA(rtl::OUString::createFromAscii("linearGradient"));
+ static rtl::OUString aClassStrB(rtl::OUString::createFromAscii("radialGradient"));
+
+ return checkForCssStyle(
+ SVGTokenLinearGradient == getType() ? aClassStrA : aClassStrB,
+ maSvgStyleAttributes);
}
void SvgGradientNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
@@ -81,7 +86,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX1:
diff --git a/svgio/source/svgreader/svggradientstopnode.cxx b/svgio/source/svgreader/svggradientstopnode.cxx
index 55a46cf..6c6d758 100644
--- a/svgio/source/svgreader/svggradientstopnode.cxx
+++ b/svgio/source/svgreader/svggradientstopnode.cxx
@@ -38,7 +38,9 @@ namespace svgio
const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
{
- return &maSvgStyleAttributes;
+ static rtl::OUString aClassStr(rtl::OUString::createFromAscii("stop"));
+
+ return checkForCssStyle(aClassStr, maSvgStyleAttributes);
}
void SvgGradientStopNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
@@ -54,7 +56,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenOffset:
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index 951d72b..cebd613 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -78,7 +78,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenPreserveAspectRatio:
diff --git a/svgio/source/svgreader/svglinenode.cxx b/svgio/source/svgreader/svglinenode.cxx
index f4b5035..5bba7d5 100644
--- a/svgio/source/svgreader/svglinenode.cxx
+++ b/svgio/source/svgreader/svglinenode.cxx
@@ -61,7 +61,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX1:
diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx
index 7366143..5bad024 100644
--- a/svgio/source/svgreader/svgmarkernode.cxx
+++ b/svgio/source/svgreader/svgmarkernode.cxx
@@ -64,7 +64,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenViewBox:
diff --git a/svgio/source/svgreader/svgmasknode.cxx b/svgio/source/svgreader/svgmasknode.cxx
index e80f2e8..736ce14 100644
--- a/svgio/source/svgreader/svgmasknode.cxx
+++ b/svgio/source/svgreader/svgmasknode.cxx
@@ -69,7 +69,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX:
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 431ba0c..24decd3 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -40,96 +40,131 @@ namespace svgio
return 0;
}
- const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+ void SvgNode::fillCssStyleVector(const rtl::OUString& rClassStr)
{
- if(maCssStyleVector.empty()) // #120435# Evaluate for CSS styles only once, this cannot change
+ OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?");
+ mbCssStyleVectorBuilt = true;
+
+ // #125293# If we have CssStyles we need to buuild a linked list of SvgStyleAttributes
+ // which represent this for the current object. There are various methods to
+ // specify CssStyles which need to be taken into account in a given order:
+ // - local CssStyle (independent from global CssStyles at SvgDocument)
+ // - 'id' CssStyle
+ // - 'class' CssStyle(s)
+ // - type-dependent elements (e..g. 'rect' for all rect elements)
+ // - local attributes (rOriginal)
+ // - inherited attributes (up the hierarchy)
+ // The first four will be collected in maCssStyleVector for the current element
+ // (once, this will not change) and be linked in the needed order using the
+ // get/setCssStyleParent at the SvgStyleAttributes which will be used preferred in
+ // member evaluation over the existing parent hierarchy
+
+ // check for local CssStyle with highest priority
+ if(mpLocalCssStyle)
{
- const SvgDocument& rDocument = getDocument();
+ // if we have one, use as first entry
+ maCssStyleVector.push_back(mpLocalCssStyle);
+ }
+
+ const SvgDocument& rDocument = getDocument();
- if(rDocument.hasSvgStyleAttributesById())
+ if(rDocument.hasSvgStyleAttributesById())
+ {
+ // check for 'id' references
+ if(getId())
{
- // #i125293# If we have CssStyles we need to buuild a linked list of SvgStyleAttributes
- // which represent this for the current object. There are various methods to
- // specify CssStyles which need to be taken into account in a given order:
- // - 'id' element
- // - 'class' element(s)
- // - type-dependent elements (e..g. 'rect' for all rect elements)
- // - local firect attributes (rOriginal)
- // - inherited attributes (up the hierarchy)
- // The first three will be collected in maCssStyleVector for the current element
- // (once, this will not change) and be linked in the needed order using the
- // get/setCssStyleParent at the SvgStyleAttributes which will be used preferred in
- // member evaluation over the existing parent hierarchy
-
- // check for 'id' references
- if(getId())
+ // concatenate combined style name during search for CSS style equal to Id
+ // when travelling over node parents
+ rtl::OUString aConcatenatedStyleName;
+ const SvgNode* pCurrent = this;
+ const SvgStyleAttributes* pNew = 0;
+
+ while(!pNew && pCurrent)
{
- // search for CSS style equal to Id
- const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId());
+ if(pCurrent->getId())
+ {
+ aConcatenatedStyleName = *pCurrent->getId() + aConcatenatedStyleName;
+ }
- if(pNew)
+ if(aConcatenatedStyleName.getLength())
{
- const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
+ pNew = rDocument.findSvgStyleAttributesById(aConcatenatedStyleName);
}
+
+ pCurrent = pCurrent->getParent();
}
- // check for 'class' references
- if(getClass())
+ if(pNew)
{
- // find all referenced CSS styles, a list of entries is allowed
- const rtl::OUString* pClassList = getClass();
- const sal_Int32 nLen(pClassList->getLength());
- sal_Int32 nPos(0);
- const SvgStyleAttributes* pNew = 0;
+ maCssStyleVector.push_back(pNew);
+ }
+ }
- skip_char(*pClassList, ' ', nPos, nLen);
+ // check for 'class' references
+ if(getClass())
+ {
+ // find all referenced CSS styles (a list of entries is allowed)
+ const rtl::OUString* pClassList = getClass();
+ const sal_Int32 nLen(pClassList->getLength());
+ sal_Int32 nPos(0);
+ const SvgStyleAttributes* pNew = 0;
- while(nPos < nLen)
- {
- rtl::OUStringBuffer aTokenValue;
+ skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
- copyToLimiter(*pClassList, ' ', nPos, aTokenValue, nLen);
- skip_char(*pClassList, ' ', nPos, nLen);
+ while(nPos < nLen)
+ {
+ rtl::OUStringBuffer aTokenValue;
- rtl::OUString aId(".");
- const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
+ skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
- // look for CSS style common to token
- aId += aOUTokenValue;
- pNew = rDocument.findSvgStyleAttributesById(aId);
+ rtl::OUString aId(rtl::OUString::createFromAscii("."));
+ const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
- if(!pNew && !rClassStr.isEmpty())
- {
- // look for CSS style common to class.token
- aId = rClassStr + aId;
+ // look for CSS style common to token
+ aId = aId + aOUTokenValue;
+ pNew = rDocument.findSvgStyleAttributesById(aId);
- pNew = rDocument.findSvgStyleAttributesById(aId);
- }
+ if(!pNew && rClassStr.getLength())
+ {
+ // look for CSS style common to class.token
+ aId = rClassStr + aId;
- if(pNew)
- {
- const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
- }
+ pNew = rDocument.findSvgStyleAttributesById(aId);
}
- }
-
- // check for class-dependent references to CssStyles
- if(rClassStr.getLength())
- {
- // search for CSS style equal to class type
- const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
if(pNew)
{
- const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
+ maCssStyleVector.push_back(pNew);
}
}
}
+
+ // check for class-dependent references to CssStyles
+ if(rClassStr.getLength())
+ {
+ // search for CSS style equal to class type
+ const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
+
+ if(pNew)
+ {
+ maCssStyleVector.push_back(pNew);
+ }
+ }
+ }
+ }
+
+ const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+ {
+ if(!mbCssStyleVectorBuilt)
+ {
+ // build needed CssStyleVector for local node
+ const_cast< SvgNode* >(this)->fillCssStyleVector(rClassStr);
}
if(maCssStyleVector.empty())
{
- // return original if no CssStlyes found
+ // return given original if no CssStlyes found
return &rOriginal;
}
else
@@ -186,7 +221,9 @@ namespace svgio
mpClass(0),
maXmlSpace(XmlSpace_notset),
maDisplay(Display_inline),
- maCssStyleVector()
+ maCssStyleVector(),
+ mpLocalCssStyle(0),
+ mbCssStyleVectorBuilt(false)
{
OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)");
@@ -213,50 +250,59 @@ namespace svgio
maChildren.pop_back();
}
- if(mpId) delete mpId;
- if(mpClass) delete mpClass;
+ if(mpId)
+ {
+ delete mpId;
+ }
+
+ if(mpClass)
+ {
+ delete mpClass;
+ }
+
+ if(mpLocalCssStyle)
+ {
+ delete mpLocalCssStyle;
+ }
+ }
+
+ void SvgNode::readLocalCssStyle(const rtl::OUString& aContent)
+ {
+ if(!mpLocalCssStyle)
+ {
+ // create LocalCssStyle if needed but not yet added
+ mpLocalCssStyle = new SvgStyleAttributes(*this);
+ }
+ else
+ {
+ // 2nd fill would be an error
+ OSL_ENSURE(false, "Svg node has two local CssStyles, this may lead to problems (!)");
+ }
+
+ if(mpLocalCssStyle)
+ {
+ // parse and set values to it
+ mpLocalCssStyle->readStyle(aContent);
+ }
+ else
+ {
+ OSL_ENSURE(false, "Could not get/create a local CssStyle for a node (!)");
+ }
}
void SvgNode::parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs)
{
+ // no longer need to pre-sort moving 'style' entries to the back so that
+ // values get overwritten - that was the previous, not complete solution for
+ // handling the priorities between svg and Css properties
const sal_uInt32 nAttributes(xAttribs->getLength());
- // #i122522# SVG defines that 'In general, this means that the presentation attributes have
- // lower priority than other CSS style rules specified in author style sheets or style
- // attributes.' in http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes
- // (6.4 Specifying properties using the presentation attributes SVG 1.1). That means that
- // e.g. font-size will appear as presentation attribute and CSS style attribute. In these
- // cases, CSS style attributes need to have precedence. To do so it is possible to create
- // a proirity system for all properties of a shape, but it will also work to parse the
- // presentation attributes of type 'style' last, so they will overwrite the less-prioritized
- // already interpreted ones. Thus, remember SVGTokenStyle entries and parse them last.
- // To make this work it is required that parseAttribute is only called by parseAttributes
- // which is the case.
- std::vector< sal_uInt32 > aSVGTokenStyleIndexes;
for(sal_uInt32 a(0); a < nAttributes; a++)
{
const OUString aTokenName(xAttribs->getNameByIndex(a));
const SVGToken aSVGToken(StrToSVGToken(aTokenName));
- if(SVGTokenStyle == aSVGToken)
- {
- // #i122522# remember SVGTokenStyle entry
- aSVGTokenStyleIndexes.push_back(a);
- }
- else
- {
- parseAttribute(aTokenName, aSVGToken, xAttribs->getValueByIndex(a));
- }
- }
-
- // #i122522# parse SVGTokenStyle entries last to override already interpreted
- // 'presentation attributes' of potenially the same type
- for(sal_uInt32 b(0); b < aSVGTokenStyleIndexes.size(); b++)
- {
- const sal_uInt32 nSVGTokenStyleIndex(aSVGTokenStyleIndexes[b]);
- const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(nSVGTokenStyleIndex));
-
- parseAttribute(aTokenName, SVGTokenStyle, xAttribs->getValueByIndex(nSVGTokenStyleIndex));
+ parseAttribute(aTokenName, aSVGToken, xAttribs->getValueByIndex(a));
}
}
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index 73beb80..cf13a37 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -59,7 +59,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenD:
diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx
index a9abed5..a50892e 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -78,7 +78,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenViewBox:
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index 3b52ce4..09da02d 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -62,7 +62,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenPoints:
diff --git a/svgio/source/svgreader/svgrectnode.cxx b/svgio/source/svgreader/svgrectnode.cxx
index cd89c08..2ee3949 100644
--- a/svgio/source/svgreader/svgrectnode.cxx
+++ b/svgio/source/svgreader/svgrectnode.cxx
@@ -63,7 +63,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX:
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 4d9448a..b48431d 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -183,12 +183,38 @@ namespace svgio
if(!aTokenName.isEmpty())
{
- skip_char(rCandidate, ' ', ':', nPos, nLen);
- OUStringBuffer aTokenValue;
- copyToLimiter(rCandidate, ';', nPos, aTokenValue, nLen);
- skip_char(rCandidate, ' ', ';', nPos, nLen);
- const OUString aOUTokenName(aTokenName.makeStringAndClear());
- const OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
+ rtl::OUStringBuffer aTokenValue;
+ copyToLimiter(rCandidate, sal_Unicode(';'), nPos, aTokenValue, nLen);
+ skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
+ const rtl::OUString aOUTokenName(aTokenName.makeStringAndClear());
+ rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+
+ // check for '!important' CssStyle mark, currently not supported
+ // but neds to be extracted for correct parsing
+ static rtl::OUString aTokenImportant(RTL_CONSTASCII_USTRINGPARAM("!important"));
+ const sal_Int32 nIndexTokenImportant(aOUTokenValue.indexOf(aTokenImportant));
+
+ if(-1 != nIndexTokenImportant)
+ {
+ // if there currently just remove it and remove spaces to have the value only
+ rtl::OUString aNewOUTokenValue;
+
+ if(nIndexTokenImportant > 0)
+ {
+ // copy content before token
+ aNewOUTokenValue += aOUTokenValue.copy(0, nIndexTokenImportant);
+ }
+
+ if(aOUTokenValue.getLength() > nIndexTokenImportant + aTokenImportant.getLength())
+ {
+ // copy content after token
+ aNewOUTokenValue += aOUTokenValue.copy(nIndexTokenImportant + aTokenImportant.getLength());
+ }
+
+ // remove spaces
+ aOUTokenValue = aNewOUTokenValue.trim();
+ }
parseStyleAttribute(aOUTokenName, StrToSVGToken(aOUTokenName), aOUTokenValue);
}
diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx
index 99f7ff5..b17c528 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -92,17 +92,42 @@ namespace svgio
while(nPos < nLen)
{
+ // read the full style node names (may be multiple) and put to aStyleName
const sal_Int32 nInitPos(nPos);
- skip_char(aContent, ' ', '#', nPos, nLen);
- copyToLimiter(aContent, '{', nPos, aTokenValue, nLen);
- const OUString aStyleName = aTokenValue.makeStringAndClear().trim();
+ skip_char(aContent, sal_Unicode(' '), nPos, nLen);
+ copyToLimiter(aContent, sal_Unicode('{'), nPos, aTokenValue, nLen);
+ skip_char(aContent, sal_Unicode(' '), sal_Unicode('{'), nPos, nLen);
- if(!aStyleName.isEmpty() && nPos < nLen)
+ const rtl::OUString aStyleName(aTokenValue.makeStringAndClear().trim());
+ const sal_Int32 nLen2(aStyleName.getLength());
+ std::vector< rtl::OUString > aStyleNames;
+
+ if(nLen2)
{
- skip_char(aContent, ' ', '{', nPos, nLen);
- copyToLimiter(aContent, '}', nPos, aTokenValue, nLen);
- skip_char(aContent, ' ', '}', nPos, nLen);
- const OUString aStyleContent = aTokenValue.makeStringAndClear().trim();
+ // extract names
+ sal_Int32 nPos2(0);
+ rtl::OUStringBuffer aSingleName;
+
+ while(nPos2 < nLen2)
+ {
+ skip_char(aStyleName, sal_Unicode('#'), nPos2, nLen2);
+ copyToLimiter(aStyleName, sal_Unicode(' '), nPos2, aSingleName, nLen2);
+ skip_char(aStyleName, sal_Unicode(' '), nPos2, nLen2);
+
+ const rtl::OUString aOUSingleName(aSingleName.makeStringAndClear().trim());
+
+ if(aOUSingleName.getLength())
+ {
+ aStyleNames.push_back(aOUSingleName);
+ }
+ }
+ }
+
+ if(aStyleNames.size() && nPos < nLen)
+ {
+ copyToLimiter(aContent, sal_Unicode('}'), nPos, aTokenValue, nLen);
+ skip_char(aContent, sal_Unicode(' '), sal_Unicode('}'), nPos, nLen);
+ const rtl::OUString aStyleContent(aTokenValue.makeStringAndClear().trim());
if(!aStyleContent.isEmpty())
{
@@ -113,8 +138,16 @@ namespace svgio
// fill with content
pNewStyle->readStyle(aStyleContent);
- // register new style at document
- const_cast< SvgDocument& >(getDocument()).addSvgStyleAttributesToMapper(aStyleName, *pNewStyle);
+ // concatenate combined style name
+ rtl::OUString aConcatenatedStyleName;
+
+ for(sal_uInt32 a(0); a < aStyleNames.size(); a++)
+ {
+ aConcatenatedStyleName += aStyleNames[a];
+ }
+
+ // register new style at document for (evtl. concatenated) stylename
+ const_cast< SvgDocument& >(getDocument()).addSvgStyleAttributesToMapper(aConcatenatedStyleName, *pNewStyle);
}
}
diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx
index 6c39cc9..d6d2a83 100644
--- a/svgio/source/svgreader/svgsvgnode.cxx
+++ b/svgio/source/svgreader/svgsvgnode.cxx
@@ -69,8 +69,23 @@ namespace svgio
if(pStyles && pStyles->getParentStyle())
{
- // #i125258# no initial values when SVG has a parent style (probably CssStyle)
- bSetInitialValues = false;
+ // SVG has a parent style (probably CssStyle), check if fill is set there anywhere
+ // already. If yes, do not set the default fill (black)
+ bool bFillSet(false);
+ const SvgStyleAttributes* pParentStyle = pStyles->getParentStyle();
+
+ while(pParentStyle && !bFillSet)
+ {
+ bFillSet = pParentStyle->isFillSet();
+ pParentStyle = pParentStyle->getParentStyle();
+ }
+
+ if(bFillSet)
+ {
+ // #125258# no initial values when SVG has a parent style at which a fill
+ // is already set
+ bSetInitialValues = false;
+ }
}
}
@@ -113,7 +128,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenViewBox:
diff --git a/svgio/source/svgreader/svgsymbolnode.cxx b/svgio/source/svgreader/svgsymbolnode.cxx
index ca76e1a..c131059 100644
--- a/svgio/source/svgreader/svgsymbolnode.cxx
+++ b/svgio/source/svgreader/svgsymbolnode.cxx
@@ -58,7 +58,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenViewBox:
diff --git a/svgio/source/svgreader/svgtextnode.cxx b/svgio/source/svgreader/svgtextnode.cxx
index 21565a3..9ef3c7f 100644
--- a/svgio/source/svgreader/svgtextnode.cxx
+++ b/svgio/source/svgreader/svgtextnode.cxx
@@ -66,7 +66,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx
index 7934a1d..aba2624 100644
--- a/svgio/source/svgreader/svgtextpathnode.cxx
+++ b/svgio/source/svgreader/svgtextpathnode.cxx
@@ -280,7 +280,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenStartOffset:
diff --git a/svgio/source/svgreader/svgtrefnode.cxx b/svgio/source/svgreader/svgtrefnode.cxx
index 8e37b9e..961e1a4 100644
--- a/svgio/source/svgreader/svgtrefnode.cxx
+++ b/svgio/source/svgreader/svgtrefnode.cxx
@@ -55,7 +55,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenXlinkHref:
diff --git a/svgio/source/svgreader/svgtspannode.cxx b/svgio/source/svgreader/svgtspannode.cxx
index 1397249..b837e72 100644
--- a/svgio/source/svgreader/svgtspannode.cxx
+++ b/svgio/source/svgreader/svgtspannode.cxx
@@ -58,7 +58,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
default:
diff --git a/svgio/source/svgreader/svgusenode.cxx b/svgio/source/svgreader/svgusenode.cxx
index 650b73e..c0220b7 100644
--- a/svgio/source/svgreader/svgusenode.cxx
+++ b/svgio/source/svgreader/svgusenode.cxx
@@ -62,7 +62,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
More information about the Libreoffice-commits
mailing list