Kaydet (Commit) afe7392f authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Xisco Faulí

SVG: Clean up this code a litle bit

Change-Id: Ib941321d43a9a04d57f3c7c4a55528927fed5036
Reviewed-on: https://gerrit.libreoffice.org/24009Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarXisco Faulí <anistenis@gmail.com>
üst 31bddb87
...@@ -123,7 +123,7 @@ namespace svgio ...@@ -123,7 +123,7 @@ namespace svgio
const SvgStyleAttributes* checkForCssStyle(const 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 /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
void fillCssStyleVector(const OUString& rClassStr); void fillCssStyleVector(const OUString& rClassStr, const SvgStyleAttributes& rOriginal);
void fillCssStyleVectorUsingHierarchyAndSelectors( void fillCssStyleVectorUsingHierarchyAndSelectors(
const OUString& rClassStr, const OUString& rClassStr,
const SvgNode& rCurrent, const SvgNode& rCurrent,
......
...@@ -162,7 +162,7 @@ namespace svgio ...@@ -162,7 +162,7 @@ namespace svgio
} }
} }
void SvgNode::fillCssStyleVector(const OUString& rClassStr) void SvgNode::fillCssStyleVector(const OUString& rClassStr, const SvgStyleAttributes& rOriginal)
{ {
OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?"); OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?");
mbCssStyleVectorBuilt = true; mbCssStyleVectorBuilt = true;
...@@ -199,6 +199,9 @@ namespace svgio ...@@ -199,6 +199,9 @@ namespace svgio
// add CssStyle for selector '*' if found // add CssStyle for selector '*' if found
maCssStyleVector.push_back(pNew); maCssStyleVector.push_back(pNew);
} }
//local attributes
maCssStyleVector.push_back(&rOriginal);
} }
const SvgStyleAttributes* SvgNode::checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const const SvgStyleAttributes* SvgNode::checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
...@@ -206,7 +209,7 @@ namespace svgio ...@@ -206,7 +209,7 @@ namespace svgio
if(!mbCssStyleVectorBuilt) if(!mbCssStyleVectorBuilt)
{ {
// build needed CssStyleVector for local node // build needed CssStyleVector for local node
const_cast< SvgNode* >(this)->fillCssStyleVector(rClassStr); const_cast< SvgNode* >(this)->fillCssStyleVector(rClassStr, rOriginal);
} }
if(maCssStyleVector.empty()) if(maCssStyleVector.empty())
...@@ -232,7 +235,6 @@ namespace svgio ...@@ -232,7 +235,6 @@ namespace svgio
// for the element containing the hierarchy) in a vector of pointers and to use that. // for the element containing the hierarchy) in a vector of pointers and to use that.
// Resetting the CssStyleParent on rOriginal is probably not needed // Resetting the CssStyleParent on rOriginal is probably not needed
// but simply safer to do. // but simply safer to do.
const_cast< SvgStyleAttributes& >(rOriginal).setCssStyleParent(nullptr);
// loop over the existing CssStyles and link them. There is a first one, take // loop over the existing CssStyles and link them. There is a first one, take
// as current // as current
...@@ -246,9 +248,6 @@ namespace svgio ...@@ -246,9 +248,6 @@ namespace svgio
pCurrent = pNext; pCurrent = pNext;
} }
// pCurrent is the last used CssStyle, let it point to the original style
pCurrent->setCssStyleParent(&rOriginal);
// return 1st CssStyle as style chain start element (only for the // return 1st CssStyle as style chain start element (only for the
// local element, still no hierarchy used here) // local element, still no hierarchy used here)
return maCssStyleVector[0]; return maCssStyleVector[0];
......
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