25#include <osl/diagnose.h>
54 std::vector< OUString > parseClass(
const SvgNode& rNode)
56 std::vector< OUString > aParts;
61 const OUString& rClassList = *rNode.
getClass();
62 const sal_Int32 nLen(rClassList.getLength());
67 OUStringBuffer aToken;
71 const sal_Int32 nInitPos(nPos);
79 aParts.push_back(aPart);
84 OSL_ENSURE(
false,
"Could not interpret on current position (!)");
97 const OUString& aConcatenated)
109 const OUString& rId = *rCurrent.
getId();
113 const OUString aNewConcatenated(
114 "#" + rId + aConcatenated);
123 if(!aConcatenated.isEmpty() && pParent && pParent->
getId())
125 const OUString& rParentId = pParent->
getId().value();
126 addCssStyle(rDocument,
"#" + rParentId + aConcatenated);
131 std::vector <OUString> aClasses = parseClass(rCurrent);
132 for(
const auto &aClass : aClasses)
134 const OUString aNewConcatenated(
"." + aClass + aConcatenated);
143 if(!aConcatenated.isEmpty() && pParent)
145 std::vector <OUString> aParentClasses = parseClass(*pParent);
146 for(
const auto &aParentClass : aParentClasses)
148 addCssStyle(rDocument,
"." + aParentClass + aConcatenated);
156 if(sCurrentType.isEmpty())
159 OUString aNewConcatenated(aConcatenated);
161 if(!rCurrent.
getId() && !rCurrent.
getClass() && 0 == aConcatenated.indexOf(sCurrentType))
168 aNewConcatenated = sCurrentType + aConcatenated;
183 addCssStyle(rDocument, sParentType + sCurrentType);
200 if (pParent->
getId().has_value())
202 sParentId = pParent->
getId().value();
204 std::vector <OUString> aParentClasses = parseClass(*pParent);
209 const OUString& rId = *rCurrent.
getId();
213 if (!sParentId.isEmpty())
215 const OUString aConcatenated(
"#" + sParentId +
">#" + rId);
219 for(
const auto &aParentClass : aParentClasses)
221 const OUString aConcatenated(
"." + aParentClass +
">#" + rId);
225 if (!sParentType.isEmpty())
227 const OUString aConcatenated(sParentType +
">#" + rId);
234 std::vector <OUString> aClasses = parseClass(rCurrent);
235 for(
const auto &aClass : aClasses)
238 if (!sParentId.isEmpty())
240 const OUString aConcatenated(
"#" + sParentId +
">." + aClass);
244 for(
const auto &aParentClass : aParentClasses)
246 const OUString aConcatenated(
"." + aParentClass +
">." + aClass);
250 if (!sParentType.isEmpty())
252 const OUString aConcatenated(sParentType +
">." + aClass);
259 if(!sCurrentType.isEmpty())
261 if (!sParentId.isEmpty())
263 const OUString aConcatenated(
"#" + sParentId +
">" + sCurrentType);
267 for(
const auto &aParentClass : aParentClasses)
269 const OUString aConcatenated(
"." + aParentClass +
">" + sCurrentType);
273 if (!sParentType.isEmpty())
275 const OUString aConcatenated(sParentType +
">" + sCurrentType);
390 mrDocument(rDocument),
392 mpAlternativeParent(nullptr),
395 mbDecomposing(false),
396 mbCssStyleVectorBuilt(false)
422 OSL_ENSURE(
false,
"Svg node has two local CssStyles, this may lead to problems (!)");
432 OSL_ENSURE(
false,
"Could not get/create a local CssStyle for a node (!)");
441 const sal_uInt32
nAttributes(xAttribs->getLength());
445 const OUString aTokenName(xAttribs->getNameByIndex(
a));
454 if(!aContent.empty())
540 if(!aContent.isEmpty())
548 if(!aContent.isEmpty())
556 if(!aContent.isEmpty())
571 if(!aContent.isEmpty())
622 if(rChildren.empty())
627 const sal_uInt32
nCount(rChildren.size());
631 SvgNode* pCandidate = rChildren[
a].get();
635 const auto& rGrandChildren = pCandidate->
getChildren();
645 if(!aNewTarget.empty())
653 OSL_ENSURE(
false,
"Null-Pointer in child node list (!)");
663 const OUString& rTitle = pStyles->
getTitle();
664 const OUString& rDesc = pStyles->
getDesc();
666 if(!rTitle.isEmpty() || !rDesc.isEmpty())
669 OUString aObjectName;
676 if(!aObjectName.isEmpty())
680 aObjectName =
aURL.getName(
797 rVisitor.
visit(*
this);
void removeSvgNodeFromMapper(const OUString &rStr)
void addSvgNodeToMapper(const OUString &rStr, const SvgNode &rNode)
add/remove nodes with Id to mapper
const OUString & getAbsolutePath() const
const SvgStyleAttributes * findGlobalCssStyleAttributes(const OUString &rStr) const
void addOrphanNode(SvgNode *pOrphan)
invalid nodes that have no parent
bool hasGlobalCssStyleAttributes() const
find a style by its Id
void parseAttributes(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs)
style helpers
virtual ~SvgNode() override
virtual bool supportsParentStyle() const
#i125258# tell if this node is allowed to have a parent style (e.g. defs do not)
std::optional< OUString > const & getId() const
Id access.
std::unique_ptr< SvgStyleAttributes > mpLocalCssStyle
possible local CssStyle, e.g. style="fill:red; stroke:red;"
const std::vector< std::unique_ptr< SvgNode > > & getChildren() const
Display getDisplay() const
Display access #i121656#.
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer &rTarget, bool bReferenced) const
SVGToken getType() const
basic data read access
SvgNode(SVGToken aType, SvgDocument &rDocument, SvgNode *pParent)
void fillCssStyleVectorUsingHierarchyAndSelectors(const SvgNode &rCurrent, const OUString &aConcatenated)
const SvgStyleAttributes * checkForCssStyle(const SvgStyleAttributes &rOriginal) const
helper to evtl. link to css style
void setXmlSpace(XmlSpace eXmlSpace)
std::vector< std::unique_ptr< SvgNode > > maChildren
sub hierarchy
XmlSpace getXmlSpace() const
XmlSpace access.
void setClass(OUString const &)
XmlSpace maXmlSpace
XmlSpace value.
virtual double getCurrentXHeightInherited() const override
return xheight of node inherited from parents
double getCurrentXHeight() const
::std::vector< const SvgStyleAttributes * > maCssStyleVector
const SvgNode * getParent() const
std::optional< OUString > mpId
Id svan value.
std::optional< OUString > mpClass
Class svan value.
void fillCssStyleVector(const SvgStyleAttributes &rOriginal)
helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
virtual double getCurrentFontSizeInherited() const override
return font size of node inherited from parents
std::optional< OUString > const & getClass() const
Class access.
bool mbCssStyleVectorBuilt
virtual basegfx::B2DRange getCurrentViewPort() const override
InfoProvider support for %, em and ex values.
void fillCssStyleVectorUsingParent(const SvgNode &rCurrent)
double getCurrentFontSize() const
void addCssStyle(const SvgDocument &rDocument, const OUString &aConcatenated)
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent)
void accept(Visitor &rVisitor)
void setId(OUString const &)
void readLocalCssStyle(std::u16string_view aContent)
scan helper to read and interpret a local CssStyle to mpLocalCssStyle
virtual const SvgStyleAttributes * getSvgStyleAttributes() const
const SvgDocument & getDocument() const
void setDisplay(Display eDisplay)
double solve(const InfoProvider &rInfoProvider, NumberType aNumberType=NumberType::length) const
const OUString & getTitle() const
const OUString & getDesc() const
Visibility getVisibility() const
Visibility.
SvgNumber getFontSizeNumber() const
void setCssStyleParent(const SvgStyleAttributes *pNew)
helper to set mpCssStyleParent temporarily for CSS style hierarchies
virtual void visit(SvgNode const &pNode)=0
RegionData_Impl * mpParent
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
OUString SVGTokenToStr(const SVGToken &rToken)
void skip_char(std::u16string_view rCandidate, sal_Unicode nChar, sal_Int32 &nPos, const sal_Int32 nLen)
SVGToken StrToSVGToken(const OUString &rStr, bool bCaseIndependent)
void copyToLimiter(std::u16string_view rCandidate, sal_Unicode nLimiter, sal_Int32 &nPos, OUStringBuffer &rTarget, const sal_Int32 nLen)
Display getDisplayFromContent(std::u16string_view aContent)