svgnode.cxx (50b37974) | svgnode.cxx (0906e779) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 29 unchanged lines hidden (view full) --- 38 { 39 const SvgStyleAttributes* SvgNode::getSvgStyleAttributes() const 40 { 41 return 0; 42 } 43 44 const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const 45 { | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 29 unchanged lines hidden (view full) --- 38 { 39 const SvgStyleAttributes* SvgNode::getSvgStyleAttributes() const 40 { 41 return 0; 42 } 43 44 const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const 45 { |
46 const SvgDocument& rDocument = getDocument(); 47 48 if(rDocument.hasSvgStyleAttributesById()) | 46 if(maCssStyleVector.empty()) // #120435# Evaluate for CSS styles only once, this cannot change |
49 { | 47 { |
50 if(getClass()) | 48 const SvgDocument& rDocument = getDocument(); 49 50 if(rDocument.hasSvgStyleAttributesById()) |
51 { | 51 { |
52 // find all referenced CSS styles, a list of entries is allowed 53 const rtl::OUString* pClassList = getClass(); 54 const sal_Int32 nLen(pClassList->getLength()); 55 sal_Int32 nPos(0); 56 const SvgStyleAttributes* pNew = 0; | 52 if(getClass()) 53 { 54 // find all referenced CSS styles, a list of entries is allowed 55 const rtl::OUString* pClassList = getClass(); 56 const sal_Int32 nLen(pClassList->getLength()); 57 sal_Int32 nPos(0); 58 const SvgStyleAttributes* pNew = 0; |
57 | 59 |
58 skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); | 60 skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); |
59 | 61 |
60 while(nPos < nLen) 61 { 62 rtl::OUStringBuffer aTokenValue; | 62 while(nPos < nLen) 63 { 64 rtl::OUStringBuffer aTokenValue; |
63 | 65 |
64 copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen); 65 skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); | 66 copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen); 67 skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); |
66 | 68 |
67 rtl::OUString aId(rtl::OUString::createFromAscii(".")); 68 const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear()); | 69 rtl::OUString aId(rtl::OUString::createFromAscii(".")); 70 const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear()); |
69 | 71 |
70 // look for CSS style common to token 71 aId = aId + aOUTokenValue; 72 pNew = rDocument.findSvgStyleAttributesById(aId); | 72 // look for CSS style common to token 73 aId = aId + aOUTokenValue; 74 pNew = rDocument.findSvgStyleAttributesById(aId); |
73 | 75 |
74 if(!pNew && rClassStr.getLength()) 75 { 76 // look for CSS style common to class.token 77 aId = rClassStr + aId; | 76 if(!pNew && rClassStr.getLength()) 77 { 78 // look for CSS style common to class.token 79 aId = rClassStr + aId; |
78 | 80 |
79 pNew = rDocument.findSvgStyleAttributesById(aId); 80 } | 81 pNew = rDocument.findSvgStyleAttributesById(aId); 82 } |
81 | 83 |
84 if(pNew) 85 { 86 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 87 } 88 } 89 } 90 91 if(maCssStyleVector.empty() && getId()) 92 { 93 // if none found, search for CSS style equal to Id 94 const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId()); 95 |
|
82 if(pNew) 83 { 84 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 85 } 86 } | 96 if(pNew) 97 { 98 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 99 } 100 } |
87 } 88 89 if(maCssStyleVector.empty() && getId()) 90 { 91 // if none found, search for CSS style equal to Id 92 const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId()); | |
93 | 101 |
94 if(pNew) | 102 if(maCssStyleVector.empty() && rClassStr.getLength()) |
95 { | 103 { |
96 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 97 } 98 } 99 100 if(maCssStyleVector.empty() && rClassStr.getLength()) 101 { 102 // if none found, search for CSS style equal to class type 103 const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr); | 104 // if none found, search for CSS style equal to class type 105 const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr); |
104 | 106 |
105 if(pNew) 106 { 107 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); | 107 if(pNew) 108 { 109 const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 110 } |
108 } 109 } 110 } 111 112 if(maCssStyleVector.empty()) 113 { 114 return &rOriginal; 115 } 116 else 117 { 118 // set CssStyleParent at maCssStyleVector members to hang them in front of | 111 } 112 } 113 } 114 115 if(maCssStyleVector.empty()) 116 { 117 return &rOriginal; 118 } 119 else 120 { 121 // set CssStyleParent at maCssStyleVector members to hang them in front of |
119 // the existing style | 122 // the existing style. Build a style chain, reset parent of original for security. 123 // Repeated style requests should only be issued from sub-Text nodes and I'm not 124 // sure if in-between text nodes may build other chains (should not happen). But 125 // it's only a re-chaining with pointers (cheap), so allow to do it every time. |
120 SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal); | 126 SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal); |
127 pCurrent->setCssStyleParent(0); |
|
121 122 for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++) 123 { 124 SvgStyleAttributes* pCandidate = const_cast< SvgStyleAttributes* >(maCssStyleVector[maCssStyleVector.size() - a - 1]); 125 126 pCandidate->setCssStyleParent(pCurrent); 127 pCurrent = pCandidate; 128 } --- 301 unchanged lines hidden --- | 128 129 for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++) 130 { 131 SvgStyleAttributes* pCandidate = const_cast< SvgStyleAttributes* >(maCssStyleVector[maCssStyleVector.size() - a - 1]); 132 133 pCandidate->setCssStyleParent(pCurrent); 134 pCurrent = pCandidate; 135 } --- 301 unchanged lines hidden --- |